Zenodo, 2026 · Muhammad Maroof
QuerySmith: Fine-Tuning Phi-4-mini for Text-to-SQL Generation with CPU-Efficient Partial-Residual Quantization
LLMs fine-tuned for text-to-SQL are usually evaluated and deployed assuming GPU inference, which limits use in on-premise or resource-constrained settings. This work (1) fine-tunes Phi-4-mini-instruct (3.8B parameters) with QLoRA (rank 16, alpha 32, dropout 0.05) on the QuerySmith-Spider-Bird dataset, and (2) introduces a progression of CPU quantization strategies, culminating in a partial-residual quantization scheme that keeps accuracy close to FP32 while running on CPU-only hardware.
Key contributions
- Compact text-to-SQL model fine-tuned on a Spider/BIRD-derived dataset
- Partial-residual quantization: aggressive quantization of a subset of transformer blocks plus low-rank SVD error correction; recovers 92.2% of the accuracy lost by naive INT4 (0.707 vs 0.636)
- llama.cpp / GGUF deployment adds a further 65.3% latency reduction; best throughput at 8 to 12 CPU threads on a 14-core Intel Core i5 (16 GB RAM)
- Post-optimization fine-tuning exceeds the FP32 baseline (0.743 vs 0.713) while running 6.6x faster and 4.2x smaller
| Config | Accuracy | ms/token | Size (MB) |
|---|---|---|---|
| FP32 (baseline) | 0.713 | 148.0 | 14890.5 |
| FP16 | 0.709 | 121.4 | 7445.0 |
| INT8 | 0.682 | 89.1 | 3721.8 |
| INT4 (naive) | 0.636 | 71.1 | 1859.9 |
| Partial-Residual | 0.707 | 79.3 | 3511.2 |
| Partial-Residual + llama.cpp Q4_0 | 0.707 | 27.5 | n/a |
| + post-optimization fine-tune | 0.743 | 22.3 | 3511.2 |
6.6x faster, 4.2x smaller!
Limitations: Residual rank fixed at 8; 200-example evaluation set.
@misc{maroof2026querysmith,
title={QuerySmith: Fine-Tuning Phi-4-mini for Text-to-SQL Generation with CPU-Efficient Partial-Residual Quantization},
author={Maroof, Muhammad},
year={2026},
publisher={Zenodo},
url={https://zenodo.org/records/23000490}
}