Views
No views yet


| Model and Dataset | HuggingFace Link |
|---|---|
| bird train and dev 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 |
transformers library. Below is an example of how to use the model for text-to-SQL generation. For more detailed instructions on training and evaluation, please refer to the official GitHub repository.1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4# Load the model and tokenizer
5model_id = "cycloneboy/CscSQL-Grpo-Qwen2.5-Coder-7B-Instruct" # Example 7B model from the project
6tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 device_map="auto",
10 torch_dtype="auto", # or torch.bfloat16 if supported
11 trust_remote_code=True # Required for custom architectures like Qwen2
12).eval()
13
14# Prepare your input: natural language question and database schema
15question = "What is the average age of students?"
16schema_info = """
17CREATE TABLE students (
18 student_id INT PRIMARY KEY,
19 name TEXT,
20 age INT,
21 major TEXT
22);
23""" # Replace with actual schema from your database
24
25# Construct the prompt using the Qwen2 chat template format
26# The model expects a structured input that includes the schema and question, followed by "SQL:"
27formatted_prompt = f"Given the following database schema:
28{schema_info}
29
30Generate a SQL query for the following natural language question:
31{question}
32SQL:"
33
34messages = [
35 {"role": "user", "content": formatted_prompt}
36]
37
38# Apply the chat template and tokenize
39text = tokenizer.apply_chat_template(
40 messages,
41 tokenize=False,
42 add_generation_prompt=True # Adds '<|im_start|>assistant
43' to prepare for model's response
44)
45
46inputs = tokenizer(text, return_tensors="pt").to(model.device)
47
48# Generate the SQL query
49generated_ids = model.generate(
50 **inputs,
51 max_new_tokens=256,
52 do_sample=False, # Use greedy decoding for reproducibility
53 temperature=0.7,
54 top_p=0.9,
55 eos_token_id=tokenizer.eos_token_id,
56 pad_token_id=tokenizer.pad_token_id,
57)
58
59# Decode and print the generated SQL
60# Note: The output may contain the original prompt and special tokens. Post-processing might be needed.
61output_text = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
62print(output_text)1@misc{sheng2025cscsqlcorrectiveselfconsistencytexttosql,
2 title={CSC-SQL: Corrective Self-Consistency in Text-to-SQL via Reinforcement Learning},
3 author={Lei Sheng and Shuai-Shuai Xu},
4 year={2025},
5 eprint={2505.13271},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2505.13271},
9}