CoolFace
Modelpublic

XGenerationLab/XiYanSQL-QwenCoder-7B-2504

sourceHugging Faceapache-2.0updated 10mo agoView on Hugging Face
11likes766downloads
Model Card

Important Links

📖Github | 🤖ModelScope | 🌐XiYan-SQL | 🌕析言GBI | 📄Paper

Introduction

We are excited to release the XiYanSQL-QwenCoder-2504 version, our latest SQL generation model. This version continues to optimize upon the previous version, delivering enhanced performance.

  • —Our model incorporates important explorations combining fine-tuning and GRPO training, leveraging the post-training strategies of GRPO without a thinking process, achieving both efficiency and accuracy in SQL generation.
  • —It demonstrates impressive performance and supports multiple dialects, ready to use out of the box.
  • —Improved generalization capabilities, excelling on different dialects and out-of-domain datasets.

In this evaluation, we have also added a real-world SQL benchmark (the DW test set), which serves as an important internal evaluation baseline. This test set includes thousands of complex queries from real scenarios in both PostgreSQL and MySQL dialects, effectively reflecting the model's performance across multiple dialects and out-of-domain data.

Model Downloads

**Model****Download Latest**
XiYanSQL-QwenCoder-3B🤗HuggingFace 🤖Modelscope
XiYanSQL-QwenCoder-7B🤗HuggingFace 🤖Modelscope
XiYanSQL-QwenCoder-14B🤗HuggingFace 🤖Modelscope
XiYanSQL-QwenCoder-32B🤗HuggingFace 🤖Modelscope

Performance

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.

Model nameSizeBIRD Dev@M-SchemaBIRD Dev@DDLSpider Test@M-SchemaSpider Test@DDLDW PostgreSQL@M-SchemaDW MySQL@M-Schema
GPT-4o-0806UNK58.47%54.82%82.89%78.45%46.79%57.77%
GPT-4.1-0414UNK59.39%54.11%84.45%79.86%54.29%63.18%
Claude3.5-sonnet-1022UNK53.32%50.46%76.27%73.04%55.22%52.84%
Claude3.7-sonnetUNK54.82%49.22%78.04%74.66%53.23%54.61%
Gemini-1.5-ProUNK61.34%57.89%85.11%84.00%52.78%62.78%
DeepSeek-V2.5-1210236B55.74%55.61%82.08%80.57%45.74%52.18%
DeepSeek-V3685B59.58%56.71%81.52%79.91%52.56%55.95%
DeepSeek-R1685B58.15%55.61%80.72%78.85%60.56%62.00%
DeepSeek-R1-Distill-Qwen-32B32B50.65%48.31%78.65%77.33%37.22%44.72%
Deepseek-Coder-33B-Instruct33B47.52%44.72%72.39%62.0%31.48%36.17%
OmniSQL-32B32B60.37%55.87%85.16%83.19%38.19%42.34%
XiYanSQL-QwenCoder-3B-25023B53.52%52.54%83.34%79.10%34.75%35.62%
XiYanSQL-QwenCoder-3B-25043B55.08%52.09%84.10%80.57%36.65%37.63%
XiYanSQL-QwenCoder-7B-25027B59.65%56.32%84.15%80.01%39.38%42.10%
XiYanSQL-QwenCoder-7B-25047B62.13%57.43%85.97%82.48%42.08%44.67%
XiYanSQL-QwenCoder-14B-250214B63.23%60.10%85.31%82.84%38.51%41.62%
XiYanSQL-QwenCoder-14B-250414B65.32%60.17%86.82%83.75%40.52%44.60%
XiYanSQL-QwenCoder-32B-241232B67.07%63.04%88.39%85.46%45.07%52.84%
XiYanSQL-QwenCoder-32B-250432B67.14%62.26%89.20%86.17%53.52%57.74%

Quickstart with Transformers and vLLM

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 format for the schema; other formats such as DDL are also acceptable, but they may affect performance. Currently, we mainly support mainstream dialects like SQLite, PostgreSQL, and MySQL.

Requirements

  • —transformers >= 4.37.0
  • —vllm >= 0.7.2

Prompt Template

python
nl2sqlite_template_cn = """你是一名{dialect}专家,现在需要阅读并理解下面的【数据库schema】描述,以及可能用到的【参考信息】,并运用{dialect}知识生成sql语句回答【用户问题】。
【用户问题】
{question}

【数据库schema】
{db_schema}

【参考信息】
{evidence}

【用户问题】
{question}


### Inference with Transformers

import torch from transformers import AutoModelForCausalLM, AutoTokenizer

modelname = "XGenerationLab/XiYanSQL-QwenCoder-7B-2504" model = AutoModelForCausalLM.frompretrained( modelname, torchdtype=torch.bfloat16, device_map="auto" )

tokenizer = AutoTokenizer.frompretrained(modelname)

dialects -> ['SQLite', 'PostgreSQL', 'MySQL']

prompt = nl2sqlitetemplatecn.format(dialect="", db_schema="", question="", evidence="") message = [{'role': 'user', 'content': prompt}]

text = tokenizer.applychattemplate( message, tokenize=False, addgenerationprompt=True ) modelinputs = tokenizer([text], returntensors="pt").to(model.device)

generatedids = model.generate( **modelinputs, padtokenid=tokenizer.padtokenid, eostokenid=tokenizer.eostokenid, maxnewtokens=1024, temperature=0.1, topp=0.8, dosample=True, ) generatedids = [ outputids[len(inputids):] for inputids, outputids in zip(modelinputs.inputids, generatedids) ] response = tokenizer.batchdecode(generatedids, skipspecialtokens=True)[0]


### Inference with vLLM

from vllm import LLM, SamplingParams from transformers import AutoTokenizer modelpath = "XGenerationLab/XiYanSQL-QwenCoder-7B-2504" llm = LLM(model=modelpath, tensorparallelsize=8) tokenizer = AutoTokenizer.frompretrained(modelpath) samplingparams = SamplingParams( n=1, temperature=0.1, maxtokens=1024 )

dialects -> ['SQLite', 'PostgreSQL', 'MySQL']

prompt = nl2sqlitetemplatecn.format(dialect="", dbschema="", question="", evidence="") message = [{'role': 'user', 'content': prompt}] text = tokenizer.applychattemplate( message, tokenize=False, addgenerationprompt=True ) outputs = llm.generate([text], samplingparams=sampling_params) response = outputs[0].outputs[0].text



## Acknowledgments
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!

@article{XiYanSQL, title={XiYan-SQL: A Novel Multi-Generator Framework For Text-to-SQL}, author={Yifu Liu and Yin Zhu and Yingqi Gao and Zhiling Luo and Xiaoxia Li and Xiaorong Shi and Yuntao Hong and Jinyang Gao and Yu Li and Bolin Ding and Jingren Zhou}, year={2025}, eprint={2507.04701}, archivePrefix={arXiv}, primaryClass={cs.CL}, url={https://arxiv.org/abs/2507.04701}, }