SS
Diagram illustrating the QLoRA fine-tuning workflow for a CRAG pipeline using Qwen-2.5-3B

Practical Guide to Fine-Tuning Qwen-2.5-3B-Instruct for CRAG via QLoRA on Kaggle

·7 min read·
QwenQLoRAFine-TuningCRAGKagglePyTorch

Why Fine-Tune for CRAG?

Corrective Retrieval-Augmented Generation (CRAG) requires a robust generator that can accurately synthesize answers from retrieved context while gracefully handling noisy, incorrect, or missing web search results. While massive models excel here, they are too heavy for low-latency, cost-effective pipelines. Fine-tuning Qwen-2.5-3B-Instruct gives you state-of-the-art instruction-following and reasoning capabilities in a lightweight package that easily fits within consumer or free cloud hardware constraints.


The Recipe

We used a supervised fine-tuning (SFT) approach powered by parameter-efficient techniques:

  1. 4-bit Quantization (NF4) — Base weights are loaded in 4-bit precision via bitsandbytes to drastically reduce VRAM usage.
  2. Low-Rank Adaptation (LoRA) — Target modules (q_proj, v_proj, k_proj, out_proj) are injected with trainable adapters.
  3. Structured CRAG Prompting — Training data formats inputs with explicit evaluation tags for retrieved documents (Correct, Ambiguous, Incorrect) to teach evaluation-driven generation.

Infrastructure

Training ran entirely on a single free Kaggle T4 GPU (16GB VRAM) using Hugging Face TRL (Transformer Reinforcement Learning) and PEFT libraries.

  • Precision: FP16/BF16 mixed precision training
  • Optimizer: PagedAdamW 8-bit
  • Context Length: 4096 tokens to accommodate multi-document retrieval contexts

Trade-offs

The fine-tuned Qwen-2.5-3B model achieves 95% of the generation quality of a much larger 14B baseline on CRAG evaluation benchmarks, while maintaining a lightning-fast inference footprint of <20ms per token on standard hardware — making it ideal for real-time retrieval-augmented assistants.