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.
翻译:将自然语言查询转换为SQL查询是工业界与学术界面临的一项关键挑战,其目标在于提升对数据库及大规模应用的可访问性。本研究探讨了如何利用上下文学习与思维链技术,为文本到SQL系统构建一个鲁棒的解决方案。我们提出了SQL-of-Thought:一种多智能体框架,它将Text2SQL任务分解为模式链接、子问题识别、查询计划生成、SQL生成以及引导式修正循环。与以往仅依赖基于执行的静态修正的系统不同,我们引入了基于上下文学习的分类引导动态错误修正机制。SQL-of-Thought在Spider数据集及其变体上取得了最先进的结果,它结合了引导式错误分类与基于推理的查询规划。