NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

MARS-SQL: A Multi-Agent Reinforcement Learning Framework For Text-To-SQL

Haolin Yang, Jipeng Zhang, Zhitao He, Alexander Zhou, Yi R. Fung

The Challenge of Enterprise Text-to-SQL

While Large Language Models (LLMs) excel at generating simple SQL queries, they frequently stumble when navigating real-world enterprise databases. These environments are characterized by massive, complex schemas filled with hundreds of tables and columns—many of which act as "distractors" that can easily lead an AI astray.

Current approaches predominantly rely on "static prompting," where the model is given a set of instructions and expected to generate the perfect query in a single attempt. If the AI makes a typo in a table name or misunderstands a complex join condition, it fails silently. What is missing is a "closed-loop" system: an environment where the AI can interact with the database, receive error messages, and dynamically self-correct its logic.

To bridge this gap, researchers have introduced MARS-SQL, a novel multi-agent framework that transforms Text-to-SQL from a one-shot translation task into a trainable, interactive dialogue.

The MARS-SQL Architecture

Rather than relying on a single monolithic model, MARS-SQL decomposes the Text-to-SQL problem into a trainable agentic workflow featuring three specialized roles:

  1. Grounding Agent: Acting as the initial filter, this agent analyzes the user's natural language question alongside the massive database schema. It prunes away irrelevant tables and columns, providing a clean, highly precise context for the next stage.
  2. Generation Agent: The core "brain" of the system operates in a ReAct-style loop (Think-Act-Observe). Instead of merely outputting a final answer, it generates intermediate SQL queries, executes them on a live database, and observes the results. Crucially, this agent is trained using Group Relative Policy Optimization (GRPO)—a memory-efficient reinforcement learning algorithm—relying on sparse rewards based on final execution correctness.
  3. Validation Agent: Because the Generation Agent explores multiple possible reasoning "trajectories," the Validation Agent serves as a high-quality reranker. It treats verification as a generative modeling task, calculating the probability that a specific reasoning path is correct to select the optimal final answer.

Unlike traditional prompted agents, MARS-SQL's agents are specifically trained to perform these roles using environmental feedback.

Key Innovations and Insights

The MARS-SQL framework reveals several critical insights about the future of agentic AI:

  • Interaction > Scaling: One of the most striking findings is that a system of three specialized 7B-parameter agents (21B parameters total) significantly outperforms much larger monolithic models (30B+ parameters). The ability to iteratively "think" and interact with an environment proves more valuable than raw parameter count.
  • Learning from Failure: Through reinforcement learning, the Generation Agent learns that an OperationalError (such as a misspelled table name) is not a dead end. It learns to interpret the error, re-evaluate the schema, and self-correct its query.
  • Extreme Data Efficiency: MARS-SQL achieves state-of-the-art results using only ~35,000 training instances. The authors estimate that reaching comparable performance via standard Supervised Fine-Tuning (SFT) would require roughly 15 million synthetic examples.
  • Validation as Next-Token Prediction: Instead of relying on simple majority voting (Self-Consistency), the Validation Agent leverages the model's internal next-token prediction probabilities to score reasoning paths. This method is substantially more robust at identifying the correct answer among plausible-looking candidates.

Empirical Results

MARS-SQL sets a new benchmark for open-source Text-to-SQL performance, evaluated across several rigorous datasets including BIRD, Spider 1.0, Spider-DK, and SParC.

  • BIRD-dev: The framework achieved an impressive 77.84% execution accuracy, marking a 5.55% improvement over the previous best open-source competitor. It even outperformed top-tier closed-source solutions like CHASE-SQL paired with Gemini.
  • Spider-test: Demonstrating exceptional out-of-domain generalization, MARS-SQL reached 89.75% accuracy on unseen databases without any specific training on the Spider dataset.
  • Training Efficiency: The entire training pipeline is highly optimized, taking approximately 13 hours on a standard node equipped with 4x H800 GPUs.

Limitations and Future Directions

While highly effective, the authors are transparent about the "agent tax" associated with this framework:

  • Inference Footprint: Although each agent is relatively small (7B), the total system footprint is ~21B parameters. While they can be run sequentially to conserve VRAM, the system remains more resource-intensive than a single, smaller model.
  • Latency: Multi-turn reasoning inherently takes time. The average end-to-end latency is currently about 22 seconds per query.

Future research will focus on mitigating these limitations. The authors suggest that system-level optimizations, such as pipeline parallelism, could cut latency by 40-60%. Additionally, ongoing work will explore making these agentic workflows more efficient in terms of token usage and VRAM, paving the way for faster, more complex multi-agent cooperation.

Summary updated

BibTeX
@inproceedings{yang2026mars,
  author = {Haolin Yang and Jipeng Zhang and Zhitao He and Alexander Zhou and Yi R. Fung},
  title = {{MARS-SQL: A Multi-Agent Reinforcement Learning Framework For Text-To-SQL}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=HF2bafS1kZ},
}
Figure