Instructions to use holygrimm/qwen2.5-coder-3b-text2sql with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Local Apps Settings
- Unsloth Desktop
|
Download README.md from holygrimm/qwen2.5-coder-3b-text2sql: direct link, hf CLI and curl.
- Browser
- Download file 2.51 kB
-
https://huggingface.co/holygrimm/qwen2.5-coder-3b-text2sql/resolve/main/README.md
- Command line
-
hf download hf://holygrimm/qwen2.5-coder-3b-text2sql/README.md
-
curl -L -o README.md https://huggingface.co/holygrimm/qwen2.5-coder-3b-text2sql/resolve/main/README.md
2.51 kB
metadata
base_model: Qwen/Qwen2.5-Coder-3B-Instruct
tags:
- text-to-sql
- sqlite
- qwen2.5-coder
- unsloth
- qlora
datasets:
- b-mc2/sql-create-context
language:
- en
license: apache-2.0
Qwen2.5-Coder-3B-Text2SQL
A fine-tuned version of Qwen/Qwen2.5-Coder-3B-Instruct specialized for converting natural language questions and CREATE TABLE database schemas into executable SQLite queries.
- LoRA Adapters: holygrimm/qwen2.5-coder-3b-text2sql-lora
- Merged 16-bit Weights: holygrimm/qwen2.5-coder-3b-text2sql
Benchmark (500 Held-Out Queries)
Evaluated on 500 unseen examples from b-mc2/sql-create-context (seed=42, indices 30000:30500) by executing generated queries against an in-memory SQLite database and comparing returned rows against ground truth:
| Model | Execution Accuracy | Syntax Error Rate |
|---|---|---|
| Qwen2.5-Coder-3B-Instruct (Base) | 83.8% | 5.6% |
| Qwen2.5-Coder-3B-Text2SQL (Fine-Tuned) | 94.6% | 2.4% |
Training Details
- Dataset: 30,000 training examples from
b-mc2/sql-create-context - Method: QLoRA (
r=16,lora_alpha=16, all linear projections) with response-only loss masking via Unsloth - Hyperparameters: 1 epoch, effective batch size 16, cosine LR schedule (
2e-4),adamw_8bit - Final Training Loss:
0.0361
Quickstart Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "holygrimm/qwen2.5-coder-3b-text2sql"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", torch_dtype="auto")
schema = "CREATE TABLE employees (id INT, name TEXT, department TEXT, salary INT);"
question = "What is the average salary in the Engineering department?"
messages = [
{"role": "system", "content": "You are a SQL expert. Convert the question into a valid SQLite query using the provided schema. Output ONLY the raw SQL query without markdown formatting or explanation."},
{"role": "user", "content": f"### Schema:\n{schema}\n\n### Question:\n{question}"}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer([prompt], return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=128)
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))