Abstract
AGRO-SQL is a novel framework designed to overcome the primary bottlenecks in Text-to-SQL: data scarcity and reasoning limitations. By integrating a high-fidelity synthetic data factory with an "agentic" reinforcement learning (RL) approach, AGRO-SQL enables models to learn the underlying logic of SQL execution rather than simple pattern matching. Utilizing the stable Group Relative Policy Optimization (GRPO) algorithm and execution-verified data, the framework achieves a state-of-the-art 72.10% Execution Accuracy on the BIRD benchmark for single-model methods.
Introduction
Translating natural language into executable SQL queries (Text-to-SQL) is essential for democratizing data access. However, current Large Language Models (LLMs) struggle with two major issues: the high cost of annotated complex NL-SQL pairs and the inability to self-correct during generation. Standard Supervised Fine-Tuning (SFT) often results in models that mimic syntax without understanding execution logic, while traditional Reinforcement Learning (RL) is frequently unstable in sparse-reward SQL environments.
Methodology: The AGRO-SQL Pipeline
AGRO-SQL employs a dual-centric approach to stabilize training and improve reasoning capabilities.
1. Data-Centric: RL-Ready Iterative Synthesis
To break the "data scaling wall," the framework utilizes an iterative data factory. This process involves structural-aware synthesis through database augmentation and SQL decomposition. Crucially, the pipeline employs a Generation-as-Verification strategy, retaining only synthetic trajectories where execution results perfectly match the ground truth. This "zero-noise" approach prevents reward hacking during the RL phase.
2. Model-Centric: Agentic RL with GRPO
AGRO-SQL treats SQL generation as an agentic task where the model interacts with the database environment.
- Diversity-Aware Cold Start: The model is initialized using high-quality interactive trajectories distilled from a teacher model.
- Group Relative Policy Optimization (GRPO): Unlike standard PPO, GRPO refines the policy by comparing a group of generated trajectories against each other. This eliminates the need for a complex value network, significantly stabilizing training in sparse-reward environments.
3. Inference-Time Strategy
At test time, the system uses a three-stage context augmentation (profiling columns, generating semantic descriptions, and dynamic pruning) followed by a multi-turn refinement loop. If an initial SQL draft fails, the agent observes the execution error and iteratively refines the query.
Experimental Results
The framework was evaluated on the Spider and BIRD (Big Bench for Large-scale Database Grounded Text-to-SQLs) benchmarks. BIRD is particularly challenging, featuring 95 large-scale databases and complex reasoning requirements.
As shown in the results, AGRO-SQL (using a Qwen3-8B-Base backbone) achieved:
- BIRD Benchmark: 72.10% Execution Accuracy (EX), setting a new state-of-the-art for single-model methods.
- Spider Benchmark: 89.13% EX.
- Efficiency: It significantly outperformed standard RL baselines (which averaged ~63% on BIRD), demonstrating that high-fidelity data combined with GRPO is more effective than simply increasing compute for standard RL.
Discussion and Insights
- Execution as Ground Truth: By shifting from string-matching (SFT) to execution-matching (RL), the model internalizes SQL logic.
- The Agentic Advantage: Treating Text-to-SQL as a multi-turn interaction (Action -> Feedback -> Correction) allows smaller models (8B parameters) to outperform much larger models that rely on one-shot generation.
- Stability via GRPO: Relative reward comparison within groups prevents the training "explosions" common in traditional RL, making the optimization process more robust.
Limitations and Future Work
While highly effective, the approach depends on a runnable database environment for training, which may not be feasible in all production settings. Additionally, while execution equivalence ensures correct answers, it does not strictly guarantee that the SQL structure perfectly matches the user's semantic intent in every edge case. Future research will explore "execution-free" feedback signals to reduce computational overhead.
Summary updated