arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2504.08600cs.DB
收藏

SQL-R1:通过强化学习训练自然语言到SQL推理模型

SQL-R1: Training Natural Language to SQL Reasoning Model By Reinforcement Learning

IDEA Research, International Digital Economy Academy(国际数字经济发展研究院);The Hong Kong University of Science and Technology (Guangzhou)(香港科技大学(广州));University of Chinese Academy of Sciences(中国科学院大学);DataArc Tech Ltd.(DataArc科技有限公司)

Peixian Ma, Xialie Zhuang, Chengjin Xu, Xuhui Jiang, Ran Chen, Jian Guo

AI总结:

SQL-R1提出用强化学习训练NL2SQL推理模型,设计专门奖励函数,仅用少量合成数据即在Spider和BIRD上达到88.6%和67.1%的执行准确率。

摘要:

自然语言到SQL(NL2SQL)通过将自然语言查询转换为结构化SQL语句,实现了与数据库的直观交互。尽管近期在增强数据库应用中的人机交互方面取得了进展,但在涉及多表连接和嵌套查询的复杂场景中,推理性能仍面临重大挑战。当前方法主要利用监督微调(SFT)来训练NL2SQL模型,这可能限制了模型在新环境(如金融和医疗保健)中的适应性和可解释性。为了在上述复杂情况下提升NL2SQL模型的推理性能,我们引入了SQL-R1,一种通过强化学习(RL)算法训练的新型NL2SQL推理模型。我们设计了一种专门针对NL2SQL任务的基于RL的奖励函数,并讨论了冷启动和合成数据对强化训练有效性的影响。此外,我们仅使用少量合成NL2SQL数据进行增强训练就达到了具有竞争力的准确率,并进一步探索了用于RL的数据工程。在现有实验中,SQL-R1在基准Spider和BIRD上的执行准确率分别达到88.6%和67.1%。代码可在https://github.com/IDEA-FinAI/SQL-R1获取。

英文摘要:

Natural Language to SQL (NL2SQL) enables intuitive interactions with databases by transforming natural language queries into structured SQL statements. Despite recent advancements in enhancing human-computer interaction within database applications, significant challenges persist, particularly regarding the reasoning performance in complex scenarios involving multi-table joins and nested queries. Current methodologies primarily utilize supervised fine-tuning~(SFT) to train the NL2SQL model, which may limit adaptability and interpretability in new environments~(e.g., finance and healthcare). In order to enhance the reasoning performance of the NL2SQL model in the above complex situations, we introduce SQL-R1, a novel NL2SQL reasoning model trained by the reinforcement learning~(RL) algorithms. We design a specialized RL-based reward function tailored for NL2SQL tasks and discussed the impact of cold start and synthetic data on the effectiveness of intensive training. In addition, we achieve competitive accuracy using only a tiny amount of synthetic NL2SQL data for augmented training and further explore data engineering for RL. In existing experiments, SQL-R1 achieves execution accuracy of 88.6\% and 67.1\% on the benchmark Spider and BIRD, respectively. The code is available at https://github.com/IDEA-FinAI/SQL-R1 .

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

↑