NL2SQL with Iterative Self-Refinement
Anjali Vemula, Akshat Dasula
Key points
From the paper's conclusion- We introduce a multi-agent, persona-driven NL2SQL framework that combines (1) domain relevance detection, (2) schema-grounded knowledge construction, (3) KPI-aware SQL synthesis, (4) syntax-level self-repair using sqlite execution feedback, and (5) semantic consistency checking via SQL-to-NL reverse engineering.
Abstract
Bridging the gap between human intent and machine logic remains a critical challenge in data access for non-technical users, yet Large Language Models (LLMs) remain unreliable: they hallucinate schema elements, generate syntactically invalid queries, or fail to capture user intent. These limitations are especially critical in domains such as insurance, where KPIs, regulatory constraints, and legacy relational systems demand high precision. We introduce a multi-agent, persona-driven NL2SQL framework that combines (1) domain relevance detection, (2) schema-grounded knowledge construction, (3) KPI-aware SQL synthesis, (4) syntax-level self-repair using sqlite execution feedback, and (5) semantic consistency checking via SQL-to-NL reverse engineering. Our system significantly reduces query hallucination and improves semantic fidelity compared to direct LLM prompting. Evaluated on 60 queries (50 from a HuggingFace text-to-SQL dataset and 10 custom domain queries), the system achieves 90% correctness using Mistral across seven coordinated LLM calls showing that this approach can substantially increase the reliability of NL2SQL pipelines in high-stakes environments.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- SchemaRAG: A Schema-aware Retrieval-Augmented Generation Framework for Text-to-SQLProceedings of the ACM on Management of Data · 2026
- Reimagining Text-to-SQL: A Survey of Large Language Model Architectures and StrategiesarXiv · 2026
- text2ql: Multi-Target Natural Language Querying via a Language-Agnostic Intermediate RepresentationarXiv · 2026
- PremiseSQL: Evaluating Premise Critique and Abstention in Text-to-SQL SystemsarXiv · 2026
- [Experiment, Analysis, and Benchmark] How well do LLMs comprehend and design relational database schemata?arXiv · 2026
- Text-to-SQL in the Era of Large Language Models: A Survey of Reasoning-Centric and Efficiency-Centric ApproachesElectronics · 2026