TL;DR
DualSQL consolidates schema linking and SQL generation into a single, parameter-shared LLM backbone optimized via multi-agent reinforcement learning. By introducing robust rollout guardrails and a stricter evaluation metric (REX), DualSQL-8B achieves a new single-model state-of-the-art of 71.1% execution accuracy on the BIRD benchmark, outperforming models four times its size.
What Problem Does This Paper Address?
Converting natural language questions into executable SQL queries (Text-to-SQL) is notoriously difficult for large language models (LLMs). The challenges are threefold: injecting massive database schemas into limited context windows degrades reasoning; queries require precise "schema linking" to map ambiguous user intent to rigid database structures; and standard evaluation metrics often fail to accurately judge query correctness.
To cope, state-of-the-art systems use modular pipelines that separate schema linking from SQL generation. However, existing approaches train separate models for each task, completely missing out on the natural synergy between them. Furthermore, when researchers try to use reinforcement learning (RL) to optimize these multi-turn, tool-using agents, the training becomes highly unstable, frequently suffering from format and mode collapse.
Methods
DualSQL addresses these gaps by unifying the schema linker and SQL generator into a single open-weight LLM backbone (tested on Qwen3-4B and 8B). Both agents share the exact same model weights and agentic scaffold, allowing them to learn shared database representations.
The framework introduces several key components:
- Database Access Tools: The agents interact with databases using three specialized tools: a SQL Executor for execution feedback and row sampling, a Full Text Search tool for fuzzy matching schema names, and a Database Profiler that offloads metadata analysis offline.
- Asynchronous Rollout System: To maximize throughput, an asynchronous controller manages the pipeline rollout, chaining the schema linking and SQL generation stages without strict synchronization bottlenecks.
- Agentic Rollout Guardrails: To stabilize Group Relative Policy Optimization (GRPO) training, the authors implement strict format checking. Crucially, they introduce a rollout cutoff (stopping the trajectory immediately upon a format violation) and loss masking (ignoring previous turns if a trajectory ends in an error) to prevent the model from learning "reward hacking" behaviors.
- Robust Execution Match (REX): Instead of relying on standard Execution Accuracy (EX)—which is sensitive to benign formatting variations and blind to row duplicates—the authors propose REX. REX deterministically computes exact execution equivalence by finding the maximum matching between result sets using a Linear Sum Assignment Problem (LSAP) solver.
Datasets
The models were trained on a refined version of the official BIRD (Big Bench for Relational Database Grounded Text-to-SQL) training set. After filtering out trivial and intractable examples and manually correcting 384 annotation errors, the final training set consisted of 3,755 examples.
Evaluation was conducted on the BIRD development set, and the Spider test set was utilized for out-of-domain generalization testing.
Key Insights and Ideas
- Synergy Beats Isolation: Treating schema linking and SQL generation as dual facets of a single agent significantly extends the performance ceiling. The multi-agent RL training boosts schema linking precision by 1.4% compared to training a standalone schema linker, proving that the tasks reinforce each other.
- Hard Filters Prevent Collapse: Standard RL stabilization techniques (like importance sampling) fail in multi-turn tool environments. Immediate rollout cutrails act as a vital hard filter, forcing the model to maintain format correctness throughout prolonged exploration.
- High-Fidelity Rewards Clean the Signal: Training with the stricter REX metric prevents the model from receiving false positives. Error analysis shows that models trained with standard EX struggle with
DISTINCTandORDER BYclauses because EX fails to distinguish these nuances, whereas REX provides a clean, un-noisy reward signal.
Key Results
- State-of-the-Art Efficiency: DualSQL-8B achieved 71.1% execution accuracy (EX) on the BIRD development set. This sets a new single-model state-of-the-art, outperforming much larger models like Arctic-Text2SQL-R1 (32B), which scored 70.5%.
- Small Model Punch: DualSQL-4B achieved 68.0% EX, matching or beating previous 7B and 14B parameter baselines.
- Robust Generalization: Despite being trained exclusively on BIRD, DualSQL-8B generalized exceptionally well to the Spider dataset, achieving 83.1% EX and 80.8% REX.
Limitations and Future Work
- Model Backbone Constraints: DualSQL was only instantiated on the Qwen3 family because it natively supports both extended reasoning and tool calling.
- Lack of Process Rewards: The current reward design relies entirely on outcome-based evaluation (REX). It lacks fine-grained, process-level reward signals that could guide the agent through highly complex, multi-step reasoning paths.
- Production Security: The agents require read-only database access. Deploying this system in production requires additional guardrails against query-induced resource exhaustion and adversarial prompt injection.
- Future Directions: The authors point toward developing inter-agent credit assignment mechanisms, scaling synthetic training data, and adapting the multi-agent RL recipe for even larger model architectures.
Summary updated