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

Reasoning-SQL: Reinforcement Learning with SQL Tailored Partial Rewards for Reasoning-Enhanced Text-to-SQL

Mohammadreza Pourreza, Shayan Talaei, Ruoxi Sun, Xingchen Wan, Hailong Li, Azalia Mirhoseini, Amin Saberi, Sercan O Arik

TL;DR

This paper introduces Reasoning-SQL, a novel reinforcement learning (RL) framework that uses tailored partial rewards to enhance Text-to-SQL capabilities in large language models (LLMs). By addressing reward sparsity with specific rewards for schema linking, AI feedback, syntax, and N-gram similarity, Reasoning-SQL significantly improves accuracy and generalization, even outperforming larger proprietary models.

What Problem Does This Paper Address?

Text-to-SQL, the task of translating natural language questions into SQL queries, is complex, requiring deep understanding of language, database schemas, and intricate reasoning. Existing methods often rely on predefined reasoning paths, which can limit their effectiveness. A key challenge is the "reward sparsity" in RL, where models receive infrequent or binary feedback (e.g., correct/incorrect SQL execution), making it hard to learn nuanced reasoning. This paper aims to overcome these limitations by developing a more informative and granular reward system for RL-based Text-to-SQL training.

Methods

The core of this work is the Reasoning-SQL framework, which employs Reinforcement Learning (RL), specifically Group Relative Policy Optimization (GRPO), to train LLMs for Text-to-SQL. The novelty lies in a custom suite of partial rewards designed to address the reward sparsity problem:

  • Execution Accuracy (RLEF): The standard reward, checking if the generated SQL query produces the correct output.
  • LLM-as-a-Judge (RLAIF): An LLM acts as a judge to provide nuanced feedback on queries that fail execution accuracy, assessing logical consistency and semantic correctness.
  • Syntax Check: Rewards syntactically valid SQL queries.
  • Schema Linking: Rewards accurate mapping of natural language entities to database schema elements, measured by Jaccard similarity.
  • N-gram Similarity: Rewards lexical and syntactic overlap with the gold query.
  • Format Reward: Encourages adherence to specific output structures (e.g., using <reasoning> tags).

These partial rewards are combined into a composite reward, which GRPO uses to optimize the LLM's policy for generating better SQL queries and reasoning steps.

Datasets

The primary dataset used for training and evaluation is BIRD. The authors also used Spider, Spider-DK, and Spider-Syn for generalization analysis. The BIRD dataset was filtered to remove noisy or ambiguous queries.

Key Insights and Ideas

  • Partial Rewards are Crucial for Text-to-SQL RL: The paper strongly demonstrates that a sparse execution accuracy reward is insufficient for effective RL training in Text-to-SQL. A well-designed set of partial rewards provides the granular feedback needed for LLMs to learn complex reasoning.
  • LLM-as-a-Judge is Effective for Nuanced Feedback: Using an LLM to evaluate incorrect queries offers a scalable way to provide more informative feedback than binary execution results alone.
  • Emergent Reasoning is Powerful: The RL training process naturally leads LLMs to develop structured reasoning patterns, which are shown to be more effective than human-designed reasoning strategies for Text-to-SQL.
  • RL Outperforms SFT for Generalization: While supervised fine-tuning (SFT) can lead to memorization, RL-based training with these rewards fosters robust generalization capabilities.
  • Smaller Models Can Compete: The approach enables smaller LLMs to achieve state-of-the-art performance, significantly reducing the cost and computational requirements compared to larger proprietary models.

Key Results

  • Reasoning-SQL, using RL with partial rewards, consistently outperforms supervised fine-tuning (SFT) across various model sizes.
  • The 14B-parameter RL-trained model achieved state-of-the-art results on the BIRD benchmark, outperforming larger proprietary models like O3-mini by 4% and Gemini-1.5-Pro-002 by 3%.
  • When integrated into the CHASE-SQL pipeline, the approach achieved 72.78% execution accuracy on the BIRD test set, matching performance of larger models at a significantly lower cost (93% reduction).
  • The emergent reasoning style developed by the model consistently outperformed human-designed thinking formats when used as few-shot examples.

Limitations and Future Work

  • Cost of LLM-as-a-Judge: While effective, using an LLM for judging introduces computational cost. The authors acknowledge this but highlight that the overall cost reduction is still substantial.
  • Generalization to Out-of-Distribution Tasks: While generalization was tested on Spider variants, further exploration on more diverse out-of-distribution tasks could be beneficial.
  • Further Exploration of Reward Weighting: The paper mentions that weights were carefully chosen, but a more in-depth analysis of optimal weight configurations for different tasks or model sizes could be a future direction.
  • Continued Improvement of Reasoning: The paper shows emergent reasoning, but further research into guiding and refining this emergent reasoning process could lead to even more robust and interpretable models.

Summary updated

BibTeX
@inproceedings{pourreza2025reasoning,
  author = {Mohammadreza Pourreza and Shayan Talaei and Ruoxi Sun and Xingchen Wan and Hailong Li and Azalia Mirhoseini and Amin Saberi and Sercan O Arik},
  title = {{Reasoning-SQL: Reinforcement Learning with SQL Tailored Partial Rewards for Reasoning-Enhanced Text-to-SQL}},
  booktitle = {COLM},
  year = {2025},
  url = {https://openreview.net/forum?id=HbwkIDWQgN},
}
Figure