Improving SQL Generation with Schema Retrieval and Reaction Mechanism
摘要
Text-to-SQL is one of the crucial tasks in natural language processing. We present an innovative approach to the text-to-SQL parsing challenge, leveraging retrieval-driven in-context learning to enhance the performance of large language model (LLMs) in translating natural language queries into SQL queries. We address the critical challenges of schema linking and SQL generation quality by incorporates a schema-similar retrieval module and a Reaction mechanism for error correction. Our schema-similar retrieval module identifies and integrates the most contextually relevant data from the database schema into the LLMs’ input, significantly improving the model's reasoning capabilities. The Reaction mechanism introduces a novel verification process during SQL generation, ensuring syntactical correctness and query accuracy. Our method has been rigorously tested on the Archer, a complex bilingual text-to-SQL dataset known for its demanding reasoning requirements. The results demonstrate a remarkable improvement in query accuracy, achieving 42.56% on the Archer dataset, surpassing both Deepseek and GPT-4o baselines. This advancement not only streamlines the interaction between non-expert users and database access but also contributes to the broader field of natural language processing by pushing the boundaries of LLMs applicability in structured query generation.