# Domain-Specific Few-Shot Table Prompt Question Answering via Contrastive Exemplar Selection
## 3 Methodology
### Exemplar Retrieval Approach
On the other hand, the proposed EPR method achieved a score of 63.5% on SC, showing an improvement of 18.2% compared to zero-shot. In terms of the SA metric, the random model and the BM25 model achieved scores of 32.9% and 37.4%, respectively, showing improvements of 8.4% and 12.9% compared to zero-shot. The proposed EPR method, on the other hand, showed an improvement of 19.1%. For the WN, WC, WO, and WV metrics, the random model, BM25 model, and EPR method all exhibited varying degrees of performance improvement. Overall, the experimental results demonstrate that exemplar injection has a significant effect on improving sub-module tasks, especially with our proposed EPR method showing the best performance across multiple metrics. This indicates that the EPR method can better utilize exemplar information to enhance the performance of SMI-SQL tasks. ### Case Analysis

Further qualitatively compare and analyze the impact of zero-shot, random sampling, BM25, and the proposed EPR strategy exemplar selection on downstream text-to-SQL tasks by selecting two examples from ESQL and SMI-SQL, respectively. As shown in Table 8, under the zero-shot condition, the SQL generated by the ESQL dataset is formatted in a disorderly fashion, leading to situations where the generated SQL is NOSQL, and it exhibits a strong degree of randomness, resulting in lower accuracy. In comparison, the random sampling and BM25 strategies generate SQL with higher relevance to the question after injecting samples, but there are still errors in predicting submodules such as condition columns, aggregation functions, etc., leading to SQL errors. However, the proposed EPR strategy in this paper can better understand the problem, provide high-quality exemplar \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Models** & **SC** & **SA** & **WN** & **WC** & **WO** & **WV** \\ \hline ZERO SHOT & 22.3\% & 28.9\% & 41.4\% & 17.6\% & 24.4\% & 22.9\% \\ RANDOM & 41.8\% & 33.5\% & 44.6\% & 27.4\% & 36.8\% & 26.4\% \\ BM25 & 59.6\% & 37.6\% & 49.7\% & 34.6\% & 37.4\% & 27.5\% \\ EPR(Ours) & 61.8\% & 44.5\% & 52.3\% & 37.5\% & 45.8\% & 34.2\% \\ \hline \hline \end{tabular}
\end{table} 
Table 6: Comparison results of exemplar retrieval prompt strategies for ESQL submodules. \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Models** & **SC** & **SA** & **WN** & **WC** & **WO** & **WV** \\ \hline ZERO SHOT & 45.3\% & 24.5\% & 33.7\% & 15.6\% & 20.3\% & 17.1\% \\ RANDOM & 53.4\% & 32.9\% & 45.2\% & 22.8\% & 32.7\% & 22.5\% \\ BM25 & 58.9\% & 37.4\% & 47.9\% & 30.5\% & 38.9\% & 27.8\% \\ EPR(Ours) & 63.5\% & 43.6\% & 50.4\% & 39.7\% & 47.5\% & 33.7\% \\ \hline \hline \end{tabular}
\end{table} 
Table 7: Comparison results of exemplar retrieval prompt strategies for SMI-SQL submodules. to guide the large language model's generation, and achieve correct predictions under the above circumstances. Table 9 presents a comparison of different exemplar retrieval strategies in SMI-SQL. Similar to ESQL, the model's output under zero-shot conditions still includes NOSQL and complex SQL outputs that do not align with the questions. After injecting exemplars using different strategies, the relevance of the model's output to the questions is significantly improved. However, random sampling and BM25 strategies still exhibit some errors in predicting certain sub-modules. In contrast, the output guided by the EPR strategy proposed in this paper per-forms well in terms of sub-module logical form and overall SQL execution result accuracy. Table 10 presents the case analysis of examples where the proposed EPR method still fails to correctly parse the ESQL and SMI-SQL datasets. Firstly, the proposed method still exhibits sub-module prediction errors such as WHERE clause operators and query columns in text-to-SQL tasks. For instance, in Question-1, the model incorrectly predicted '=' as '<', while in Question-3, it made an extra prediction of the query column 'level code'. For the simple query in Question 1, the EPR model failed to produce the correct output condition.