[论文解读] A Preview of XiYan-SQL: A Multi-Generator Ensemble Framework for Text-to-SQL
XiYan-SQL 是一种用于文本到 SQL 的多生成器集成框架,结合了监督微调与上下文学习,以生成多样化且高质量的 SQL 候选语句。它引入了 M-Schema 以改进模式表示,采用精炼器和微调后的选择模型来纠正错误并选择最优查询,在 Spider 上实现 89.65% 的最先进执行准确率,在 Bird 上实现 72.23% 的准确率。
To tackle the challenges of large language model performance in natural language to SQL tasks, we introduce XiYan-SQL, an innovative framework that employs a multi-generator ensemble strategy to improve candidate generation. We introduce M-Schema, a semi-structured schema representation method designed to enhance the understanding of database structures. To enhance the quality and diversity of generated candidate SQL queries, XiYan-SQL integrates the significant potential of in-context learning (ICL) with the precise control of supervised fine-tuning. On one hand, we propose a series of training strategies to fine-tune models to generate high-quality candidates with diverse preferences. On the other hand, we implement the ICL approach with an example selection method based on named entity recognition to prevent overemphasis on entities. The refiner optimizes each candidate by correcting logical or syntactical errors. To address the challenge of identifying the best candidate, we fine-tune a selection model to distinguish nuances of candidate SQL queries. The experimental results on multiple dialect datasets demonstrate the robustness of XiYan-SQL in addressing challenges across different scenarios. Overall, our proposed XiYan-SQL achieves the state-of-the-art execution accuracy of 75.63% on Bird benchmark, 89.65% on the Spider test set, 69.86% on SQL-Eval, 41.20% on NL2GQL. The proposed framework not only enhances the quality and diversity of SQL queries but also outperforms previous methods.
研究动机与目标
- 为解决现有文本到 SQL 模型在生成多样化、高质量 SQL 查询方面,以及在不同数据库模式下泛化能力方面的局限性。
- 通过引入 M-Schema(一种半结构化、分层的数据库模式表示),提升模式理解能力,从而增强大语言模型的表现。
- 通过结合监督微调以实现可控性,以及上下文学习以提升候选生成的多样性,降低推理开销并提高准确性。
- 通过专用精炼器和微调后的选择模型,提升最终输出质量,其表现优于自一致性方法。
- 验证该框架在关系型数据库(如 Spider、Bird)和非关系型数据库(如 NL2GQL)中的鲁棒性。
提出的方法
- 该框架采用多生成器集成策略,结合两个微调后的 SQL 生成器与一个使用 GPT-4o 的上下文学习(ICL)生成器。
- 采用两阶段多任务训练方法,对生成器进行微调,以适应多样化的风格偏好并增强语义理解能力。
- 引入 M-Schema 作为半结构化模式表示,以分层紧凑格式包含表、列和数据类型,提升模型对模式的理解。
- ICL 示例基于问题骨架相似性与命名实体掩码进行选择,以避免对实体的过度强调,提升泛化能力。
- 每个候选查询均由一个精炼器处理,利用执行反馈或错误信号纠正逻辑或语法错误。
- 训练一个微调后的选择模型以区分候选查询之间的细微差异,取代自一致性方法,从而提升最终准确率。
实验结果
研究问题
- RQ1结合微调与上下文学习的多生成器集成框架是否能显著提升生成 SQL 查询的质量与多样性?
- RQ2所提出的 M-Schema 表示是否在提升大语言模型对复杂数据库模式的理解方面优于传统的 DDL 和 MAC-SQL Schema?
- RQ3微调后的选择模型是否能优于自一致性方法,从多个输出中选出最佳 SQL 查询?
- RQ4模式链接(即筛选相关模式元素)对端到端执行准确率有何影响?
- RQ5该集成框架在包括 nGQL 等非关系型系统在内的多样化数据库中,其泛化能力达到何种程度?
主要发现
- XiYan-SQL 在 Spider 测试集上实现了 89.65% 的最先进执行准确率,优于先前方法。
- 在具有挑战性的 Bird 开发基准上,其执行准确率达到 72.23%,表明对分布外样本具有强大的泛化能力。
- 与 DDL 模式相比,M-Schema 在四种大语言模型上平均提升执行准确率 2.03%,其中 GPT-4o 和 Claude 3.5 Sonnet 提升最大。
- 模式链接将精确率从 10.14% 提升至 74.74%,并将执行准确率从 57.95% 提升至 60.10%,证明其在过滤相关模式信息方面的有效性。
- 消融实验表明,移除微调生成器、ICL 生成器、精炼器或选择模型均导致性能显著下降,其中移除选择模型导致准确率下降 2.74%。
- 将候选数量从三个增加到五个,使 Bird 基准上的准确率提升至 72.23%,证实候选多样性与集成选择机制的有效性。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。