Commit
·
59c7ef4
1
Parent(s):
a2f2fb4
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,149 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
---
|
4 |
+
### Important Links
|
5 |
+
|
6 |
+
📖[Github](https://github.com/XGenerationLab/XiYanSQL-QwenCoder) |
|
7 |
+
🤗[HuggingFace](https://huggingface.co/collections/XGenerationLab/xiyansql-models-67c9844307b49f87436808fc) |
|
8 |
+
🌐[XiYan-SQL](https://github.com/XGenerationLab/XiYan-SQL) |
|
9 |
+
🌕[析言GBI](https://bailian.console.aliyun.com/xiyan) |
|
10 |
+
🤖[Modelscope Space](https://www.modelscope.cn/studios/XGenerationLab/XiYanSQL-QwenCoder-32B)
|
11 |
+
|
12 |
+
|
13 |
+
## Introduction
|
14 |
+
We are excited to update our new XiYanSQL-QwenCoder series model, demonstrating improvements over its predecessor in some key features.
|
15 |
+
- The new XiYanSQL-QwenCoder model applies the merits of GRPO training strategy without thinking process, maintaining high efficiency and accuracy in SQL generation.
|
16 |
+
- The new XiYanSQL-QwenCoder model keeps its great performance in various benchmarks, including BIRD, Spider and DW benchmarks which will be released in the future.
|
17 |
+
- The new XiYanSQL-QwenCoder model demonstrates better generalization than its predecessor, especially in different dialects and out-of-domain datasets.
|
18 |
+
|
19 |
+
|
20 |
+
## Model Downloads
|
21 |
+
|
22 |
+
|
23 |
+
| **Model** | **Download Latest** |
|
24 |
+
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
25 |
+
|XiYanSQL-QwenCoder-3B | 🤗[HuggingFace](https://huggingface.co/XGenerationLab/XiYanSQL-QwenCoder-3B-2504) 🤖[Modelscope](https://www.modelscope.cn/models/XGenerationLab/XiYanSQL-QwenCoder-3B-2504) |
|
26 |
+
|XiYanSQL-QwenCoder-7B | 🤗[HuggingFace](https://huggingface.co/XGenerationLab/XiYanSQL-QwenCoder-7B-2504) 🤖[Modelscope](https://www.modelscope.cn/models/XGenerationLab/XiYanSQL-QwenCoder-7B-2504) |
|
27 |
+
|XiYanSQL-QwenCoder-14B | 🤗[HuggingFace](https://huggingface.co/XGenerationLab/XiYanSQL-QwenCoder-14B-2504) 🤖[Modelscope](https://www.modelscope.cn/models/XGenerationLab/XiYanSQL-QwenCoder-14B-2504) |
|
28 |
+
|XiYanSQL-QwenCoder-32B | 🤗[HuggingFace](https://huggingface.co/XGenerationLab/XiYanSQL-QwenCoder-32B-2504) 🤖[Modelscope](https://www.modelscope.cn/models/XGenerationLab/XiYanSQL-QwenCoder-32B-2504) |
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
## Performance
|
33 |
+
The XiYanSQL-QwenCoder models, as multi-dialect SQL base models, demonstrating robust SQL generation capabilities. The following presents the evaluation results at the time of release. We conducted a comprehensive evaluation of the model's performance under two schema formats, M-Schema, and original DDL, using the BIRD and Spider as SQLite benchmarks in the Text-to-SQL domain, as well as DW benchmarks for PostgreSQL and MySQL dialects.
|
34 |
+
|
35 |
+
| Model name | Size | BIRD Dev@M-Schema | BIRD Dev@DDL | Spider Test@M-Schema | Spider Test@DDL | DW PostgreSQL@M-Schema | DW MySQL@M-Schema |
|
36 |
+
|------------------------------|:------:|:-----------------:|:------------:|:--------------------:|:---------------:|:----------------------:|:-----------------:|
|
37 |
+
| GPT-4o-0806 | UNK | 58.47% | 54.82% | 82.89% | 78.45% | 46.79% | 57.77% |
|
38 |
+
| GPT-4.1-0414 | UNK | 59.39% | 54.11% | 84.45% | 79.86% | 54.29% | 63.18% |
|
39 |
+
| Claude3.5-sonnet-1022 | UNK | 53.32% | 50.46% | 76.27% | 73.04% | 55.22% | 52.84% |
|
40 |
+
| Claude3.7-sonnet | UNK | 54.82% | 49.22% | 78.04% | 74.66% | 53.23% | 54.61% |
|
41 |
+
| Gemini-1.5-Pro | UNK | 61.34% | 57.89% | 85.11% | 84.00% | 52.78% | 62.78% |
|
42 |
+
| Gemini-2.5-Pro | UNK | 67.21% | 63.43% | 88.29% | 86.27% | 63.16% | 65.37% |
|
43 |
+
| DeepSeek-V2.5-1210 | 236B | 55.74% | 55.61% | 82.08% | 80.57% | 45.74% | 52.18% |
|
44 |
+
| DeepSeek-V3 | 685B | 59.58% | 56.71% | 81.52% | 79.91% | 52.56% | 55.95% |
|
45 |
+
| DeepSeek-R1 | 685B | 58.15% | 55.61% | 80.72% | 78.85% | 60.56% | xx% |
|
46 |
+
| DeepSeek-R1-Distill-Qwen-32B | 32B | 50.65% | 48.31% | 78.65% | 77.33% | 37.22% | 44.72% |
|
47 |
+
| Deepseek-Coder-33B-Instruct | 33B | 47.52% | 44.72% | 72.39% | xx% | 31.48% | 36.17% |
|
48 |
+
| OmniSQL-32B | 32B | 60.37% | 55.87% | 85.16% | 83.19% | 38.19% | 42.34% |
|
49 |
+
| XiYanSQL-QwenCoder-32B-2412 | 32B | 67.07% | 63.04% | 88.39% | 85.46% | 45.07% | 52.84% |
|
50 |
+
| XiYanSQL-QwenCoder-32B-2504 | 32B | 67.14% | 62.26% | 89.20% | 86.17% | 53.52% | 57.74% |
|
51 |
+
|
52 |
+
|
53 |
+
## Requirements
|
54 |
+
|
55 |
+
transformers >= 4.37.0
|
56 |
+
vllm >= 0.7.2
|
57 |
+
|
58 |
+
## Quickstart with Transformers and vLLM
|
59 |
+
|
60 |
+
Here is a simple code snippet for quickly using **XiYanSQL-QwenCoder** model. We provide a Chinese version of the prompt, and you just need to replace the placeholders for "question," "db_schema," and "evidence" to get started. We recommend using our [M-Schema](https://github.com/XGenerationLab/M-Schema) format for the schema; other formats such as DDL are also acceptable, but they may affect performance.
|
61 |
+
Currently, we mainly support mainstream dialects like SQLite, PostgreSQL, and MySQL.
|
62 |
+
|
63 |
+
### Prompt Template
|
64 |
+
```python
|
65 |
+
nl2sqlite_template_cn = """你是一名{dialect}专家,现在需要阅读并理解下面的【数据库schema】描述,以及可能用到的【参考信息】,并运用{dialect}知识生成sql语句回答【用户问题】。
|
66 |
+
【用户问题】
|
67 |
+
{question}
|
68 |
+
|
69 |
+
【数据库schema】
|
70 |
+
{db_schema}
|
71 |
+
|
72 |
+
【参考信息】
|
73 |
+
{evidence}
|
74 |
+
|
75 |
+
【用户问题】
|
76 |
+
{question}
|
77 |
+
|
78 |
+
```sql"""
|
79 |
+
```
|
80 |
+
|
81 |
+
|
82 |
+
### Inference with Transformers
|
83 |
+
```python
|
84 |
+
import torch
|
85 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
86 |
+
|
87 |
+
model_name = "XGenerationLab/XiYanSQL-QwenCoder-32B-2502"
|
88 |
+
model = AutoModelForCausalLM.from_pretrained(
|
89 |
+
model_name,
|
90 |
+
torch_dtype=torch.bfloat16,
|
91 |
+
device_map="auto"
|
92 |
+
)
|
93 |
+
|
94 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
95 |
+
|
96 |
+
## dialects -> ['SQLite', 'PostgreSQL', 'MySQL']
|
97 |
+
prompt = nl2sqlite_template_cn.format(dialect="", db_schema="", question="", evidence="")
|
98 |
+
message = [{'role': 'user', 'content': prompt}]
|
99 |
+
|
100 |
+
text = tokenizer.apply_chat_template(
|
101 |
+
message,
|
102 |
+
tokenize=False,
|
103 |
+
add_generation_prompt=True
|
104 |
+
)
|
105 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
106 |
+
|
107 |
+
generated_ids = model.generate(
|
108 |
+
**model_inputs,
|
109 |
+
pad_token_id=tokenizer.pad_token_id,
|
110 |
+
eos_token_id=tokenizer.eos_token_id,
|
111 |
+
max_new_tokens=1024,
|
112 |
+
temperature=0.1,
|
113 |
+
top_p=0.8,
|
114 |
+
do_sample=True,
|
115 |
+
)
|
116 |
+
generated_ids = [
|
117 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
118 |
+
]
|
119 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
120 |
+
```
|
121 |
+
|
122 |
+
### Inference with vLLM
|
123 |
+
```python
|
124 |
+
from vllm import LLM, SamplingParams
|
125 |
+
from transformers import AutoTokenizer
|
126 |
+
model_path = "XGenerationLab/XiYanSQL-QwenCoder-32B-2502"
|
127 |
+
llm = LLM(model=model_path, tensor_parallel_size=8)
|
128 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
129 |
+
sampling_params = SamplingParams(
|
130 |
+
n=1,
|
131 |
+
temperature=0.1,
|
132 |
+
max_tokens=2048
|
133 |
+
)
|
134 |
+
|
135 |
+
## dialects -> ['SQLite', 'PostgreSQL', 'MySQL']
|
136 |
+
prompt = nl2sqlite_template_cn.format(dialect="", db_schema="", question="", evidence="")
|
137 |
+
message = [{'role': 'user', 'content': prompt}]
|
138 |
+
text = tokenizer.apply_chat_template(
|
139 |
+
message,
|
140 |
+
tokenize=False,
|
141 |
+
add_generation_prompt=True
|
142 |
+
)
|
143 |
+
outputs = llm.generate([text], sampling_params=sampling_params)
|
144 |
+
response = outputs[0].outputs[0].text
|
145 |
+
```
|
146 |
+
|
147 |
+
|
148 |
+
## Acknowledgments
|
149 |
+
If you find our work useful, please give us a citation or a like, so we can make a greater contribution to the open-source community!
|