通过重试数据训练模型,让AI自动修正SQL生成错误。
RetrySQL: text-to-SQL training with retry data for self-correcting query generation
- 用错误与修正步骤构造重试数据,训练模型自纠错能力。
- 相比传统预训练,执行准确率提升最高达4个百分点。
- 适合想用开源模型提升SQL生成质量的研究者和开发者。
文本到SQL任务是自然语言处理中的关键挑战。现有方法多依赖黑箱语言模型,结合专用组件构建端到端管道,但缺乏针对SQL的专用生成模型研究。近期自纠正生成策略显示出潜力,但尚未应用于文本到SQL任务。本文提出RetrySQL,一种新型文本到SQL生成模型训练方法:先准备参考SQL查询的推理步骤,再人为破坏生成带错与修正步骤的重试数据,并用特殊标记分隔。持续用该数据预训练开源代码模型,结果表明,相比无重试数据的预训练,整体及困难样本执行准确率最高提升4个百分点。同时发现,仅用LoRA微调无法从重试数据中学习,必须全参数预训练。实验验证了模型确实习得了自纠正能力,且下游准确率提升源于此技能。将训练好的模型融入完整文本到SQL流程后,其执行准确率可媲美参数量大数倍的专有模型。这证明自纠正可在文本到SQL任务中被有效学习,并为面向SQL的语言模型提供了一种新精度提升路径。
原文摘要 · Abstract (English)
The text-to-SQL task is an active challenge in Natural Language Processing. Many existing solutions focus on using black-box language models extended with specialized components within customized end-to-end text-to-SQL pipelines. While these solutions use both closed-source proprietary language models and coding-oriented open-source models, there is a lack of research regarding SQL-specific generative models. At the same time, recent advancements in self-correcting generation strategies show promise for improving the capabilities of existing architectures. The application of these concepts to the text-to-SQL task remains unexplored. In this paper, we introduce RetrySQL, a new approach to training text-to-SQL generation models. We prepare reasoning steps for reference SQL queries and then corrupt them to create retry data that contains both incorrect and corrected steps, divided with a special token. We continuously pre-train an open-source coding model with this data and demonstrate that retry steps yield an improvement of up to 4 percentage points in both overall and challenging execution accuracy metrics, compared to pre-training without retry data. Additionally, we confirm that supervised fine-tuning with LoRA is ineffective for learning from retry data and that full-parameter pre-training is a necessary requirement for that task. We showcase that the self-correcting behavior is learned by the model and the increase in downstream accuracy metrics is a result of this additional skill. Finally, we incorporate RetrySQL-trained models into the full text-to-SQL pipeline and showcase that they are competitive in terms of execution accuracy with proprietary models that contain orders of magnitude more parameters. RetrySQL demonstrates that self-correction can be learned in the text-to-SQL task and provides a novel way of improving generation accuracy for SQL-oriented language models.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。