CoolFace
Modelpublic

XGenerationLab/XiYanSQL-QwenCoder-3B-2502

sourceHugging Faceapache-2.0updated 10mo agoView on Hugging Face
5likes194downloads
Model Card

Important Links

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

Introduction

We are excited to open source the XiYanSQL-QwenCoder series model, dedicated to advancing the development of LLMs in the text-to-SQL domain. As of now, XiYanSQL-QwenCoder covers four mainstream model sizes: 3B, 7B, 14B, and 32B parameters, to meet the needs of different developers.

  • —The XiYanSQL-QwenCoder model demonstrates strong performance in SQL generation, with the XiYanSQL-QwenCoder-32B achieving a 69.03% EX score on the BIRD TEST set, setting a new SOTA with a single fine-tuned model. Other models in the series also maintain a leading position at their respective sizes.
  • —The XiYanSQL-QwenCoder model supports multiple SQL dialects, such as SQLite, PostgreSQL, and MySQL.
  • —The XiYanSQL-QwenCoder model can be used directly for text-to-SQL tasks or serve as a better starting point for fine-tuning SQL models.

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 benchmarks in the Text-to-SQL domain.

Model nameBIRD Dev@M-SchemaBIRD Dev@DDLSpider Test@M-SchemaSpider Test@DDL
Codellama-34b33.05%-67.74%-
Deepseek-coder-33b47.52%44.72%72.39%-
TableGPT246.35%47.07%74.76%77.28%
Codestral 22b50.52%47.00%78.45%75.47%
GLM-4-plus54.37%-79.40%-
Claude35_sonnet-102253.32%50.46%76.27%73.04%
Deepseek(v2.5-1210)55.74%55.61%82.08%80.57%
Gemini-1.5-pro61.34%57.89%85.11%84.00%
GPT-4o-080658.47%54.82%82.89%78.45%
XiYanSQL-QwenCoder-3B54.11%53.19%82.69%78.85%
XiYanSQL-QwenCoder-7B59.78%56.58%84.86%80.31%
XiYanSQL-QwenCoder-14B63.10%60.37%85.76%82.79%
XiYanSQL-QwenCoder-32B67.01%63.04%88.39%85.46%

Requirements

transformers >= 4.37.0

Quickstart

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.

python

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

【数据库schema】
{db_schema}

【参考信息】
{evidence}

【用户问题】
{question}

import torch from transformers import AutoModelForCausalLM, AutoTokenizer

modelname = "XGenerationLab/XiYanSQL-QwenCoder-3B-2502" 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-3B-2502" 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}, }