Downloads · 30 days
54
32% of all-time downloads
ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql
Qwen3.5-0.8B-OptiQ-4bit-text-to-sql is a text generation model from ulldma. Use it when you need the model to write or continue text. It is set up for mlx. The card lists the license as apache-2.0.
A Qwen3.5-0.8B model (the smallest member of the Qwen3.5 family, in 4-bit MLX format) fine-tuned with LoRA to translate natural-language questions into SQL queries. Runs entirely on Apple Silicon Macs using MLX, e.g.…
Downloads · 30 days
54
32% of all-time downloads
All-time downloads
169
Public
Parameters
752M
670 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors650 MB · 97%
How the weights are stored.
U32752M · 100%
From the Hugging Face model README
A Qwen3.5-0.8B model (the smallest member of the Qwen3.5 family, in 4-bit MLX format) fine-tuned with LoRA to translate natural-language questions into SQL queries. Runs entirely on Apple Silicon Macs using MLX, e.g. starting from 4 GB shared VRAM.
You: "What is the total population of cities in Switzerland (CH)?"
→ SELECT SUM(population) FROM cities WHERE country = 'CH'
The base 0.8B model produces 0% valid SQL out of the box (it answers in prose or hallucinates numbers). Prompt engineering ("Only answer in SQL") lifts this to just 1.5%. After 600 LoRA iterations, the model emits valid SQL in 86.5% of test cases and reaches 47% semantic accuracy (exact-match of query semantics on held-out data).
Not intended for: production analytics on large multi-table databases, complex multi-join/window-function SQL, or non-English input.
Requires mlx-lm:
pip install mlx-lm
from mlx_lm import load, generate
model, tokenizer = load("ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql")
schema = (
"CREATE TABLE employees (Name VARCHAR, Department VARCHAR, "
"Salary INT, Start_Date DATE);"
)
prompt = f"{schema}\nQ: Who earns more than 100k in Engineering?\nA: "
response = generate(model, tokenizer, prompt=prompt, max_tokens=100)
print(response)
# SELECT Name FROM employees WHERE Department = 'Engineering' AND Salary > 100000;
Or from the command line:
python -m mlx_lm generate \
--model ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql \
--max-tokens 100 \
--prompt "CREATE TABLE cities (name VARCHAR, country_code VARCHAR, population INT);
Q: What is the total population of cities in Switzerland (CH)?
A: "
The model expects the exact format used during training:
CREATE TABLE ... ; [INSERT INTO ... VALUES (...);]
Q: <natural language question>
A:
It completes the A: line with a single SQL statement.
| Parameter | Value |
|---|---|
| Method | LoRA |
| Base model | Qwen3.5-0.8B (4-bit, MLX/OptiQ) |
| Rank / scale / dropout | 8 / 20.0 / 0.0 |
| Target layers | 16 |
| Optimizer | AdamW-family (Adam), LR schedule: constant |
| Learning rate | 1e-5 |
| Iterations | 600 (batch size 2, grad checkpointing) |
| Max sequence length | 512 |
Trained on an Apple Silicon Mac with mlx-lm; see the training repo for the full pipeline (uv sync → train → eval).
Fine-tuned on a filtered subset of gretelai/synthetic_text_to_sql: 5,000 train / 500 validation / 1,000 test examples covering basic SELECT queries and single joins across ~100 domains (healthcare, finance, education, …).