Instructions to use cycloneboy/CscSQL-Grpo-Qwen2.5-Coder-3B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cycloneboy/CscSQL-Grpo-Qwen2.5-Coder-3B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="cycloneboy/CscSQL-Grpo-Qwen2.5-Coder-3B-Instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("cycloneboy/CscSQL-Grpo-Qwen2.5-Coder-3B-Instruct") model = AutoModelForCausalLM.from_pretrained("cycloneboy/CscSQL-Grpo-Qwen2.5-Coder-3B-Instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use cycloneboy/CscSQL-Grpo-Qwen2.5-Coder-3B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "cycloneboy/CscSQL-Grpo-Qwen2.5-Coder-3B-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cycloneboy/CscSQL-Grpo-Qwen2.5-Coder-3B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/cycloneboy/CscSQL-Grpo-Qwen2.5-Coder-3B-Instruct
- SGLang
How to use cycloneboy/CscSQL-Grpo-Qwen2.5-Coder-3B-Instruct with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "cycloneboy/CscSQL-Grpo-Qwen2.5-Coder-3B-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cycloneboy/CscSQL-Grpo-Qwen2.5-Coder-3B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "cycloneboy/CscSQL-Grpo-Qwen2.5-Coder-3B-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cycloneboy/CscSQL-Grpo-Qwen2.5-Coder-3B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use cycloneboy/CscSQL-Grpo-Qwen2.5-Coder-3B-Instruct with Docker Model Runner:
docker model run hf.co/cycloneboy/CscSQL-Grpo-Qwen2.5-Coder-3B-Instruct
CSC-SQL: Corrective Self-Consistency in Text-to-SQL via Reinforcement Learning
This repository contains the models and code for the paper CSC-SQL: Corrective Self-Consistency in Text-to-SQL via Reinforcement Learning.
📖 Paper on arXiv | 💻 GitHub Repository
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 private test set, our 7B model achieves 71.72% execution accuracy, while the 32B model achieves 73.67%.
Main Results
Performance Comparison of different Text-to-SQL methods on BIRD dev and test dataset. On the BIRD private test set, our 7B model achieves 71.72% execution accuracy, while the 32B model achieves 73.67%.
Model Checkpoints
The available models are fine-tuned on Qwen2.5-Coder and are accessible on Hugging Face:
| Model and Dataset | HuggingFace |
|---|---|
| CscSQL-Merge-Qwen2.5-Coder-3B-Instruct | 🤗 HuggingFace |
| CscSQL-Merge-Qwen2.5-Coder-7B-Instruct | 🤗 HuggingFace |
| CscSQL-Grpo-Qwen2.5-Coder-3B-Instruct | 🤗 HuggingFace |
| CscSQL-Grpo-XiYanSQL-QwenCoder-3B-2502 | 🤗 HuggingFace |
| CscSQL-Grpo-Qwen2.5-Coder-7B-Instruct | 🤗 HuggingFace |
| CscSQL-Grpo-XiYanSQL-QwenCoder-7B-2502 | 🤗 HuggingFace |
Quickstart
You can use this model with the transformers library. The config.json indicates Qwen2ForCausalLM as its architecture.
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
model_name = "cycloneboy/CscSQL-Grpo-Qwen2.5-Coder-7B-Instruct"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.bfloat16,
device_map="auto"
)
model.eval()
# Example usage for text-to-SQL generation
question = "List the names of all employees."
db_schema = "CREATE TABLE employees (id INT, name TEXT, salary INT);"
prompt = f"Question: {question}
Schema: {db_schema}
SQL: "
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
generation_config = GenerationConfig(
max_new_tokens=128,
do_sample=True,
temperature=0.7,
top_k=20,
top_p=0.8,
repetition_penalty=1.05,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.pad_token_id,
)
with torch.no_grad():
outputs = model.generate(
**inputs,
generation_config=generation_config
)
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
print(f"Generated SQL: {response}")
Citation
If you find our work helpful or inspiring, please feel free to cite our paper:
@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},
}
- Downloads last month
- 58
