Research map / Large language models / Agents, code and math
SQL-R1: Training Natural Language to SQL Reasoning Model By Reinforcement Learning
Read the paperCheck your idea against 108,967 papers
AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.
Trains NL2SQL reasoning models (SQL-R1) with GRPO-based reinforcement learning on Qwen2.5-Coder models, using a composite format/execution/result/length reward, with optional SFT cold start on synthetic SynSQL data.
Problem
Complex NL2SQL reasoning (multi-table joins, nested queries) and interpretability/generalization limits of SFT-trained text-to-SQL models.
Approach
Apply GRPO with a progressive reward (format, execution, execution-accuracy result, and length rewards) directly to NL2SQL generation with explicit think/answer reasoning, and study whether SFT cold start and synthetic data help, selecting final SQL by self-consistency over execution results.
Key results
- SQL-R1 with Qwen2.5-Coder-7B reports 88.7% on Spider test and 66.6% on BIRD dev with self-consistency over 8 candidates.
- SQL-R1 with Qwen2.5-Coder-14B reports 88.1% on Spider test and 67.1% on BIRD dev.
- Reward ablation on BIRD dev: removing the format, execution, result, or length reward drops accuracy from 63.1% to 60.4%, 60.7%, 62.4%, and 61.0% respectively.
Measured effects reported in the paper
| What was changed | Where | Measured | Effect |
|---|---|---|---|
| Apply SQL-R1 reinforcement learning to Qwen2.5-Coder-3B | Qwen2.5-Coder-3B · Spider Dev | execution accuracy: 77.0 -> 78.1 | Helped |
| Apply SQL-R1 reinforcement learning to Qwen2.5-Coder-3B | Qwen2.5-Coder-3B · Spider Test | execution accuracy: 77.2 -> 78.9 | Helped |
| Apply SQL-R1 reinforcement learning to Qwen2.5-Coder-3B | Qwen2.5-Coder-3B · BIRD Dev | execution accuracy: 50.5 -> 54.6 | Helped |
| Apply SQL-R1 reinforcement learning to Qwen2.5-Coder-7B | Qwen2.5-Coder-7B · Spider Dev | execution accuracy: 77.4 -> 87.6 | Helped |
| Apply SQL-R1 reinforcement learning to Qwen2.5-Coder-7B | Qwen2.5-Coder-7B · Spider Test | execution accuracy: 79.4 -> 88.7 | Helped |
| Apply SQL-R1 reinforcement learning to Qwen2.5-Coder-7B | Qwen2.5-Coder-7B · BIRD Dev | execution accuracy: 58.2 -> 63.1 | Helped |
| Apply SQL-R1 reinforcement learning to Qwen2.5-Coder-14B | Qwen2.5-Coder-14B · Spider Dev | execution accuracy: 87.0 -> 86.7 | No clear effect |
| Apply SQL-R1 reinforcement learning to Qwen2.5-Coder-14B | Qwen2.5-Coder-14B · Spider Test | execution accuracy: 88.0 -> 88.1 | Helped |
| Apply SQL-R1 reinforcement learning to Qwen2.5-Coder-14B | Qwen2.5-Coder-14B · BIRD Dev | execution accuracy: 66.1 -> 67.1 | Helped |
| Add the full reward function, including format reward (ablation) | SQL-R1 with Qwen2.5-Coder-7B · BIRD Dev | accuracy: 60.4 -> 63.1 | Helped |
| Add the full reward function, including execution reward (ablation) | SQL-R1 with Qwen2.5-Coder-7B · BIRD Dev | accuracy: 60.7 -> 63.1 | Helped |
| Add the full reward function, including result reward (ablation) | SQL-R1 with Qwen2.5-Coder-7B · BIRD Dev | accuracy: 62.4 -> 63.1 | Helped |
Surprising findings
- SFT cold start with reasoning instructions on SynSQL-200K did not improve BIRD-Dev accuracy for the 7B model (59.2% after SFT+RL vs 63.1% RL alone), so cold start is not universally beneficial.
- Smaller models benefited more from RL than the 14B model, which showed only minor improvement over its base.
Limitations
- Trained and evaluated only on SQLite-dialect datasets; other dialects untested.
- Experiments limited to Qwen2.5-Coder series models.
- Inconsistent reported numbers across the paper (e.g., BIRD dev for 7B given as 66.6% in the abstract and table but 63.1% in text; Spider test 88.6% vs 88.7%).
Experimental setup
Datasets: SynSQL-2.5M SynSQL-200K SynSQL-Complex-5K Spider BIRD Spider-DK Spider-Syn Spider-Realistic Spider2.0
Benchmarks: Spider BIRD Spider-DK Spider-Syn Spider-Realistic Spider2.0
Metrics: execution accuracy
Baselines: CodeS DTS-SQL CHESS Alpha-SQL SQL-o1 OmniSQL DeepRetrieval Reasoning-SQL DIN-SQL DAIL-SQL MCTS-SQL CHASE-SQL
Builds on: GRPO DeepSeek-R1 SynSQL-2.5M OmniSQL
Closest papers by meaning
- CogSQL: A Cognitive Framework for Enhancing Large Language Models in Text-to-SQL Translation (AAAI 2025 · similarity 0.89)
- MARS-SQL: A Multi-Agent Reinforcement Learning Framework For Text-To-SQL (ICML 2026 · similarity 0.88)
- ROUTE: Robust Multitask Tuning and Collaboration for Text-to-SQL (ICLR 2025 · similarity 0.88)
- Alpha-SQL: Zero-Shot Text-to-SQL using Monte Carlo Tree Search (ICML 2025 · similarity 0.88)
- Webscale-RL: Automated Data Pipeline for Scaling RL Data to Pretraining Levels (ICLR 2026 · similarity 0.87)
- Reshaping Reasoning in LLMs: A Theoretical Analysis of RL Training Dynamics through Pattern Selection (ICLR 2026 · similarity 0.87)
Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.
