arXiv:2609.02944cs.IRcs.AI2026-09KDD

通过多阶段自我反思机制提升文本转SQL的准确率

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

  • 用大模型驱动的反馈循环实现逐级优化
  • 在BIRD基准上达到72.03%执行准确率
  • 适合需要高可靠SQL生成的企业级应用

通过自然语言民主化数据访问是现代企业的重要目标,但实际应用受制于三大挑战:1. 数据库模式复杂且不清晰;2. 因模式结构化与查询模糊导致相关表列检索无效;3. 缺乏有效的验证与纠错机制,导致生成的SQL存在语法或逻辑错误。为此,我们提出Reflect-SQL框架,基于多阶段自我反思方法,利用知识库理解复杂模式,构建高效检索与生成机制。系统不采用单次尝试,而是通过大模型作为裁判的评分机制,在多个反馈回路中迭代优化:反馈驱动的检索回路优化用户自然语言查询,合成回路验证并修正SQL,蕴含回路优化端到端流程并持续丰富知识库。通过多层反思,Reflect-SQL弥合了用户意图与复杂数据间的鸿沟。在具有挑战性的BIRD基准上,该框架实现72.03%的执行准确率,显著优于现有最先进基线,展现出企业在实际应用中所需的可靠性飞跃。

原文摘要 · Abstract (English)

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.

文本转SQL大模型自反思数据库

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。