Skip to content

CycloneBoy/csc_sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSC-SQL: Corrective Self-Consistency in Text-to-SQL via Reinforcement Learning

Important Links

📖Arxiv Paper | 🤗HuggingFace | 🤖ModelScope |

News

  • June 27, 2025: Uploaded the dataset and grpo training code for grpo training
  • May 27, 2025: The CSC-SQL 32B model achieved an Execution Accuracy (EX) of 73.67% on the BIRD test set, while the 7B model attained an EX of 71.72%, surpassing all other known methods based on open-source models.
  • May 25, 2025: Release model and inference code
  • May 19, 2025: Publish the paper to arxiv

Introduction

Large language models (LLMs) have demonstrated strong capabilities in translating natural language questions about relational databases into SQL queries. In particular, test-time scaling techniques such as Self-Consistency and Self-Correction can enhance SQL generation accuracy by increasing computational effort during inference. However, these methods have notable limitations: Self-Consistency may select suboptimal outputs despite majority votes, while Self-Correction typically addresses only syntactic errors. To leverage the strengths of both approaches, we propose CSC-SQL, a novel method that integrates Self-Consistency and Self-Correction. CSC-SQL selects the two most frequently occurring outputs from parallel sampling and feeds them into a merge revision model for correction. Additionally, we employ the Group Relative Policy Optimization (GRPO) algorithm to fine-tune both the SQL generation and revision models via reinforcement learning, significantly enhancing output quality. Experimental results confirm the effectiveness and generalizability of CSC-SQL. On the BIRD development set, our 3B model achieves 65.28% execution accuracy, while the 7B model achieves 69.19%. The code will be open sourced at https://github.com/CycloneBoy/csc_sql.

csc_sql_framework

Main Results

csc_sql_result

Performance Comparison of different Text-to-SQL methods on BIRD dev and test dataset. csc_sql_result main csc_sql_result main

Model

Model and Dataset Modelscope HuggingFace
bird train and dev dataset 🤖 Modelscope 🤗 HuggingFace
CscSQL-Merge-Qwen2.5-Coder-3B-Instruct 🤖 Modelscope 🤗 HuggingFace
CscSQL-Merge-Qwen2.5-Coder-7B-Instruct 🤖 Modelscope 🤗 HuggingFace
CscSQL-Grpo-Qwen2.5-Coder-3B-Instruct 🤖 Modelscope 🤗 HuggingFace
CscSQL-Grpo-XiYanSQL-QwenCoder-3B-2502 🤖 Modelscope 🤗 HuggingFace
CscSQL-Grpo-Qwen2.5-Coder-7B-Instruct 🤖 Modelscope 🤗 HuggingFace
CscSQL-Grpo-XiYanSQL-QwenCoder-7B-2502 🤖 Modelscope 🤗 HuggingFace

Dataset

Model and Dataset Modelscope HuggingFace
bird train and dev dataset 🤖 Modelscope 🤗 HuggingFace

bird GRPO dataset file description

# Original bird training and development sets directly obtained from the seeklhy/SynSQL-2.5M dataset (OmniSQL)
bird_train/train_bird.json
bird_train/dev_bird.json
# Dataset for sql generate grpo training organized from seeklhy/SynSQL-2.5M dataset  (OmniSQL)
bird_train/train_sql_generate_omnisql_bird.json
bird_train/dev_sql_generate_omnisql_bird.json
# Generated merged revision training set for bird
bird_train/train_merge_bird.json

Train and Eval

Eval docs

Train docs

TODO

  • Release inference code
  • Upload Model
  • Release training code
  • Fix bug
  • Update doc

Thanks to the following projects

Citation

@misc{sheng2025cscsqlcorrectiveselfconsistencytexttosql,
      title={CSC-SQL: Corrective Self-Consistency in Text-to-SQL via Reinforcement Learning}, 
      author={Lei Sheng and Shuai-Shuai Xu},
      year={2025},
      eprint={2505.13271},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2505.13271}, 
}

About

CSC-SQL: Corrective Self-Consistency in Text-to-SQL via Reinforcement Learning

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published