Distil text2sql
Collection
A fine-tuned Qwen3-4B model for converting natural language questions into SQL queries. • 4 items • Updated • 3
How to use distil-labs/distil-qwen3-4b-text2sql-gguf-4bit with llama.cpp:
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf distil-labs/distil-qwen3-4b-text2sql-gguf-4bit # Run inference directly in the terminal: llama cli -hf distil-labs/distil-qwen3-4b-text2sql-gguf-4bit
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf distil-labs/distil-qwen3-4b-text2sql-gguf-4bit # Run inference directly in the terminal: llama cli -hf distil-labs/distil-qwen3-4b-text2sql-gguf-4bit
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf distil-labs/distil-qwen3-4b-text2sql-gguf-4bit # Run inference directly in the terminal: ./llama-cli -hf distil-labs/distil-qwen3-4b-text2sql-gguf-4bit
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf distil-labs/distil-qwen3-4b-text2sql-gguf-4bit # Run inference directly in the terminal: ./build/bin/llama-cli -hf distil-labs/distil-qwen3-4b-text2sql-gguf-4bit
docker model run hf.co/distil-labs/distil-qwen3-4b-text2sql-gguf-4bit
How to use distil-labs/distil-qwen3-4b-text2sql-gguf-4bit with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "distil-labs/distil-qwen3-4b-text2sql-gguf-4bit"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "distil-labs/distil-qwen3-4b-text2sql-gguf-4bit",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/distil-labs/distil-qwen3-4b-text2sql-gguf-4bit
How to use distil-labs/distil-qwen3-4b-text2sql-gguf-4bit with Ollama:
ollama run hf.co/distil-labs/distil-qwen3-4b-text2sql-gguf-4bit
How to use distil-labs/distil-qwen3-4b-text2sql-gguf-4bit with Unsloth Studio:
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for distil-labs/distil-qwen3-4b-text2sql-gguf-4bit to start chatting
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for distil-labs/distil-qwen3-4b-text2sql-gguf-4bit to start chatting
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for distil-labs/distil-qwen3-4b-text2sql-gguf-4bit to start chatting
How to use distil-labs/distil-qwen3-4b-text2sql-gguf-4bit with Docker Model Runner:
docker model run hf.co/distil-labs/distil-qwen3-4b-text2sql-gguf-4bit
How to use distil-labs/distil-qwen3-4b-text2sql-gguf-4bit with Lemonade:
# Download Lemonade from https://lemonade-server.ai/ lemonade pull distil-labs/distil-qwen3-4b-text2sql-gguf-4bit
lemonade run user.distil-qwen3-4b-text2sql-gguf-4bit-{{QUANT_TAG}}lemonade list
4-bit quantized GGUF version of distil-qwen3-4b-text2sql for efficient local inference. Only 2.5GB - runs on most laptops and edge devices.
| Metric | DeepSeek-V3 (Teacher) | Qwen3-4B (Base) | This Model |
|---|---|---|---|
| LLM-as-a-Judge | 80% | 62% | 80% |
| Exact Match | 48% | 16% | 60% |
| ROUGE | 87.6% | 84.2% | 89.5% |
git lfs install
git clone https://huggingface.co/distil-labs/distil-qwen3-4b-text2sql-gguf-4bit
cd distil-qwen3-4b-text2sql-gguf-4bit
# Create the Ollama model (Modelfile is included)
ollama create distil-qwen3-4b-text2sql -f Modelfile
# Run the model
ollama run distil-qwen3-4b-text2sql
>>> Schema:
... CREATE TABLE employees (id INTEGER PRIMARY KEY, name TEXT, department TEXT, salary INTEGER);
...
... Question: How many employees earn more than 50000?
SELECT COUNT(*) FROM employees WHERE salary > 50000;
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:11434/v1", api_key="EMPTY")
schema = """CREATE TABLE employees (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
department TEXT,
salary INTEGER
);"""
question = "How many employees earn more than 50000?"
response = client.chat.completions.create(
model="distil-qwen3-4b-text2sql",
messages=[
{
"role": "system",
"content": """You are given a database schema and a natural language question. Generate the SQL query that answers the question.
Rules:
- Use only tables and columns from the provided schema
- Use uppercase SQL keywords (SELECT, FROM, WHERE, etc.)
- Use SQLite-compatible syntax
- Output only the SQL query, no explanations"""
},
{
"role": "user",
"content": f"Schema:\n{schema}\n\nQuestion: {question}"
}
],
temperature=0
)
print(response.choices[0].message.content)
# Output: SELECT COUNT(*) FROM employees WHERE salary > 50000;
| Property | Value |
|---|---|
| Format | GGUF (Q4_K_M) |
| Size | ~2.5 GB |
| Base Model | distil-labs/distil-qwen3-4b-text2sql |
| Parameters | 4 billion |
| Quantization | 4-bit |
| Model | Format | Size | Use Case |
|---|---|---|---|
| distil-qwen3-4b-text2sql | Safetensors | ~8 GB | Transformers, vLLM |
| distil-qwen3-4b-text2sql-gguf | GGUF (F16) | ~15 GB | Full precision GGUF |
| This model | GGUF (Q4_K_M) | ~2.5 GB | Recommended for local use |
This model is released under the Apache 2.0 license.
We're not able to determine the quantization variants.
Base model
Qwen/Qwen3-4B-Base