SQL思维链:基于多智能体引导式错误修正的文本到SQL转换
SQL-of-Thought: Multi-agentic Text-to-SQL with Guided Error Correction
August 30, 2025
作者: Saumya Chaturvedi, Aman Chadha, Laurent Bindschaedler
cs.AI
摘要
将自然语言查询转换为SQL查询是工业界和学术界共同面临的关键挑战,旨在提升对数据库及大规模应用的可访问性。本研究探讨了如何利用上下文学习与思维链技术,为文本到SQL系统开发出稳健的解决方案。我们提出了“SQL思维链”:一个多智能体框架,该框架将Text2SQL任务分解为模式链接、子问题识别、查询计划生成、SQL生成以及一个引导式修正循环。与以往仅依赖基于执行的静态修正系统不同,我们引入了基于上下文学习的分类指导下的动态错误修正机制。SQL思维链在Spider数据集及其变体上取得了最先进的成果,通过结合引导式错误分类与基于推理的查询规划,展现了卓越的性能。
English
Converting natural language queries into SQL queries is a crucial challenge
in both industry and academia, aiming to increase access to databases and
large-scale applications. This work examines how in-context learning and
chain-of-thought can be utilized to develop a robust solution for text-to-SQL
systems. We propose SQL-of-Thought: a multi-agent framework that decomposes the
Text2SQL task into schema linking, subproblem identification, query plan
generation, SQL generation, and a guided correction loop. Unlike prior systems
that rely only on execution-based static correction, we introduce
taxonomy-guided dynamic error modification informed by in-context learning.
SQL-of-Thought achieves state-of-the-art results on the Spider dataset and its
variants, combining guided error taxonomy with reasoning-based query planning.