Qwen Data Science Instruct – QLoRA Fine-Tuned LLM
Fine-tuned version of Qwen2.5-3B-Instruct optimized for Data Science and ML coding tasks using QLoRA on 16.4K instruct examples with Unsloth. Achieved an 86% win rate over the base model with +109.5% BLEU and +66.9% ROUGE-L score gains.
General-purpose small LLMs frequently produce non-idiomatic, unoptimized, or hallucinated Data Science and Machine Learning code. They struggle with complex Pandas vectorized manipulation, statistical edge cases, and strict data leakage prevention in scikit-learn pipelines.
Fine-tuned Qwen2.5-3B-Instruct using QLoRA (4-bit quantization, rank 16, alpha 16) with Unsloth on the ed001/ds-coder-instruct-v1 dataset (~16.4k examples). Enforced generation-only loss backpropagation by masking loss on user prompt tokens. Optimized with AdamW 8-bit, 2e-4 learning rate, and cosine scheduler, completing 3 epochs on a single Tesla T4 GPU in 7.38 hours using just 6.51 GB peak VRAM.
- →86% win rate against base Qwen2.5-3B-Instruct on 100 held-out data science coding test cases
- →+109.49% BLEU score improvement (0.0855 -> 0.1791) measuring exact code syntax and token match
- →+66.89% ROUGE-L score improvement (0.2535 -> 0.4231) validating structural code alignment
- →+12.59% semantic similarity gain (0.7001 -> 0.7883) evaluated against canonical solutions
- →+25.65% overall composite score gain across combined code quality metrics
- →Trained on a single Tesla T4 GPU in 7.38 hours with ultra-lean 6.51 GB peak VRAM footprint
- 01Unsloth kernel optimizations deliver ~2x training speedup and 60% memory reduction over standard HuggingFace PEFT
- 02Prompt loss masking is vital for instruct fine-tuning; backpropagating on prompt tokens introduces severe gradient noise
- 03Targeting all linear projection layers (q, k, v, o, gate, up, down) with LoRA rank 16 yielded superior generalization compared to q/v-only adapters
- 04Automated NLP metrics (BLEU, ROUGE-L) provide strong stylistic alignment proxies, but sandbox execution validation is key for future iterations