用强化学习提升自然语言转SQL的准确率,解决常见错误问题。
CSC-SQL: Corrective Self-Consistency in Text-to-SQL via Reinforcement Learning
- 并行采样选高频答案,再通过修正模型优化
- 7B模型在BIRD测试集上达71.72%执行准确率
- 适合需要高精度数据库查询的应用场景
大语言模型在将自然语言问题转换为SQL查询方面表现出色。测试时扩展技术如Self-Consistency和Self-Correction可通过增加推理计算量提升准确性,但存在局限:Self-Consistency可能选择非最优输出,Self-Correction通常仅处理语法错误。为此,我们提出CSC-SQL,融合Self-Consistency与Self-Correction。该方法从并行采样中选取两个最频繁出现的输出,输入合并修订模型进行修正。同时,采用组相对策略优化(GRPO)算法,通过强化学习微调生成与修订模型,显著提升输出质量。实验结果表明,CSC-SQL在BIRD私有测试集上,7B模型实现71.72%的执行准确率,32B模型达73.67%。代码已开源:https://github.com/CycloneBoy/csc_sql。
原文摘要 · Abstract (English)
Large language models (LLMs) have demonstrated strong capabilities in translating natural language questions about relational databases into SQL queries. In particular, test-time scaling techniques such as Self-Consistency and Self-Correction can enhance SQL generation accuracy by increasing computational effort during inference. However, these methods have notable limitations: Self-Consistency may select suboptimal outputs despite majority votes, while Self-Correction typically addresses only syntactic errors. To leverage the strengths of both approaches, we propose CSC-SQL, a novel method that integrates Self-Consistency and Self-Correction. CSC-SQL selects the two most frequently occurring outputs from parallel sampling and feeds them into a merge revision model for correction. Additionally, we employ the Group Relative Policy Optimization (GRPO) algorithm to fine-tune both the SQL generation and revision models via reinforcement learning, significantly enhancing output quality. Experimental results confirm the effectiveness and generalizability of CSC-SQL. On the BIRD private test set, our 7B model achieves 71.72\% execution accuracy, while the 32B model achieves 73.67\%. The code has been open sourced at https://github.com/CycloneBoy/csc_sql.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。