Recent In-Context Learning based methods have achieved remarkable success in Text-to-SQL task. However, there is still a large gap between the performance of these models and human performance on datasets with complex database schema and difficult questions, such as BIRD. Besides, existing work has neglected to supervise intermediate steps when solving questions iteratively with question decomposition methods, and the schema linking methods used in these works are very rudimentary. To address these issues, we propose MAG-SQL, a multi-agent generative approach with soft schema linking and iterative Sub-SQL refinement. In our framework, an entity-based method with tables' summary is used to select the columns in database, and a novel targets-conditions decomposition method is introduced to decompose those complex questions. Additionally, we build a iterative generating module which includes a Sub-SQL Generator and Sub-SQL Refiner, introducing external oversight for each step of generation. Through a series of ablation studies, the effectiveness of each agent in our framework has been demonstrated. When evaluated on the BIRD benchmark with GPT-4, MAG-SQL achieves an execution accuracy of 61.08%, compared to the baseline accuracy of 46.35% for vanilla GPT-4 and the baseline accuracy of 57.56% for MAC-SQL. Besides, our approach makes similar progress on Spider. The codes are available at https://github.com/LancelotXWX/MAG-SQL.
翻译:近年来,基于上下文学习的模型在文本到SQL任务中取得了显著成功。然而,在处理具有复杂数据库模式和困难问题的数据集(如BIRD)时,这些模型的性能与人类表现之间仍存在较大差距。此外,现有研究在使用问题分解方法迭代求解问题时,忽视了对中间步骤的监督,且所采用的模式链接方法较为基础。为解决这些问题,我们提出了MAG-SQL,一种结合软模式链接与迭代子SQL优化的多智能体生成式方法。在我们的框架中,采用基于实体和表摘要的方法来选择数据库中的列,并引入了一种新颖的目标-条件分解方法来分解复杂问题。此外,我们构建了一个包含子SQL生成器和子SQL优化器的迭代生成模块,为每个生成步骤引入了外部监督。通过一系列消融实验,验证了我们框架中每个智能体的有效性。在BIRD基准测试中使用GPT-4进行评估时,MAG-SQL实现了61.08%的执行准确率,而原始GPT-4的基线准确率为46.35%,MAC-SQL的基线准确率为57.56%。此外,我们的方法在Spider数据集上也取得了类似的进展。代码可在 https://github.com/LancelotXWX/MAG-SQL 获取。