Fine-tuning
How it works
1) Choose a pretrained base model. 2) Prepare a smaller task- or domain-specific dataset (e.g. instruction-response pairs for instruction tuning). 3) Continue training with gradient descent, usually at a low learning rate (e.g. around 2e-5) to avoid destroying knowledge from pretraining. 4) In full fine-tuning all weights are updated; in PEFT/LoRA the base weights are frozen and only injected low-rank adaptation matrices are trained. 5) The resulting model (or a lightweight adapter) is saved and deployed. A low learning rate, few epochs and regularization mitigate catastrophic forgetting and overfitting.
Problem solved
Training large models from scratch is expensive, requires huge datasets and compute, and a general-purpose model is rarely optimal for a narrow task or domain. Fine-tuning lets you reuse the knowledge captured in a base model and adapt it to a specific goal at low cost.
Components
The pretrained model whose weights are further tuned (or frozen in PEFT).
Official
A smaller, specialized dataset (e.g. input-output pairs) defining the target behavior.
Official
Typically cross-entropy loss and an Adam/AdamW-type optimizer with a low learning rate.
Official
Small, low-rank matrices injected into model layers (LoRA) instead of updating all weights.
Official
Implementation
Overly aggressive fine-tuning overwrites general knowledge acquired during pretraining.
A small fine-tuning dataset encourages memorizing examples instead of generalizing.
A high learning rate destabilizes learned weights and destroys base knowledge.
Evolution
Fine-tuning ImageNet-pretrained CNNs becomes standard transfer-learning practice in computer vision.
Howard and Ruder introduce universal language model fine-tuning for NLP, showing effective inductive transfer for any text task.
BERT popularizes the scheme where a pretrained model is fine-tuned with one extra layer for many NLP tasks, reaching SOTA results.
LoRA freezes base weights and trains low-rank matrices, cutting trainable parameters by up to ~10,000x and GPU memory by 3x vs full fine-tuning of GPT-3 175B.
OpenAI fine-tunes GPT-3 on demonstrations and feedback (SFT + RLHF) so the model follows user instructions - the basis of modern assistants.
Hyperparameters (configurable axes)
Too high destroys pretrained knowledge; typically around 1e-5-5e-5 for full fine-tuning.
Full fine-tuning (all weights) vs PEFT/LoRA (a fraction of parameters). Determines memory cost and forgetting risk.
Too many epochs lead to overfitting on a small fine-tuning dataset.
Size of the low-rank adaptation matrices; a trade-off between capacity and parameter count.
Compute bottleneck
Full fine-tuning must store gradients and optimizer states for all parameters, which is the main reason parameter-efficient methods (PEFT/LoRA) emerged.
Execution paradigm
Standard fine-tuning updates dense weights via backpropagation; in PEFT/LoRA only a small dense set (adapters) is updated while the rest stays frozen.
Parallelism
Computation within a batch is fully parallel and scales via data parallelism across devices, but successive optimizer steps are sequential.
Hardware requirements
Gradient-based fine-tuning benefits from tensor cores and mixed-precision training (bf16/fp16) on Ampere+ GPUs.