arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2505.13271cs.CL
收藏

CSC-SQL:基于强化学习的文本到SQL中的纠错自洽性

CSC-SQL: Corrective Self-Consistency in Text-to-SQL via Reinforcement Learning

Wuhan University of Technology(武汉理工大学);University of Science and Technology of China(中国科学技术大学)

Lei Sheng, Shuai-Shuai Xu

AI总结:

针对文本到SQL中Self-Consistency和Self-Correction的局限,提出CSC-SQL方法,结合两者优势并利用GRPO强化学习微调生成与修订模型,在BIRD测试集上取得高准确率。

摘要:

大型语言模型(LLMs)在将关于关系数据库的自然语言问题翻译为SQL查询方面展现出了强大的能力。特别是,诸如Self-Consistency和Self-Correction等测试时扩展技术,可以通过增加推理期间的计算量来提高SQL生成的准确率。然而,这些方法存在显著局限性:Self-Consistency尽管采用多数投票,但仍可能选择次优输出,而Self-Correction通常仅解决语法错误。为利用这两种方法的优势,我们提出了CSC-SQL,一种结合Self-Consistency和Self-Correction的新方法。CSC-SQL从并行采样中选择出现频率最高的两个输出,并将其输入到合并修订模型中进行纠正。此外,我们采用Group Relative Policy Optimization(GRPO)算法,通过强化学习对SQL生成和修订模型进行微调,显著提升了输出质量。实验结果证实了CSC-SQL的有效性和泛化能力。在BIRD私有测试集上,我们的7B模型达到了71.72%的执行准确率,而32B模型达到了73.67%。代码已在https://github.com/CycloneBoy/csc_sql开源。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑