ReToolSQL: Agentic Reinforcement Learning for Robust Text-to-SQL

📄 arXiv: 2608.27796v1 📥 PDF

作者: Pratik Kakkar, Chandra Dhir, Ravi Shankar, Pareekshit Reddy Gaddam, Anup Shirgaonkar

分类: cs.AI

发布日期: 2026-08-28


💡 一句话要点

提出ReToolSQL以解决文本到SQL生成中的迭代错误问题

🎯 匹配领域: 支柱二:RL算法与架构 (RL & Architecture)

关键词: 文本到SQL 强化学习 监督学习 多轮交互 数据库查询 执行反馈 模型优化

📋 核心要点

  1. 现有文本到SQL生成方法通常将任务视为单轮,限制了模型的错误修正能力。
  2. ReToolSQL通过两阶段训练框架,结合监督预热和强化微调,提升了模型的性能。
  3. 在BIRD-SQL基准上,ReToolSQL实现了74.32%的执行准确率,表现优于现有方法。

📝 摘要(中文)

近期研究表明,从执行反馈中进行强化学习可以显著提升文本到SQL的性能,甚至使小模型的表现超过大型系统。然而,现有方法通常将SQL生成视为单轮任务,限制了模型通过迭代修正错误的能力。本文提出ReToolSQL,一个两阶段的文本到SQL训练框架,结合了基于拒绝采样的监督预热和基于代理的强化微调。该方法通过扩展可解决问题的集合和提高单次执行准确性,展示了在BIRD-SQL基准上的优越表现,最高达74.32%的执行准确率。

🔬 方法详解

问题定义:本文旨在解决文本到SQL生成中的迭代错误修正问题。现有方法多将SQL生成视为单轮任务,导致模型在面对复杂问题时难以进行有效的错误修正。

核心思路:ReToolSQL的核心思路是通过两阶段训练框架,首先进行监督预热以扩展可解决问题的集合,然后通过强化微调提高单次执行的准确性。这种设计使得模型能够在多轮工具使用中进行有效的反馈学习。

技术框架:ReToolSQL的整体架构包括两个主要阶段:第一阶段是基于拒绝采样的监督预热,第二阶段是基于代理的强化微调。监督预热阶段利用经过验证的教师轨迹来扩展模型的能力,而强化微调则通过执行反馈来优化模型的决策过程。

关键创新:ReToolSQL的主要创新在于将监督学习与强化学习相结合,形成了一种新的训练流程。这种方法不仅提高了模型的覆盖率,还通过引导模型学习何时验证和如何修复错误SQL,显著提升了执行准确性。

关键设计:在设计上,ReToolSQL使用了复合奖励机制,基于执行正确性进行优化,且不需要额外的人类标注。模型在单一的31B参数密集模型中运行,展示了SFT到RFT的有效性。

🖼️ 关键图片

fig_0
img_1
img_2

📊 实验亮点

在BIRD-SQL开发基准上,ReToolSQL的强化微调方法单独实现了73.66%的执行准确率,结合自一致性后达到了74.12%。通过从监督预热检查点初始化强化微调,最终模型在单次执行中达到了74.32%的准确率,显示出显著的性能提升。

🎯 应用场景

ReToolSQL的研究成果在企业级文本到SQL生成中具有广泛的应用潜力,能够有效处理复杂的数据库查询任务。其强化学习的设计理念可推广至其他需要反馈学习的领域,如自然语言处理和智能问答系统,未来可能推动更多智能应用的发展。

📄 摘要(原文)

Recent work has shown that reinforcement learning from execution feedback can substantially improve text-to-SQL performance, often enabling smaller models to match or exceed much larger systems. However, most existing approaches treat SQL generation as a single-turn task, limiting the model's ability to recover from errors through iterative refinement. We present ReToolSQL, a two-stage training framework for text-to-SQL that combines (i) a supervised warm-start on rejection-sampled reasoning traces with (ii) agentic reinforcement fine-tuning (RFT) over multi-turn tool-use trajectories. The key insight is that the two stages act on complementary axes, the supervised fine-tuning (SFT) on verified privileged-teacher traces expands the set of solvable questions (raising pass@k coverage on the hardest cases), while RFT converts that expanded capability into higher single-pass accuracy by teaching the model when to verify, what evidence to retrieve, and how to repair faulty SQL from execution feedback. Applied to Gemma 4 instruction-tuned (31B), RFT alone achieves 73.66% execution accuracy (EX) on the BIRD-SQL development benchmark (74.12% EX with self-consistency). Initializing RFT from the SFT checkpoint (SFT$\to$RFT) yields our strongest model at 74.32% EX single-pass and 74.77% EX with self-consistency. At the time of writing, this ranked first on the BIRD single-model development-set leaderboard. The approach uses composite rewards anchored on execution correctness, requires no human annotation beyond the benchmark itself, and operates within a single dense 31B model, showing that a properly designed SFT$\to$RFT pipeline over tool-use trajectories is a practical path toward robust enterprise-grade text-to-SQL.