cs.IRSep 1, 2026

Reflect-SQL: A Self-Reflection Based Framework for Text-to-SQL

Authors: Anupreksha Jain, Manish Shrivastava

Organizations: International Institute of Information Technology Hyderabad, India

Abstract

Democratizing data access through natural language is a crucial goal for modern enterprises, but the practical adoption of Text-to-SQL is critically hindered by real-world complexities: 1. Obscure and large database schemas, 2. Ineffective retrieval of relevant tables and columns due to structured setting of schemas and vague user query, 3. Generation of syntactically or logically flawed SQL due to a lack of robust validation and correction mechanism. To address these systemic challenges, we introduce Reflect-SQL, a novel framework for Text to SQL, grounded in multi-stage self-reflection approach to develop understanding of obscure schema using a knowledge base, setup a process for effective retrieval and system to generate syntactically/semantically SQL. Instead of a single-pass attempt, our system employs an LLM-as-a-judge driven scoring mechanism within interconnected feedback loops to iteratively refine the results at every stage. A feedback-driven retrieval loop refines the user's natural language query, while a synthesis loop validates and corrects the SQL and finally, an entailment loop optimizes the end-to-end process and continuously enriches the knowledge base. By integrating these layers of reflection, Reflect-SQL bridges the critical gap between user intent and complex data. On the challenging BIRD benchmark, our framework achieves an execution accuracy of 72.03%, significantly outperforming state-of-the-art baselines, demonstrating a major leap in reliability for enterprise applications.

Figures & tables

Explore similar work

CardsList
  1. Schema-Free Text-to-SQL: Learning Enterprise Database Structure from Query Logs

    Oct 24, 2026Ömer Faruk Akgül, Nikhil Kapahi, Prajit Reddy MuppidiText-to-SQLGraph Retrieval-Augmented Generation

  2. AV-SQL: Decomposing Complex Text-to-SQL Queries with Agentic Views

    Apr 8, 2026Minh Tam Pham, Trinh Pham, Tong Chen +3Text-to-SQLMulti-Agent LLM Systems

  3. ACE-SQL: Adaptive Co-Optimization via Empirical Credit Assignment for Text-to-SQL

    Jun 4, 2026Xiaobing Chen, Ai Jian, Eryu Guo +1Execution-Guided Code GenerationSchema Linking