Improve model card: Add pipeline tag, library, comprehensive content, and correct GitHub links
#1
by nielsr HF Staff - opened
1234519 unmodified lines2526272829303132333435363738394041423 unmodified lines46474849---license: apache-2.0---<div align="center">19 unmodified lines</div><div align="center" style="display: flex; gap: 5px; justify-content: center;"><a href="https://idea-finai.github.io/SQL-R1/"><img src="https://img.shields.io/badge/🏠_Homepage-SQL--R1-4B4B77?style=flat-square"/></a><a href="https://arxiv.org/abs/2504.08600"><img src="https://img.shields.io/badge/📑_arXiv-2504.08600-00A98F?style=flat-square"/></a><a href="https://github.com/MPX0222/SQL-R1"><img src="https://img.shields.io/badge/⭐_GitHub-SQL--R1-2F80ED?style=flat-square"/></a><a href="https://huggingface.co/MPX0222forHF/SQL-R1-7B"><img src="https://img.shields.io/badge/🤗_HuggingFace-SQL--R1-FF9D00?style=flat-square"/></a><a href="https://github.com/MPX0222/SQL-R1/stargazers"><img src="https://img.shields.io/github/stars/MPX0222/SQL-R1?style=flat-square&color=946CE6"/></a></div>## 📖 OverviewNatural 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.## 📚 Citations```bibtex3 unmodified linesjournal={arXiv preprint arXiv:2504.08600},year={2025}}```123456719 unmodified lines27282930313233343536373839404142434445464748495051525354555657585960613 unmodified lines6566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201---license: apache-2.0pipeline_tag: text-generationlibrary_name: transformers---<div align="center">19 unmodified lines</div><div align="center" style="display: flex; gap: 5px; justify-content: center;"><a href="https://dataarctech.github.io/SQL-R1/"><img src="https://img.shields.io/badge/🏠_Homepage-blue?style=for-the-badge"/></a><a href="https://arxiv.org/abs/2504.08600"><img src="https://img.shields.io/badge/arXiv-red?style=for-the-badge&logo=arxiv"/></a><a href="https://huggingface.co/papers/2504.08600"><img src="https://img.shields.io/badge/Paper-HuggingFace-ffbd45.svg?style=for-the-badge&logo=huggingface"/></a><a href="https://github.com/IDEA-FinAI/SQL-R1"><img src="https://img.shields.io/badge/GitHub-black?style=for-the-badge&logo=github"/></a><a href="https://huggingface.co/MPX0222forHF/SQL-R1-7B"><img src="https://img.shields.io/badge/HuggingFace-FF9D00?style=for-the-badge&logo=huggingface"/></a><a href="https://www.modelscope.cn/models/MPX0222/SQL-R1-7B"><img src="https://img.shields.io/badge/🤖_ModelScope-946CE6?style=for-the-badge"/></a><a href="https://github.com/IDEA-FinAI/SQL-R1/stargazers"><img src="https://img.shields.io/github/stars/IDEA-FinAI/SQL-R1?style=for-the-badge&color=white"/></a></div><br><div align="center" style="display: flex; gap: 5px; justify-content: center;"><p><b>🔥 Our work is accepted by NeurIPS 2025. Welcome to star and cite our work! ✨</b></p></div>## 📖 OverviewNatural 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.<div align="center"><img src="images/overview.png" alt="SQL-R1 Overview" width="800"/><p align="center">Figure 1: Demonstration of our work.</p></div>## 📚 Citations```bibtex3 unmodified linesjournal={arXiv preprint arXiv:2504.08600},year={2025}}```## 📰 News- **[2025.09.18]** 🎉 SQL-R1 is accept by NeurIPS 2025! We will soon update the full version of the paper and poster. Welcome to star and cite our work!- **[2025.05.27]** 🎉 We have released the full version of SQL-R1.- **[2025.05.21]** 🎉 We have released our model weights on HuggingFace! Check out the [Model Weights](#-model-weights) section below.- **[2025.04.11]** 📑 Our paper is now available on [arXiv](https://arxiv.org/abs/2504.08600).## 🚀 Coming Soon Checklist- [x] 📝 Update the camera-ready version of the paper, homepage and poster. coming sooooon!- [x] 📊 Release model weights on HuggingFace and ModelScope- [x] 🔧 Open source training code and RL dataset- [x] 📝 Detailed documentation- [x] 🛠️ Environment setup guide## 🤖 Model WeightsWe 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](https://huggingface.co/MPX0222forHF/SQL-R1-3B) | - || SQL-R1 (7B) | 7B | [🤗 Download](https://huggingface.co/MPX0222forHF/SQL-R1-7B) | [��� Download](https://www.modelscope.cn/models/MPX0222/SQL-R1-7B) || SQL-R1 (14B) | 14B | [🤗 Download](https://huggingface.co/MPX0222forHF/SQL-R1-14B) | - |## 📑 Documentation StructureThis repository is organized as follows:```SQL-R1/├── data/ # Datasets│ ├── Spider/│ └── BIRD/├── models/ # Base models or checkpoints│ ├── Qwen2.5-Coder-3B-Instruct/│ └── Qwen2.5-Coder-7B-Instruct/......├── sh/ # Scripts for data processing, training, inference and evaluation├── src/ # Source code└── verl/ # Verl framework```## 🛠️ Environment Setup> [!NOTE]> Before getting started, make sure your computing environment supports the following settings:> - Environment: Python 3.9+> - CUDA Version: 12.0+ (for verl and vllm integration)> - GPU Prerequisites: 8 x 80GB+ GPU (for training) / 2 x 40GB GPU (for inference)### Installation1. Clone the repository:```bashgit clone https://github.com/IDEA-FinAI/SQL-R1.gitcd SQL-R1```2. Create and activate a virtual environment (recommended):```bashconda create -n sqlr1 python=3.9```3. Install dependencies:```bashpip install torch==2.4.0 --index-url https://download.pytorch.org/whl/cu121pip install vllm==0.6.3 raypip install flash-attn --no-build-isolationpip install -e . # For verl integrationpip install wandb IPython matplotlib sqlparse func_timeout nltk ijson```4. Download the model weights from HuggingFace and put them in the `models/` directory.5. 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.## 🚀 Quick Start1. Run training:```bashsh sh/train.sh```2. Run inference:```bashsh sh/inference.sh```3. Run evaluation:```bash# evaluate spidersh sh/eval_spider.sh# evaluate birdsh sh/eval_bird.sh```## 🌟 ApplicationsSQL-R1 can be effectively utilized in the following key areas:1. **Foundation Model for Workflow Systems**- Serves as a base model for complex database operations- Enables seamless integration with existing workflow automation systems- Supports customization and fine-tuning for specific business processes- Provides robust API endpoints for system integration2. **Enhanced NL2SQL Interpretability**- Generates detailed explanations for SQL query construction- Provides step-by-step reasoning for query transformation- Helps users understand the relationship between natural language and SQL syntax- Offers visualization of query execution plans3. **Self-Evolving NL2SQL Agent Checkpoint**- Acts as a foundation checkpoint for continuous learning- Enables iterative improvement through feedback loops- Supports transfer learning for domain-specific adaptations- Facilitates model versioning and performance trackingThis may be added in the future work. If you have any ideas, please feel free to contact us.## Thanks forWe thank [OmniSQL](https://github.com/RUCKBReasoning/OmniSQL) and follow their evaluation code and database information retrieval code. We have adapted and modified their evaluation scripts for our project.## Star History[](https://www.star-history.com/#IDEA-FinAI/SQL-R1&Date)
README.md+158-6