Papers › SQL-R1: Training Natural Language to SQL Reasoning Model By Reinforcement Learning

SQL-R1: Training Natural Language to SQL Reasoning Model By Reinforcement Learning

11 Apr 2025arXiv:2504.08600links table onlyarchive 2025-07-28

Peixian Ma, Xialie Zhuang, Chengjin Xu, Xuhui Jiang, Ran Chen, Jian Guo

The archive published only this paper's code-link row. Authors, date and abstract are from arXiv's metadata (CC0), read from the Kaggle arXiv metadata snapshot of 2026-09-12 where its title matched the archive's; the title is the archive's.

Natural Language to SQL (NL2SQL) enables intuitive interactions with databases by transforming natural language queries into structured SQL statements. Despite recent advancements in enhancing human-computer interaction within database applications, significant challenges persist, particularly regarding the reasoning performance in complex scenarios involving multi-table joins and nested queries. Current methodologies primarily utilize supervised fine-tuning~(SFT) to train the NL2SQL model, which may limit adaptability and interpretability in new environments~(e.g., finance and healthcare). In order to enhance the reasoning performance of the NL2SQL model in the above complex situations, we introduce SQL-R1, a novel NL2SQL reasoning model trained by the reinforcement learning~(RL) algorithms. We design a specialized RL-based reward function tailored for NL2SQL tasks and discussed the impact of cold start and synthetic data on the effectiveness of intensive training. In addition, we achieve competitive accuracy using only a tiny amount of synthetic NL2SQL data for augmented training and further explore data engineering for RL. In existing experiments, SQL-R1 achieves execution accuracy of 88.6\% and 67.1\% on the benchmark Spider and BIRD, respectively. The code is available at https://github.com/IDEA-FinAI/SQL-R1 .

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2504.08600")

Code

Syntology Ran 12 of 22 code samples harvested from 2 repositories linked to this paper; 10 have no recorded run. Of those that ran: 1 ran · honoured contract; 4 ran · violated contract; 3 ran · our draft was wrong; 1 ran · fixture could not drive it; 3 ran with no contract checked.

By repository: official repository: 18 samples from 1 repository, 8 ran; community: 4 samples from 1 repository, 4 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

IDEA-FinAI/SQL-R1 officialmentioned in papermentioned on GitHubpytorchApache-2.0 report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

22 samples harvested; 12 ran; 1 honoured the contract we drafted; 10 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · honoured contract
4ran · violated contract
3ran · our draft was wrong
1ran · fixture could not drive it
3ran
10unverified

Licence: 0 of the 22 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 2 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

condition_has_like IDEA-FinAI/SQL-R1/src/evaluation_spider.py official repository ran · violated contract Apache-2.0 (permissive) · 8231e3fdffa9c8ee · report
condition_has_or IDEA-FinAI/SQL-R1/src/evaluation_spider.py official repository ran · violated contract fingerprinted Apache-2.0 (permissive) · f2d76234528d3b57 · report
get_schema IDEA-FinAI/SQL-R1/src/evaluations/spider1_evaluations/src/process_sql.py official repository ran fingerprinted Apache-2.0 (permissive) · 0992d2a47ae733fa · report
get_schema_from_json IDEA-FinAI/SQL-R1/src/evaluations/spider1_evaluations/src/process_sql.py official repository ran Apache-2.0 (permissive) · c4dcaf29b663a364 · report
read_data IDEA-FinAI/SQL-R1/src/evaluation_spider.py official repository ran Apache-2.0 (permissive) · 63fda278334d1f2e · report
remove_sql_comments IDEA-FinAI/SQL-R1/src/utils/prepare_input_seq.py official repository ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · f49ea7fd7f652e43 · report
union_tensor_dict IDEA-FinAI/SQL-R1/verl/protocol.py official repository ran · fixture could not drive it Apache-2.0 (permissive) · 21331a58f93375e4 · report
unpad_dataproto IDEA-FinAI/SQL-R1/verl/protocol.py official repository ran · our draft was wrong Apache-2.0 (permissive) · 25f0ea3f460f6ce1 · report
compare_sql IDEA-FinAI/SQL-R1/src/evaluation_bird_post.py official repository unverified Apache-2.0 (permissive) · 0d3763ae4f97d43c · report
compare_sql_wrapper IDEA-FinAI/SQL-R1/src/evaluation_bird_post.py official repository unverified Apache-2.0 (permissive) · 91f2db0ec7a2841f · report
execute_query IDEA-FinAI/SQL-R1/src/data_preprocess/nl2sql_synsql_nonvalue.py official repository unverified Apache-2.0 (permissive) · 6ad9f49ae16cf31d · report
execute_sql IDEA-FinAI/SQL-R1/src/evaluation_bird_post.py official repository unverified Apache-2.0 (permissive) · 490449c025d402b2 · report
format_sql IDEA-FinAI/SQL-R1/src/evaluation_spider_post.py official repository unverified Apache-2.0 (permissive) · 15b496c5d27aa7dc · report
get_schema_slot IDEA-FinAI/SQL-R1/src/data_preprocess/nl2sql_synsql_nonvalue.py official repository unverified Apache-2.0 (permissive) · 5e51a446415a6550 · report
get_table_names IDEA-FinAI/SQL-R1/src/data_preprocess/nl2sql_synsql_nonvalue.py official repository unverified Apache-2.0 (permissive) · 73750dcbdb55d522 · report
get_weight_loader IDEA-FinAI/SQL-R1/verl/models/weight_loader_registry.py official repository unverified Apache-2.0 (permissive) · 919cf310ad4c189a · report
obtain_db_ddls IDEA-FinAI/SQL-R1/src/utils/prepare_input_seq.py official repository unverified Apache-2.0 (permissive) · 062dbe705bf0ea9b · report
tokenize IDEA-FinAI/SQL-R1/src/evaluations/spider1_evaluations/src/process_sql.py official repository unverified Apache-2.0 (permissive) · b72b76d185b39d84 · report
parse_response DataArcTech/SQL-R1/src/inference.py community ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · 4127f7104f276d1b · report
permute_tuple DataArcTech/SQL-R1/src/evaluations/spider1_evaluations/src/exec_eval.py community ran · violated contract Apache-2.0 (permissive) · ea2e45a6df8f96db · report
quick_rej DataArcTech/SQL-R1/src/evaluations/spider1_evaluations/src/exec_eval.py community ran · violated contract Apache-2.0 (permissive) · dcd3006254e3d81a · report
unorder_row DataArcTech/SQL-R1/src/evaluations/spider1_evaluations/src/exec_eval.py community ran · honoured contract fingerprinted Apache-2.0 (permissive) · fb60a4c142ce9cb2 · report

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections