| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Peixian Ma1,2 Xialie Zhuang1,3 Chengjin Xu1,4 Xuhui Jiang1,4 Ran Chen1 Jian Guo1
1IDEA Research, International Digital Economy Academy 2The Hong Kong University of Science and Technology (Guangzhou) 3University of Chinese Academy of Science 4DataArc Tech Ltd.
🔥 Our work is accepted by NeurIPS 2025. Welcome to star and cite our work! ✨
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 inference 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 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.
@article{ma2025sql,
title={SQL-R1: Training Natural Language to SQL Reasoning Model By Reinforcement Learning},
author={Ma, Peixian and Zhuang, Xialie and Xu, Chengjin and Jiang, Xuhui and Chen, Ran and Guo, Jian},
journal={arXiv preprint arXiv:2504.08600},
year={2025}
}We are excited to release our SQL-R1 model weights! You can find them on HuggingFace:
| Model | Size | HuggingFace Link | ModelScope Link |
|---|---|---|---|
| SQL-R1 (3B) | 3B | 🤗 Download | - |
| SQL-R1 (7B) | 7B | 🤗 Download | 🤖 Download |
| SQL-R1 (14B) | 14B | 🤗 Download | - |
This repository is organized as follows:
SQL-R1/ ├── 📁 data/ # Datasets and Databases │ ├── 📁 Spider/ │ └── 📁 BIRD/ ├── 📁 models/ # Foundation models or checkpoints │ ├── 📁 Qwen2.5-Coder-3B-Instruct/ │ └── 📁 Qwen2.5-Coder-7B-Instruct/ ├── 📁 db_info/ # Database information files (Just for inference) ├── 📁 example_data/ # Example data (Training) ├── 📁 sh/ # Scripts for data processing, training, inference and evaluation │ ├── 📄 train.sh │ ├── 📄 inference.sh │ ├── 📄 eval_spider.sh │ └── 📄 eval_bird.sh ├── 📁 src/ # Source code │ ├── 📁 data_preprocess/ │ ├── 📁 evaluations/ │ ├── 📁 utils/ │ ├── 📄 inference.py │ └── 📄 evaluation_*.py ├── 📁 verl/ # Verl reinforcement learning framework ├── 📄 requirements.txt └── 📄 README.md
Note
Before getting started, make sure your computing environment supports the following settings:
git clone https://github.com/MPX0222/SQL-R1.git
cd SQL-R1conda create -n sqlr1 python=3.9pip install torch==2.4.0 --index-url https://download.pytorch.org/whl/cu121
pip install vllm==0.6.3 ray
pip install flash-attn --no-build-isolation
pip install -e . # For verl integration
pip install wandb IPython matplotlib sqlparse func_timeout nltk ijsonDownload the model weights from HuggingFace and put them in the models/ directory.
For training, copy the training dataset in the example_data directory to the data directory. For inference, copy the database information in the db_info directory (including files forSpider-dev, Spider-test and BIRD-dev) to the related dataset (data/Spider, data/BIRD) directory.
sh sh/train.shsh sh/inference.sh# evaluate spider
sh sh/eval_spider.sh
# evaluate bird
sh sh/eval_bird.shSQL-R1 can be effectively utilized in the following key areas:
Foundation Model for Workflow Systems
Enhanced NL2SQL Interpretability
Self-Evolving NL2SQL Agent Checkpoint
This may be added in the future work. If you have any ideas, please feel free to contact us.
We thank OmniSQL and follow their evaluation code and database information retrieval code. We have adapted and modified their evaluation scripts for our project.
| Back | FazBrowse Home | New Git URL |