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

A Multi-agent Text2SQL Framework using Small Language Models and Execution Feedback

Thanh Dat Hoang, Thanh Trung Huynh, Matthias Weidlich, Thanh Nguyen, Tong Chen, Hongzhi Yin, Quoc Viet Hung NguyenarXiv 2025 · DOI

Abstract

The MATS (Multi-Agent Text2SQL) framework demonstrates that specialized Small Language Models (SLMs) can achieve state-of-the-art performance in database querying. By utilizing a multi-agent architecture and a novel training loop called Reinforcement Learning from Execution Feedback (RLEF), MATS bridges the reasoning gap typically found in smaller models. Evaluation on benchmarks like Spider and BIRD shows that MATS, with only 9B parameters, performs on par with much larger proprietary models while remaining computationally efficient and private.

Introduction

Text-to-SQL—the task of translating natural language into executable SQL—is a cornerstone of modern data engineering. While frontier models like GPT-4 excel at this, they present significant hurdles for enterprises regarding data privacy and operational costs. Small Language Models (SLMs, typically under 10B parameters) offer a private, cost-effective alternative but often lack the reasoning depth required for complex database schemas and ambiguous queries. The MATS framework addresses this "reasoning gap" by orchestrating a team of specialized agents and training them through automated execution feedback, achieving high performance without increasing model size.

Methodology

The MATS framework employs a two-pronged strategy: a multi-agent architecture and a novel training loop known as RLEF.

The Multi-Agent Pipeline

Instead of relying on a single model for the entire task, MATS decomposes Text2SQL into five specialized roles:

  • Schema Insight Agent: Filters irrelevant tables and matches natural language terms to database values.
  • Planner Agent: Decomposes queries into a "chain of thought" and generates multiple SQL candidates.
  • Validator Agent: Executes SQL against the database to flag errors or unexpected empty results.
  • Fix Agent: Refines and corrects SQL based on validator feedback.
  • Selection Agent: Selects the optimal final query from the candidate pool based on execution results.
The MATS Inference Pipeline illustrating the flow from natural language question to final SQL query through specialized agents.

Reinforcement Learning with Execution Feedback (RLEF)

To optimize these agents, MATS introduces RLEF, which uses the database itself as a teacher. The system generates multiple SQL queries; those matching ground-truth execution results are labeled "chosen," while others are "rejected." The models are then optimized using the Odds Ratio Preference Optimization (ORPO) algorithm. This approach allows for automated training without the need for expensive human ranking.

Evaluation and Results

The framework was evaluated on rigorous benchmarks, including Spider (and its robustness variants) and BIRD, a large-scale "big data" benchmark.

Performance and Efficiency

MATS, with a total parameter count of 9B, achieved 87.1% Execution Accuracy (EX) on Spider, outperforming larger models like CodeS-15B. On the BIRD benchmark, it reached 64.73% EX, comparable to GPT-4 based frameworks like CHESS.

Comparison of Execution Accuracy (EX%) vs. Parameter Count, showing MATS (9B) performing competitively against much larger models.

Beyond accuracy, MATS is highly efficient. The entire framework requires only 21.2 GB of GPU memory, allowing it to run on a single consumer-grade GPU (e.g., RTX 3090/4090). It also demonstrated significant robustness against "noisy" schema variations in the Dr.Spider dataset.

Discussion and Future Work

The success of MATS highlights that specialization can compensate for model size. By fine-tuning SLMs for specific roles like "Fixing" or "Planning," they can reach world-class performance levels. Furthermore, using execution results as a reinforcement signal provides a scalable way to improve model logic.

However, challenges remain. The multi-agent approach introduces higher inference latency (14-22 seconds per query) compared to single-pass models. Additionally, highly nested subqueries continue to be a difficult area for all models. Future research will focus on improving selection strategies and integrating domain-specific knowledge to further close the gap with proprietary LLMs.

Summary updated

BibTeX
@misc{hoang2025multi,
  author = {Thanh Dat Hoang and Thanh Trung Huynh and Matthias Weidlich and Thanh Nguyen and Tong Chen and Hongzhi Yin and Quoc Viet Hung Nguyen},
  title = {{A Multi-agent Text2SQL Framework using Small Language Models and Execution Feedback}},
  year = {2025},
  eprint = {2512.18622},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2512.18622},
}
Figure