EvoSQL: Memory-Augmented Critic-Generator Co-Evolution for Text-to-SQL
EvoSQL employs memory-augmented co-evolution with execution signals and LLM critique, boosting complex Text-to-SQL accuracy by up to 9.19%.
Key Findings
Methodology
EvoSQL adopts a multi-round co-evolution framework coupling a generator and critic, maintaining a contextual candidate memory. It verifies SQL candidates via execution signals and LLM-based critique, then uses utility-guided selection and aggregation. The approach integrates a Self-Distillation Policy Optimization (SDPO) stage to enhance execution-aware supervision. Core components include candidate generation, dual-stage validation, utility-based filtering, episodic memory, and iterative refinement. This design enables effective exploration and correction of complex queries, leveraging structured feedback and multi-turn candidate evolution.
Key Results
- On Spider and BIRD benchmarks, EvoSQL outperforms the Maj@16 baseline, with improvements up to 9.19% on BIRD-Dev and +1.37% on Qwen2.5-Coder-3B. Incorporating SDPO further enhances performance, especially on challenging queries, demonstrating the robustness of multi-round co-evolution.
- In multi-round evolution, the final prediction improves over the first round by an average of 1.37 percentage points, confirming that iterative refinement yields significant gains. Ablation studies show candidate memory, execution signals, and critic feedback are critical for success.
- Results indicate that memory-grounded co-evolution effectively addresses complex reasoning bottlenecks, providing a scalable framework for reliable Text-to-SQL systems across diverse models and datasets.
Significance
This work addresses key limitations in existing Text-to-SQL systems, especially in handling multi-step reasoning and nested queries. By integrating memory, execution feedback, and critic-guided multi-round optimization, EvoSQL significantly improves robustness, accuracy, and generalization. It offers a practical pathway for deploying more reliable natural language interfaces to databases, reducing error rates in complex scenarios, and advancing the state-of-the-art in semantic parsing. The framework’s flexibility allows adaptation to various models and tasks, promising broad impact in industrial and research settings.
Technical Contribution
The paper introduces a novel memory-augmented co-evolution framework combining candidate generation, dual-stage validation, and utility-guided selection. It innovatively incorporates structured execution feedback and LLM critique into multi-round candidate refinement. The integration of SDPO for offline supervision further enhances execution-aware training. These contributions collectively enable models to perform multi-step reasoning, error diagnosis, and targeted correction, surpassing traditional single-pass approaches and establishing a new paradigm for complex semantic parsing.
Novelty
This is the first work to embed memory-augmented multi-round co-evolution into Text-to-SQL tasks, coupling candidate verification with structured feedback and iterative aggregation. Unlike prior single-turn fine-tuning or heuristic prompting, the proposed framework dynamically refines SQL candidates through structured multi-round interactions, significantly improving performance on complex queries and setting a new benchmark for robustness and generalization.
Limitations
- Despite improvements, the approach still faces challenges with extremely nested or highly ambiguous queries, where execution signals may be insufficient for precise diagnosis. Computational overhead from multiple rounds can limit real-time deployment.
- The reliance on annotated execution data and critic feedback increases resource demands, and scalability to very large schemas or real-time systems remains to be validated.
- Further research is needed to optimize the efficiency of multi-round evolution and extend the framework to multi-modal or multi-task scenarios.
Future Work
Future directions include optimizing the efficiency of multi-round candidate evolution, integrating external knowledge bases, and exploring reinforcement learning to dynamically adapt the number of evolution rounds. Extending the framework to multi-modal inputs and multi-task settings could broaden its applicability. Additionally, developing explainability and interpretability modules will enhance user trust and system transparency, paving the way for more autonomous and intelligent database querying systems.
AI Executive Summary
The rapid development of large language models (LLMs) has significantly advanced the field of Text-to-SQL, enabling more natural and flexible database querying. However, existing systems often struggle with complex queries involving multiple reasoning steps, nested structures, and error diagnosis. Traditional approaches rely on single-pass generation or heuristic post-processing, which are insufficient for such challenging scenarios. To address these limitations, this paper introduces EvoSQL, a novel framework that leverages memory-augmented co-evolution for multi-round SQL candidate refinement.
EvoSQL integrates a generator and critic in an iterative process, maintaining a structured candidate memory. The generator produces multiple SQL candidates, which are then verified through execution signals and LLM-based critique. The critic provides structured feedback, guiding the selection and aggregation of high-utility candidates. This multi-round process allows the system to explore diverse hypotheses, diagnose errors, and progressively improve query quality. A key innovation is the Self-Distillation Policy Optimization (SDPO) stage, which fine-tunes models to better incorporate execution-aware supervision, further boosting performance.
Experimental results on the Spider and BIRD benchmarks demonstrate that EvoSQL consistently outperforms baseline models, with improvements up to 9.19% on challenging datasets. The multi-round co-evolution approach significantly enhances robustness and generalization, especially for complex queries where traditional methods falter. Ablation studies confirm that candidate memory, structured critique, and execution feedback are critical components of success.
This work marks a substantial step forward in reliable, scalable Text-to-SQL systems, offering a flexible framework adaptable to various models and tasks. While computational costs and extreme query complexity remain challenges, the proposed approach opens new avenues for research in multi-step reasoning, error diagnosis, and autonomous model improvement, promising broad impact in both academia and industry.
Deep Analysis
Background
Recent advances in NLP, especially large language models like GPT-4 and Codex, have propelled semantic parsing and Text-to-SQL tasks. Early methods relied on rule-based systems, but deep learning approaches, particularly Transformer-based models, have dominated recent progress. Schema-aware models (Li et al., 2023a) incorporate database structure understanding, while content-aware retrieval enhances semantic alignment. Despite these developments, complex queries involving multi-hop reasoning, nested subqueries, and error correction remain challenging. Existing solutions primarily focus on single-pass decoding, which limits their ability to handle multi-step reasoning, leading to high error rates and poor generalization. Multi-turn approaches, including iterative refinement and multi-agent systems, have been explored but often lack structured memory and effective error diagnosis, constraining their effectiveness in real-world scenarios. Therefore, there is a pressing need for frameworks that can dynamically explore multiple hypotheses, diagnose errors, and adaptively refine SQL queries across multiple reasoning steps.
Core Problem
Current Text-to-SQL systems face significant bottlenecks in reasoning over complex schemas and nested queries. Single-pass models often produce incomplete or incorrect SQL, especially when multi-step reasoning or error diagnosis is required. Existing methods lack effective mechanisms for maintaining candidate diversity, structured error diagnosis, and iterative refinement, resulting in limited robustness and generalization. The core challenge is to develop a system that can perform multi-round candidate generation, verification, and correction, leveraging execution feedback and structured critique to improve accuracy in complex scenarios. Addressing this gap is crucial for deploying reliable natural language interfaces to databases in real-world applications, where queries are often intricate and error-prone.
Innovation
This paper introduces several key innovations: 1) Memory-augmented co-evolution framework that couples a generator and critic for multi-round candidate refinement; 2) Dual-stage verification combining deterministic execution signals with LLM-based critique, enabling precise error diagnosis; 3) Utility-guided candidate selection and aggregation leveraging episodic memory, balancing exploration and exploitation; 4) Integration of Self-Distillation Policy Optimization (SDPO) to enhance execution-aware supervision during offline fine-tuning. These innovations collectively enable the system to perform iterative, structured reasoning, improving robustness and accuracy over traditional single-pass models. The approach effectively addresses multi-step reasoning, error diagnosis, and correction, setting a new standard for complex Text-to-SQL tasks.
Methodology
- �� Initial candidate generation: The generator produces multiple SQL hypotheses based on input question, schema, and context.
- �� Candidate verification: Each candidate undergoes execution, capturing signals like success, errors, and runtime.
- �� Critique and diagnosis: The critic analyzes the question, candidate SQL, and execution results, providing structured scores and correction suggestions.
- �� Candidate filtering: Using a utility function that considers execution confidence and consistency bonuses, high-utility candidates are selected.
- �� Memory update: Verified candidates and summaries are stored in episodic memory for future rounds.
- �� Multi-round evolution: The process repeats, with retrieval of high-utility candidates for further refinement, until early stopping criteria are met.
- �� Final selection: The candidate with the highest utility score is chosen as the output.
- �� Offline fine-tuning: SDPO leverages execution feedback to distill supervision signals into the model, improving subsequent candidate generation.
Experiments
The evaluation employs Spider and BIRD benchmarks, measuring execution accuracy (EX) with a 30-second timeout. Baselines include Maj@16, with models like Coder-3B, Coder-7B, Qwen3-4B, and SQL-R1. The experiments compare single-pass, multi-round co-evolution, and SDPO-enhanced variants. Hyperparameters include 16 candidates per round, up to 3 rounds, and specific utility weighting. Ablation studies analyze the impact of candidate memory, verification stages, and critique mechanisms. Results show consistent improvements across datasets, with the largest gains on challenging queries, validating the framework’s effectiveness in complex reasoning scenarios.
Results
EvoSQL outperforms baseline models with improvements up to 9.19% on BIRD-Dev, demonstrating superior robustness in complex queries. Multi-round evolution yields an average 1.37-point performance boost, confirming the benefit of iterative refinement. The integration of memory, verification, and critique significantly enhances accuracy, especially on difficult datasets. SDPO further boosts performance, particularly on models like Coder-3B and Qwen3-4B, indicating the value of offline execution-aware supervision. Ablation results highlight the importance of each component, confirming that structured feedback and multi-turn optimization are critical for high-quality SQL synthesis.
Applications
This framework is immediately applicable to enterprise data management, enabling automated, accurate SQL generation from natural language queries, reducing reliance on manual scripting. It can be integrated into intelligent assistants, customer support bots, and data analysis tools, improving user experience and operational efficiency. Long-term, the approach paves the way for autonomous, self-improving database interfaces capable of handling increasingly complex queries, supporting multi-modal inputs, and adapting to diverse domains. Such systems could revolutionize how non-experts interact with large-scale data repositories, democratizing data access and analysis across industries.
Limitations & Outlook
Despite its strengths, the approach faces challenges with extremely nested or ambiguous queries where execution signals are insufficient for precise diagnosis. The multi-round process incurs higher computational costs, limiting real-time deployment in resource-constrained environments. Dependence on annotated execution data and critic feedback increases resource requirements, and scalability to very large schemas or multi-modal inputs remains to be validated. Future work should focus on efficiency improvements, reducing inference latency, and extending the framework to broader multi-task and multi-modal scenarios.
Plain Language Accessible to non-experts
想象你在厨房里做菜,菜谱就像数据库的说明书。你需要按照步骤准备食材、调味料,才能做出一道美味的菜。传统的方法就像只看一次菜谱,可能会漏掉关键步骤或用错调料。而EvoSQL就像一个聪明的厨师,不断尝试不同的做法,尝试后品尝(执行),根据味道反馈(批评)调整配料和步骤。它会记住哪些做法好,哪些不好,反复试验,直到做出最合适的菜。这种多轮试验和记忆帮助厨师不断改进,最终做出完美的菜。这就像模型在生成SQL时不断验证、批评和优化,确保查询既正确又高效。
ELI14 Explained like you're 14
想象你在玩一个游戏,你要找到最快最好的路线去完成任务。刚开始,你可能试几条不同的路径,然后看看哪条最顺利。每次试完后,你会记住哪些路线好,哪些不好,然后再试一些改进的路线。慢慢地,你会变得越来越擅长找到最短、最安全的路径。EvoSQL也是这样,它会多次尝试不同的SQL语句,看看哪个能正确地从数据库中得到答案。每次尝试后,它会根据结果的好坏,改进下一次的尝试。最终,它能快速找到最合适的SQL语句,帮助用户用自然语言查询数据库,就像你用最聪明的方法完成游戏任务一样。
Glossary
Memory-Augmented Co-Evolution(记忆增强协同演化)
一种结合记忆机制和多轮交互的优化策略,通过存储验证过的候选,持续改进生成模型的性能。技术上融合候选筛选、验证与多轮优化。
论文中提出的核心机制,用于提升复杂SQL查询的推理能力。
Self-Distillation Policy Optimization(自蒸馏策略优化)
一种利用模型自身生成的目标和执行信息,进行离线微调的方法,强化模型的执行感知和推理能力。结合教师-学生框架实现知识迁移。
用于提升模型在复杂场景下的SQL生成质量。
Execution Signal(执行信号)
数据库执行结果和状态信息,用于验证SQL候选的正确性和合理性。包括成功、错误、超时等指标。
在候选验证和筛选中起关键作用。
Critic(批评者)
基于模型和执行信息,提供SQL候选的结构化评价和修正建议的模块。用于引导生成器优化。
在多轮协同演化中评估候选SQL的质量。
Episodic Memory(情节记忆)
存储验证过的候选SQL和总结信息的记忆池,用于多轮候选筛选和优化。
支持候选的持续改进和多轮演化。
Open Questions Unanswered questions from this research
- 1 如何进一步减少多轮演化的计算成本,提升推理速度,特别是在大规模数据库场景中。
- 2 如何结合外部知识和多模态信息,增强模型的推理深度和解释能力。
- 3 在极端复杂查询中,如何设计更有效的验证和诊断机制以避免性能瓶颈。
Applications
Immediate Applications
企业智能数据库查询
帮助企业自动生成复杂SQL查询,减少人工调试时间,提高数据分析效率。依赖结构化数据库和自然语言输入,适合大规模企业应用。
智能问答系统
集成到企业客服、智能助手中,实现自然语言对数据库的高精度查询,提升用户体验和响应速度。
Long-term Vision
自主学习与持续优化
未来模型能在实际使用中不断学习新知识、优化推理路径,实现自我提升,推动智能数据库的普及和深度应用。
Abstract
Text-to-SQL has advanced rapidly with large language models, but complex database queries still require reasoning beyond one-shot generation, including multi-step decomposition, execution-based diagnosis, and targeted correction. We present EvoSQL, a co-evolution framework that formulates SQL synthesis as an iterative interaction between a generator and a critic. EvoSQL maintains a contextualized candidate memory, verifies SQL candidates with both execution signals and LLM-based critique, and updates its memory through utility-guided aggregation. To strengthen the underlying generator-critic pair, we further introduce a Self-Distillation Policy Optimization (SDPO) fine-tuning stage that injects execution-aware supervision into modern coding LLM backbones. Experiments on Spider and BIRD show that EvoSQL consistently improves open-source models over Maj@16 baselines, with particularly large gains on BIRD-Dev, ranging from +1.37% for Qwen3-4B to +9.19% for Qwen2.5-Coder-3B. SDPO initialization further improves selected backbones on Spider-Test and BIRD-Dev. These results suggest that memory-grounded co-evolution is an effective path toward more reliable and generalizable Text-to-SQL systems. Code is available at https://github.com/valleysprings/EvoSQL.