# Domain-Specific Few-Shot Table Prompt Question Answering via Contrastive Exemplar Selection
## 3 Methodology
### Exemplar Retrieval Approach
### Experimental Results

The experimental results of various prompt template retrieval strategies on the ESQL dataset are compared in Table 4. The evaluation of Syn-SQL under the zero-shot condition is 57.7%, and the legality of each method is significantly improved after injecting exemplars. In particular, when using the EPR approach, the legality score of SQL reaches 92.6%, indicating excellent performance of the EPR retrieval strategy in assisting large language models to improve grammatical correctness. In terms of LF and EX metrics, the EPR approach also performs well, achieving 23.3% and 35.8%, respectively, surpassing the zero-shot 20.2% and 27.2% and significantly outperforming other comparative strategies. This demonstrates that EPR can generate SQL statements that match the query intent. It is worth noting that although EPR's LF and EX are lower compared to Syn-SQL, primarily due to the strong domain-specific nature and complexity of the ESQL and SMI-SQL datasets, this does not negate the practical benefits it brings. Table 5 shows the experimental comparison results of various prompt template retrieval strategies on the SMI-SQL dataset. The results indicate that the Syn-SQL score under zero-shot conditions is 58.6%. However, after injecting exemplars, the legality of SQL queries significantly improved. Specifically, the proposed EPR strategy achieved the highest legality score of 95.8%, surpassing other methods significantly. Additionally, the EPR model demonstrated outstanding performance in LF and EX accuracy evaluations, reaching 22.4% and 36.2%, respectively, outperforming the random strategy's 11.9% and 20.9%. This further proves the advantage of the EPR model in generating semantically accurate SQL queries and demonstrates its robustness across multiple domain-specific datasets. Table 6 presents the comparison results of exemplar retrieval strategies for submodules in the ESQL dataset. Compared to the zero-shot scenario, the exemplar injection \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Models** & **Syn-SQL** & **LF** & **EX** \\ \hline ZERO SHOT & \(57.7\%\) & 3.1\% & 8.6\% \\ RANDOM & 84.9\% & 9.8\% & 13.1\% \\ BM25 & 88.4\% & 15.4\% & 27.6\% \\ EPR(Ours) & 92.6\% & 23.3\% & 35.8\% \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Comparison of prompt retrieval strategies in the ESQL dataset. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Models** & **Syn-SQL** & **LF** & **EX** \\ \hline ZERO SHOT & 58.6\% & 2.9\% & 11.0\% \\ RANDOM & 87.9\% & 10.5\% & 15.3\% \\ BM25 & 90.5\% & 17.8\% & 33.4\% \\ EPR(Ours) & 95.8\% & 22.4\% & 36.2\% \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Comparison of prompt retrieval strategies in the SMI-SQL dataset. showed performance improvements for each submodule task. Taking the SC submodule as an example, the random sampling strategy and BM25 strategy improved by 19.5% and 37.3%, respectively, compared to zero-shot. The proposed EPR method achieved a 39.5% improvement. The experimental results demonstrate the significant effectiveness of exemplar injection in improving submodule tasks, especially with the best performance achieved by the EPR method proposed in this paper. This indicates that the EPR method can better utilize exemplar information to enhance the performance of text-to-SQL tasks. The experimental results across different submodule tasks confirm the effectiveness of exemplar injection and provide valuable insights for further research and improvement. Table 7 presents the comparison results of exemplar retrieval strategies for submodules under the ESQL dataset. The results show the performance scores of various exemplar injection strategies on six text-to-SQL subtasks. In terms of the SC metric, the random model achieved a score of 53.4% compared to zero-shot, an improvement of 8.1 percentage points. The BM25 model scored 58.9% on SC, showing an improvement of 13.6 percentage points compared to zero-shot.