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

Lei Sheng, Shuai-Shuai Xu
5/19/2025
cs.CL

Official code: CycloneBoy/csc_sql (66 stars, Apache-2.0, last commit 2025-08-12).

Abstract

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 private test set, our 7B model achieves 71.72\% execution accuracy, while the 32B model achieves 73.67\%. The code has been open sourced at https://github.com/CycloneBoy/csc_sql.

View on arXivView PDF

Code Implementations(1)

CycloneBoy/csc_sqlOfficial100%
Apache-2.0

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

6610Shell, PythonMay 19, 20251 years agoApache-2.0
grpoself-consistencytext-to-sql

Similar Papers

Cite this paper

@article{sheng2025cscsql,
  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},
  url    = {http://arxiv.org/abs/2505.13271v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2505.13271.svg)](https://codeofpaper.com/paper/2505.13271)

Discussion