Integrating Non-Parametric Attention and Prompt Refinement to Enhance LLM-Based Text-to-SQL Without External Knowledge

Sarker S, Qian L, Dong X

Sarker et al., 2025 IEEE International Conference on Data Mining Workshops (ICDMW), pp. 440-449, 2025 | | https://doi.org/10.1109/ICDMW69685.2025.00056.


Abstract

Text-to-SQL enables users without specialized database expertise to efficiently retrieve information by automatically translating natural language (NL) queries into machine-executable SQL statements. Recently, large language model (LLM)-based Text-to-SQL approaches have demonstrated remarkable performance by leveraging in-context learning and fine-tuning strategies. In particular, LLM-based Text-to-SQL without external knowledge offers a cost-effective solution while still achieving competitive performance compared to knowledge-enhanced methods. This study proposes a novel approach that integrates non-parametric attention and prompt refinement to further enhance LLM-based Text-to-SQL without the external knowledge. The non-parametric attention mechanism dynamically assigns different weights to database schema elements, such as tables and columns based on the correlations between schema elements, effectively capturing their relational importance. Additionally, the prompt is initialized and iteratively refined using the confidence scores of the SQL generated by LLMs, improving the quality of the final SQL statements. Generative Pre-trained Transformer (GPT)-based proposed method is evaluated on the BIRD benchmark dataset using Execution Accuracy (EX) and Valid Efficiency Score (VES) as performance metrics. Evaluated on the BIRD benchmark, our method improves Execution Accuracy (EX) by 6.5% over a vanilla GPT-4o baseline. We also conduct a comprehensive ablation study which confirms that both the non-parametric attention and the prompt refinement loop are critical components that contribute significantly to the overall performance gain.

Integrating Non-Parametric Attention and Prompt Refinement to Enhance LLM-Based Text-to-SQL Without External Knowledge

Keywords

Text-to-SQL, Large Language Models, prompt refinement, non-parametric attention, in-context learning, database query generation