Skip to content

CycloneBoy/csc_sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Important Links

📖Arxiv Paper | 🤗HuggingFace | 🤖ModelScope |

News

  • 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

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

Train and Eval

Eval docs

Train docs

TODO

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

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