GitHub Repo of the Pipeline
By using Qwen 3.5 9B as a teacher, a Qwen 3.5 0.8B student was fine-tuned for Text-to-SQL operations, recovering 95% of the teacher's accuracy while resolving multi-table JOIN hallucinations and running 2.3x faster. Distillation Dashboard

Overview

Initial baseline testing of the Qwen 3.5 0.8B model on Text-to-SQL generation revealed a significant bottleneck: 72% of its failures were no_such_column errors when attempting multi-table JOIN operations.
The Goal:
Build an automated knowledge distillation pipeline to transfer complex, multi-table schema reasoning from a 9B parameter teacher model into a 0.8B parameter student model, achieving high execution validity while maintaining low VRAM usage and latency.

Pipeline

  • Teacher Model: qwen3.5:9b (Ollama)
  • Student Model: qwen3.5:0.8b (Unsloth)
  • Base Dataset: b-mc2/sql-create-context
  • Training Framework: PyTorch & Unsloth (16-bit LoRA)

1. Procedural Data Distillation (src/1_generate_dataset.py) The base dataset was filtered to strictly contain complex schemas requiring at least one JOIN operation (2,001 total rows). The Teacher model generated SQL for 1,698 training rows. Importantly, an automated SQLite verification step was implemented to execute the Teacher's outputs against the schema, rejecting 268 invalid queries and ending up with 1,430 verified training examples.

2. Fine-Tuning (src/3_train_lora.ipynb) The verified JSONL dataset was used to fine-tune the 0.8B Student using Unsloth (LoRA, r=16, alpha=32). The model was trained for 3 epochs (270 steps) with a cosine learning rate scheduler and an adamw_8bit optimizer, then merged and exported to a 16-bit GGUF format for local serving.

Benchmark Results

Evaluated against an unseen test pool of 303 multi-table queries. Accuracy is defined by successful and valid execution against an SQLite database matching the provided DDL schema.

Model Parameters Valid SQL Execution Avg Latency Column Hallucinations
Qwen 3.5 (Student) 0.8B 50.50% (153/303) ~209 ms 108
Qwen 3.5 (Teacher) 9B 84.49% (256/303) ~601 ms 20
Qwen 3.5-SQL (Distilled) 0.8B 82.84% (251/303) ~257 ms 24

Key Takeaways:

  1. Hallucination Resolution: Schema-grounded distillation successfully reduced no_such_column errors by 78%.
  2. Pareto Efficiency: The distilled student matches the 9B teacher's execution rate (within 5 queries) while running 2.34x faster.

license: apache-2.0

Downloads last month
31
GGUF
Model size
0.8B params
Architecture
qwen35
Hardware compatibility
Log In to add your hardware

16-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for thxlxn/qwen3.5-0.8b-sql

Adapter
(690)
this model

Dataset used to train thxlxn/qwen3.5-0.8b-sql