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

Think2SQL: Reinforce LLM Reasoning Capabilities for Text2SQL

Simone Papicchio, Simone Rossi, Luca Cagliero, Paolo PapottiarXiv 2025 · DOI

Introduction

While Large Language Models (LLMs) have become increasingly proficient at writing simple SQL, they often struggle with complex, multi-table databases that require multi-step logical reasoning. Most current approaches rely on Supervised Fine-Tuning (SFT), which is constrained by the availability of high-quality human labels.

When researchers turn to Reinforcement Learning (RL) to overcome these limits, they encounter a "sparsity" wall: if the reward is binary (1 for a correct query, 0 for incorrect), small models often fail to learn because they cannot find the "correct" path by accident during early training. Think2SQL addresses this by providing a systematic blueprint for using Reinforcement Learning with Verifiable Rewards (RLVR) to inject complex reasoning into models under 14B parameters.

Methodology: RLVR and Gated Rewards

The researchers utilized Reinforcement Learning with Verifiable Rewards (RLVR), specifically a variant of Group-Relative Policy Optimization (GRPO). Their core innovation is the Gated Execution Reward ($R_{GATE}$). Instead of a simple "pass/fail" binary signal, they introduced a dense reward based on the QATCH framework, which evaluates the data returned by the query to calculate Cell Precision, Cell Recall, and Tuple Cardinality.

The Think2SQL training pipeline using RLVR and dense rewards to provide granular feedback.

This approach provides "partial credit" to the model, guiding it toward the correct logic even if the final SQL syntax contains minor errors. Additionally, the team implemented Reasoning Distillation, creating a "cold-start" dataset by distilling reasoning traces from Gemini-3 Flash. This teaches the model to "think" using <reasoning> tags before generating the final SQL code.

Experimental Setup

The study evaluated the Think2SQL family across several industry-standard benchmarks:

  • BIRD (Big Bench for Large-scale Database Grounding): The primary target for real-world complexity and scale.
  • Spider (and variants like Syn, DK, Realistic): Used to test cross-domain generalization and robustness against lexical shifts.
  • EHRSQL: A specialized benchmark for the medical domain to test adaptation to technical terminology.

Key Results and Insights

The Think2SQL family sets a new bar for parameter-efficient reasoning. Think2SQL-4B achieved 59.6% Execution Accuracy (EX) on the BIRD dev set, outperforming the previous state-of-the-art RL model (SQL-R1-3B) by 16.7 percentage points.

Execution Accuracy vs. Model Size (Log Scale) showing Think2SQL models outperforming significantly larger counterparts.

As shown in the performance comparison, the 14B model surpassed OmniSQL-32B by 2.7 points, proving that optimized training can overcome raw parameter count. Notably, the 4B and 14B versions demonstrate performance parity with proprietary frontier models like GPT-5.2 (preview) and OpenAI o3 on several benchmarks, despite being orders of magnitude smaller.

A key insight from the study is the Scale-Density Interdependence: small models (4B) are fragile and require dense rewards and conservative scaling to converge, whereas larger models (14B+) are robust enough to learn from sparse signals. Furthermore, the authors found that RLVR is incredibly data-efficient; training on just 12.5% of the dataset with RLVR outperformed a full-data SFT approach.

Conclusion

Think2SQL demonstrates that Reinforcement Learning with Verifiable Rewards can act as a powerful "refiner" to align model knowledge with specific execution constraints. While the study focused on the Qwen3 architecture, it provides a blueprint for teaching small LLMs to reason as effectively as much larger models. Future work will explore hybrid reward signals and methods to reduce the significant computational overhead required for RLVR training.

Summary updated

BibTeX
@misc{papicchio2025think,
  author = {Simone Papicchio and Simone Rossi and Luca Cagliero and Paolo Papotti},
  title = {{Think2SQL: Reinforce LLM Reasoning Capabilities for Text2SQL}},
  year = {2025},
  eprint = {2504.15077},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.15077},
}
Figure