← All publications

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

Simone Papicchio1, Simone Rossi2, Luca Cagliero3, Paolo Papotti2

  1. Politecnico di Torino & EURECOM
  2. EURECOM
  3. 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%.

BIRD-Dev execution accuracy against model size, with Think2SQL improvements marked by green arrows
Think2SQL improves BIRD-Dev accuracy over its Qwen3 backbones; the arrows report relative gains. Green denotes Think2SQL, red task-specific reasoning, blue general reasoning, and orange other models. Proprietary-model positions use estimated sizes because their parameter counts are undisclosed.

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.

Think2SQL rollout and execution pipeline with cell precision, cell recall, tuple cardinality, and format rewards
A sampled query returns an extra column and too many rows. Cell precision, cell recall, and tuple cardinality give complementary feedback despite zero exact execution credit. The diagram shows the weighted QATCH-plus-format reward used in the reward ablation.

Let T\mathcal T and Tpred\mathcal T_{\mathrm{pred}} be target and predicted execution results. For nonempty results, QATCH averages cell precision, cell recall, and tuple cardinality:

RCP=∣{cells∣cells∈T∩Tpred}∣∣{cells∣cells∈Tpred}∣,RCR=∣{cells∣cells∈T∩Tpred}∣∣{cells∣cells∈T}∣,RTC=min⁡(∣T∣,∣Tpred∣)max⁡(∣T∣,∣Tpred∣),RQA=RCP+RCR+RTC3.\begin{aligned} R_{\mathrm{CP}}&=\frac{|\{\mathrm{cells}\mid\mathrm{cells}\in\mathcal T\cap\mathcal T_{\mathrm{pred}}\}|} {|\{\mathrm{cells}\mid\mathrm{cells}\in\mathcal T_{\mathrm{pred}}\}|},\\ R_{\mathrm{CR}}&=\frac{|\{\mathrm{cells}\mid\mathrm{cells}\in\mathcal T\cap\mathcal T_{\mathrm{pred}}\}|} {|\{\mathrm{cells}\mid\mathrm{cells}\in\mathcal T\}|},\\ R_{\mathrm{TC}}&=\frac{\min(|\mathcal T|,|\mathcal T_{\mathrm{pred}}|)} {\max(|\mathcal T|,|\mathcal T_{\mathrm{pred}}|)},\qquad R_{\mathrm{QA}}=\frac{R_{\mathrm{CP}}+R_{\mathrm{CR}}+R_{\mathrm{TC}}}{3}. \end{aligned}

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 REXR_{\mathrm{EX}} with dense RQAR_{\mathrm{QA}}, adding a binary format reward RFRR_{\mathrm{FR}}:

R(ϕ)=0.95Rϕ+0.05RFR,ϕ∈{EX,QA}.R(\phi)=0.95R_{\phi}+0.05R_{\mathrm{FR}}, \qquad \phi\in\{\mathrm{EX},\mathrm{QA}\}.

The resulting configurations are REXFMR_{\mathrm{EXFM}} and RQAFMR_{\mathrm{QAFM}}. Our gated alternative, RGATER_{\mathrm{GATE}}, 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.

Reward ablation table comparing sparse, dense, gated, Arctic-SQL, and SQL-R1 rewards on six benchmarks
With Qwen3-4B trained on BIRD, gated feedback reaches 59.6±0.3 on BIRD-Dev, compared with 54.5±0.7 for the sparse reward. The six-dataset weighted average also favors the dense formulations; subscripts report standard deviations across three evaluation trials.

Scaling the training signal with model capacity

Rewards guide updates through relative advantages. For a prompt with GG sampled responses and positive within-group reward variance, group scaling uses

Ai=Ri−E[Rj]V[Rj],j∈{1,…,G}.A_i=\frac{R_i-\mathbb E[R_j]}{\sqrt{\mathbb V[R_j]}}, \qquad j\in\{1,\ldots,G\}.

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.

Execution accuracy for three Qwen3 sizes under group, batch, and no scaling, with sparse and dense rewards
Reward design and advantage normalization interact across model sizes. The left panel measures BIRD-Dev accuracy; the right aggregates Spider benchmarks and EHRSQL with dataset-size weights. The strongest configuration depends on both model capacity and the evaluation distribution.

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.

Cold-start ablation comparing base, Thinking, supervised, and reinforcement-learning initializations across six datasets
Direct RL from the base Qwen3-4B model has the highest BIRD-Dev and EHRSQL scores among these initializations. Distilled SFT performs well on several Spider benchmarks. The contrast exposes a trade-off between immediate specialization and subsequent transfer.

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.

Execution accuracy versus training hours for full and subsampled RL, alongside supervised and pretrained baselines
For Qwen3-4B with gated rewards and group scaling, fewer unique training examples reduce wall-clock time. Full-data RL leads on BIRD-Dev, while half-data RL leads on the Spider/EHRSQL aggregate. SFT provides a faster, lower-accuracy reference under this setup.