让AI像人一样一步步试错改SQL,性能超越大模型
SQL-Trail: Multi-Turn Reinforcement Learning with Interleaved Feedback for Text-to-SQL
- 用多轮交互+执行反馈迭代优化SQL生成
- 7B/14B模型比大厂模型平均高5%,数据效率提升18倍
- 适合需要高精度、可解释的复杂数据库查询场景
尽管大语言模型显著提升了文本转SQL的能力,但在BIRD-SQL等挑战性基准上,人工智能系统与人类专家之间仍存在明显差距。我们认为这主要源于主流的一次性生成范式,缺乏人类自然具备的迭代推理、模式探索和错误修正行为。为此,我们提出SQL-Trail,一种用于文本转SQL的多轮强化学习代理框架。该框架不一次性生成查询,而是通过与数据库环境交互并利用执行反馈来逐步优化预测。方法核心包含两点:(i) 自适应轮次预算分配机制,根据问题难度动态调整交互深度;(ii) 复合奖励面板,同时激励SQL正确性和高效探索。在多个基准上,SQL-Trail达到新最佳性能,数据效率相比先前单次强化学习方法最高提升18倍。值得注意的是,我们的7B和14B模型平均比更大规模的专有系统高出5%,证明了交互式代理工作流在鲁棒文本转SQL中的有效性。
原文摘要 · Abstract (English)
While large language models (LLMs) have substantially improved Text-to-SQL generation, a pronounced gap remains between AI systems and human experts on challenging benchmarks such as BIRD-SQL. We argue this gap stems largely from the prevailing single-pass paradigm, which lacks the iterative reasoning, schema exploration, and error-correction behaviors that humans naturally employ. To address this limitation, we introduce SQL-Trail, a multi-turn reinforcement learning (RL) agentic framework for Text-to-SQL. Rather than producing a query in one shot, SQL-Trail interacts with the database environment and uses execution feedback to iteratively refine its predictions. Our approach centers on two key ideas: (i) an adaptive turn-budget allocation mechanism that scales the agent's interaction depth to match question difficulty, and (ii) a composite reward panel that jointly incentivizes SQL correctness and efficient exploration. Across benchmarks, SQL-Trail sets a new state of the art and delivers strong data efficiency--up to 18x higher than prior single-pass RL state-of-the-art methods. Notably, our 7B and 14B models outperform substantially larger proprietary systems by 5% on average, underscoring the effectiveness of interactive, agentic workflows for robust Text-to-SQL generation.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。