arXiv:2511.01008cs.CL2025-11被引 14

用多智能体强化学习让AI更准地把自然语言转成SQL。

MARS-SQL: A multi-agent reinforcement learning framework for Text-to-SQL

  • 分三个角色协作:理解表结构、生成查询、验证结果。
  • 在Spider数据集上准确率达89.75%,优于现有方法。
  • 适合想提升复杂SQL生成能力的研究者和开发者。

大型语言模型在处理复杂Text-to-SQL任务时,常因逻辑精准度与数据库模式对齐不足而表现不佳。现有方法依赖静态提示,缺乏通过环境交互动态调整与自我修正的能力。为此,我们提出MARS-SQL,一个可训练的多智能体框架。该框架将任务分解为三个专用角色:模式定位、查询生成与解决方案验证。核心是一个基于多轮强化学习策略的生成智能体,运行于类似ReAct的循环中,能迭代推理、在实时数据库上执行中间SQL操作,并根据执行反馈优化策略。为增强鲁棒性,引入验证机制,将解选择建模为生成任务,通过下一个词预测概率识别最优交互轨迹。实验表明,交互式学习与轨迹排序结合效果显著。MARS-SQL在BIRD开发集上实现77.84%的执行准确率,在Spider测试集上达89.75%,且在跨域基准上表现出强泛化能力。代码已开源。

原文摘要 · Abstract (English)

Large Language Models (LLMs) often struggle with the precise logic and schema alignment required for complex Text-to-SQL tasks. While current methods rely heavily on static prompting, they lack the ability to dynamically adapt and self-correct through environmental interaction. To bridge this gap, we propose MARS-SQL, a trainable multi-agent framework for Text-to-SQL. Rather than introducing a new standalone SQL primitive, MARS-SQL makes an agentic workflow trainable by decomposing the problem into three specialized roles: schema grounding, query generation, and solution validation. Central to our approach is a generation agent trained via a multi-turn RL policy within a ReAct-style loop. The agent learns to iteratively reason, execute intermediate SQL actions on a live database, and refine its strategy based on execution feedback. To improve robustness, we further introduce a validation mechanism that treats solution selection as a generative modeling task, identifying the optimal interaction trajectory through next-token prediction probabilities. Empirical evaluations demonstrate the effectiveness of coupling interactive learning with trajectory ranking. MARS-SQL achieves state-of-the-art performance, recording an execution accuracy of 77.84% on the BIRD development dataset and 89.75% on the Spider test dataset, while also transferring strongly to out-of-domain benchmarks. Code is available at https://github.com/YangHaolin0526/MARS-SQL.

Text-to-SQL多智能体强化学习数据库

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。