Think2SQL: Blueprinting Reward Density and Advantage Scaling for Effective Text-to-SQL Reasoning
- Large Language Models
We study how reward density and advantage scaling shape reinforcement learning for Text-to-SQL, identifying training choices that depend on model capacity.
Paper TMLR 2026
- Politecnico di Torino & EURECOM
- EURECOM
- Politecnico di Torino
Text-to-SQL turns a natural-language question and database schema into an executable query. Correct execution provides a verifiable signal for reinforcement learning (RL), but binary correctness gives little feedback when most sampled queries are wrong. In Think2SQL, we study how partial execution credit interacts with advantage scaling and model capacity. Across Qwen3 models, dense feedback helps the 4B model, while larger models can benefit from sparse rewards. Our best 4B configuration raises BIRD-Dev execution accuracy from 49.0% to 59.6%.

Learning from partially correct query results
We condition generation on the question, evidence, and an enriched schema containing descriptions and column examples. Each rollout produces a reasoning trace and SQL answer. We execute the answer against the database and compare its returned table with the target query's result. Our refined execution accuracy preserves duplicate rows and permits column-order permutations, making the evaluation sensitive to returned content and multiplicity.

Let and be target and predicted execution results. For nonempty results, QATCH averages cell precision, cell recall, and tuple cardinality:
Precision measures excess predicted content, recall measures missing target content, and cardinality penalizes incorrect row counts. Together they distinguish several forms of partial correctness that receive the same binary execution reward. Partial execution agreement is a training proxy whose usefulness depends on how closely it tracks the intended query semantics.
We compare a sparse task signal with dense , adding a binary format reward :
The resulting configurations are and . Our gated alternative, , assigns zero to non-executable SQL, supplies a 0.1 floor for correctly formatted executable queries with QATCH at most 0.1, and uses QATCH alone above that threshold. The gate concentrates higher-quality feedback on query content.

Scaling the training signal with model capacity
Rewards guide updates through relative advantages. For a prompt with sampled responses and positive within-group reward variance, group scaling uses
The mean centers the preference signal; the standard deviation sets its magnitude. We also evaluate batch scaling and removal of variance normalization. Sparse rewards can leave a group with identical scores and no preference information. Dense feedback creates more opportunities to rank imperfect candidates.
We train Qwen3-4B, 8B, and 14B on BIRD with a DAPO objective, omitting dynamic sampling, using 16 generations and a 4,096-token limit. Dense gated rewards with group scaling work well at 4B. At 8B and 14B, sparse rewards with batch scaling become competitive. These are empirical findings within the tested configurations.

Initialization and compute change the trade-off
For Qwen3-4B, we compare direct RL with initialization from Thinking mode or supervised fine-tuning (SFT) using a corpus of 5,682 Gemini3-Flash distilled examples, with 20% held out. Distilled SFT improves the initial policy, yet subsequent RL reaches 59.4% on BIRD-Dev versus 59.6% from the base initialization. On EHRSQL, the corresponding scores are 26.2% and 33.5%. We hypothesize that teacher-specific patterns constrain exploration; the experiments measure the initialization effect.

With approximately 565 gradient updates held fixed, subsampling BIRD reduces unique examples and execution overhead. Half-data RL reaches 58.4% on BIRD-Dev and 72.2% on the held-out benchmark aggregate, versus 59.6% and 71.4% with full data. The preferred budget therefore depends on the target distribution.
