Fine-tuning
Fine-tuning is the process of continuing to train an already pretrained model on a small amount of domain-specific data so that it fits a particular task.
Why Fine-tuning Is Needed
A pretrained model is like a generalist who has just graduated: broad knowledge but not specialized enough. To make it a legal advisor, a customer service agent, or a doctor, you need targeted training.
Several Levels
- Full fine-tuning: all parameters are updated. It gives the best results but demands enormous GPU memory; fully fine-tuning a 7B model needs hundreds of GB.
- Parameter-efficient fine-tuning (PEFT): only a small subset of parameters is trained while the rest are frozen. Representative methods include LoRA, Adapter, and Prefix Tuning. GPU memory demand can drop to one tenth of full fine-tuning.
- Instruction tuning: training on "instruction-answer" pairs so the model learns to act on human instructions. This is a required step in turning a base model into an assistant.
Difference from RAG
Many people confuse fine-tuning with RAG:
- Fine-tuning: changes the model itself so it "learns" a new capability or style of expression. Suitable for style transfer, task-specific formats, and understanding of specialized terminology.
- RAG: leaves the model unchanged and instead retrieves external material into the context before generation. Suitable when knowledge updates frequently or sources must be cited.
A rule of thumb: use fine-tuning for capability, use RAG for knowledge.
Common Pitfalls
Catastrophic forgetting is the biggest risk: after fine-tuning, the model may forget its original general abilities. The mitigation is to mix a certain proportion of general data into the fine-tuning data.