Instructions to use ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Qwen3.5-0.8B Text-to-SQL (MLX LoRA)
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'
Model description
- Base model: mlx-community/Qwen3.5-0.8B-OptiQ-4bit — the compact 0.8B-parameter version, 4-bit quantized (~0.5 GB)
- Fine-tuning: LoRA (no full-weight updates), adapters fused into the base model
- Task: schema-conditioned text-to-SQL generation
- Memory footprint: runs comfortably in ~4 GB of unified memory
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).
Intended use cases
- Natural-language querying of small, known schemas (prototypes, local tools, demos)
- On-device / privacy-preserving assistants that turn questions into SQL without sending data anywhere
- Education: studying how LoRA teaches a tiny model a structured output skill
- Embedding a lightweight NL→SQL layer into Mac/iOS apps via MLX
Not intended for: production analytics on large multi-table databases, complex multi-join/window-function SQL, or non-English input.
Usage
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: "
Prompt format
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.
Training details
| 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).
Data
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, …).
Limitations
- Small model: expect mistakes on complex schemas, aggregations over many tables, or ambiguous questions
- Trained only on basic SQL + single-join complexity — multi-join, nested, and DDL-heavy queries are out of distribution
- Synthetic training data; real-world schema vocabulary may differ
- Semantic accuracy is 47% — always review generated SQL before executing it against real data
- Downloads last month
- 40
4-bit
Model tree for ulldma/Qwen3.5-0.8B-OptiQ-4bit-text-to-sql
Base model
Qwen/Qwen3.5-0.8B-Base