# Domain-Specific Few-Shot Table Prompt Question Answering via Contrastive Exemplar Selection
## 3 Methodology
### Exemplar Retrieval Approach
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Dataset** & **Models** & **Result** \\ \hline \hline \multirow{8}{*}{ESQL} & \multicolumn{3}{c}{Question-1} \\  & \multicolumn{3}{c}{The total number of units for which the Engineering Project Management Index is not equal to 3959.82 is how many?} \\ \cline{2-3}  & Golden & SELECT COUNT (‘Company name’) FROM table_4 WHERE ‘the \\  & \multicolumn{3}{c}{Engineering Project Management Index’!= “3959.82”} \\ \cline{2-3}  & EPR & SELECT COUNT (‘Company name’) FROM table_4 WHERE ‘the \\  & \multicolumn{3}{c}{Engineering Project Management Index’! \(<\) “3959.82”} \\ \cline{2-3}  & \multicolumn{3}{c}{Question-2} \\  & \multicolumn{3}{c}{In companies located in Jiangxi province with a product inventory turnover rate of less than 45.42\%, how many regions have operating revenues higher than 4730.85 units?} \\ \cline{2-3}  & Golden & SELECT COUNT (‘Company name’) FROM table_8 WHERE ‘province’ \\  & \multicolumn{3}{c}{\(=\) “Jiangxi” AND ‘The product inventory turnover rate’ \(<\) “45.42\%”} \\  & \multicolumn{3}{c}{AND ‘The regional operating income’ \(>\) “4730.85”} \\ \cline{2-3}  & EPR & SELECT COUNT(‘) FROM table_8 WHERE’ The product inventory turnover rate’ \(<\) “45.42\%” AND ‘The regional operating income’ \(>\) “4730.85” AND ‘province’ \(=\) “Jiangxi” \\ \hline \hline \multirow{8}{*}{SMI-SQL} & \multicolumn{3}{c}{Question-3} \\  & \multicolumn{3}{c}{The status of anchor cable gauge 45-14 of the main bridge (steel-concrete composite arch bridge) of the Yuehai Bridge is what?} \\ \cline{2-3}  & Golden & SELECT ‘Sensor status’ FROM t_sensor WHERE ‘Bridge name’ = “The main bridge (steel-concrete composite arch bridge) of the Yuehai Bridge” AND ‘Sensor name’ = “The anchor cable gauge 45-14” \\ \cline{2-3}  & EPR & SELECT ‘Grade code’, ‘Sensor status’ FROM t_sensor WHERE ‘Grade \\  & \multicolumn{3}{c}{code’ = “45-14” AND ‘Sensor name’ = “The anchor cable gauge”} \\ \cline{2-3}  & \multicolumn{3}{c}{Question-4} \\  & \multicolumn{3}{c}{How many very long tunnels are there in Yuanzhou District?} \\ \cline{2-3}  & Golden & SELECT COUNT (‘Tunnel name’) FROM tunnel_basic WHERE \\  & \multicolumn{3}{c}{‘Locality’ = “Yuanzhou District” AND ‘Tunnel classification’ = “Very  long tunnels”} \\ \cline{2-3}  & EPR & SELECT COUNT(‘) FROM tunnel_basic WHERE Tunnel classification’ = “Very long tunnels” AND ‘Locality’ = “Yuanzhou District” \\ \hline \hline \end{tabular}
\end{table} 
Table 10: EPR case analysis. ## 5 Conclusions

This paper proposes a few-shot table QA method based on prompt engineering on large language models in domain-specific contexts. This method involves restructuring input using input and output prompt templates for all test data, standardizing the model's output, and employing an efficient exemplar retrieval strategy to inject exemplars with the highest relevance to the current question to guide the large language model output, significantly improving accuracy in zero-shot scenarios. We evaluated the proposed method on the ESQL and SMI-SQL datasets and achieved optimal performance, particularly outperforming the compared random sampling strategy and BM25 strategy. Methodology, T.M. ; validation, T.M. and H.Z. ; formal analysis, T.M., Q.X., R.L. and Y.W. ; investigation, Q.X. ; data curation, Q.X. ; writing--original draft preparation, T.M. ; writing--review and editing, R.L. ; visualization, H.Z. ; supervision, Y.W. ; funding acquisition, R.L. All authors have read and agreed to the published version of the manuscript. This work was supported by the science and technology research program of the Chongqing Municipal Education Commission of China under grant KJZD-M202300703 and KJQN202200720, the Natural Science Foundation of Chongqing, China, under grant CSTB2023 NSCQ-MSX0145. The data presented in this study are available on request from the corresponding author due to funding agreement restrictions. Figure 3: The comparison results of various models on the ESQL dataset. Figure 2: The comparison results of various models on the ESQL dataset.