Views
No views yet
CscSQL-Grpo-Qwen2.5-Coder-7B-Instruct model, presented in the paper CSC-SQL: Corrective Self-Consistency in Text-to-SQL via Reinforcement Learning.

| 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 |
transformers library. Here's a quick example for Text-to-SQL generation following the Qwen chat template:1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
3
4model_name = "cycloneboy/CscSQL-Grpo-Qwen2.5-Coder-7B-Instruct"
5
6tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
7model = AutoModelForCausalLM.from_pretrained(
8 model_name,
9 device_map="auto",
10 torch_dtype=torch.bfloat16,
11 trust_remote_code=True
12).eval()
13
14# Example natural language question and a simplified database schema
15question = "List the names of all employees who work in the 'Sales' department."
16schema = """
17CREATE TABLE employees (
18 employee_id INT PRIMARY KEY,
19 name VARCHAR(255),
20 department_id INT
21);
22
23CREATE TABLE departments (
24 department_id INT PRIMARY KEY,
25 department_name VARCHAR(255)
26);
27"""
28
29# Construct the prompt according to the model's expected input format for Text-to-SQL
30# This is typically a combination of natural language question and the schema
31user_prompt = f"Question: {question}
32Schema: {schema}
33SQL:"
34
35messages = [
36 {"role": "user", "content": user_prompt}
37]
38
39# Apply the chat template to format the input for the model
40text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
41model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
42
43# Define generation configuration
44generation_config = GenerationConfig(
45 do_sample=True,
46 temperature=0.7,
47 top_p=0.8,
48 top_k=20,
49 repetition_penalty=1.05,
50 max_new_tokens=512, # Adjust as needed for SQL query length
51 eos_token_id=tokenizer.eos_token_id,
52 pad_token_id=tokenizer.pad_token_id,
53)
54
55# Generate the SQL query
56generated_ids = model.generate(
57 model_inputs.input_ids,
58 generation_config=generation_config
59)
60
61# Decode the generated SQL, skipping the input prompt
62generated_sql = tokenizer.batch_decode(generated_ids[:, model_inputs.input_ids.shape[1]:], skip_special_tokens=True)[0]
63
64print("Generated SQL Query:")
65print(generated_sql)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}