When to Fine-Tune (and When Not To)

Fine-tune when: you need consistent output format, domain-specific terminology, brand voice, or specialized reasoning. Don't fine-tune when: RAG can provide the knowledge, or prompt engineering achieves your goals. Fine-tuning is the last resort — it's expensive and requires maintenance.

LoRA and QLoRA: Efficient Fine-Tuning

LoRA (Low-Rank Adaptation) fine-tunes a tiny fraction of model parameters — reducing GPU memory from 80GB to 8GB. QLoRA adds quantization for even lower requirements. You can fine-tune a 7B model on a single consumer GPU. The resulting adapter is small (10-100MB) and can be swapped dynamically.

Data Preparation

Create prompt-completion pairs that demonstrate your desired behavior. 100-500 high-quality examples often suffice. Format consistently (system prompt + user message + assistant response). Include edge cases and error handling examples. Remove duplicates and contradictions. Data quality is the single biggest factor in fine-tuning success.

Training Process

Use platforms like Hugging Face's AutoTrain, OpenAI's fine-tuning API, or Axolotl for local training. Key hyperparameters: learning rate (start with 2e-5), epochs (2-3 usually enough), batch size, and LoRA rank. Monitor training loss — overfitting means your model memorizes instead of generalizing.

Evaluation

Compare fine-tuned model against base model on a held-out test set. Measure task-specific metrics (accuracy, format compliance, response quality). Use LLM-as-judge for subjective quality assessment. A/B test in production with a small percentage of traffic before full rollout.

Conclusion

Fine-tuning is powerful but often unnecessary. Try prompt engineering first, then RAG, then fine-tuning. When you do fine-tune, LoRA makes it accessible and affordable. Invest your time in data quality — 100 perfect examples outperform 10,000 mediocre ones every time.