LoRA (Low-Rank Adaptation)
Efficient fine-tuning that trains only a small number of parameters
LoRA (Low-Rank Adaptation) is a PEFT (Parameter-Efficient Fine-Tuning) technique proposed by Microsoft in 2021. Full Fine-tuning updates all model weights (tens to hundreds of billions), requiring massive GPU memory. LoRA's key insight is that "the weight change (ΞW) during fine-tuning is low-rank." It freezes the original weight matrix W(dΓd) and decomposes ΞW = A(dΓr) Γ B(rΓd) (r << d, typically r=4-64). Trainable parameters drop to 0.1-1% of the original, and at inference, W + ΞW can be pre-merged with zero additional latency. QLoRA combines this with quantization, enabling fine-tuning on 4-bit models.
Key Concepts
Freeze the original model's weight matrix W
Add low-rank matrices A(dΓr) and B(rΓd) alongside W (r is rank, typically 4-64)
Forward pass: y = Wx + (Ξ±/r) Γ ABx β add LoRA output to original output
Backpropagation: only update weights of A and B (W remains frozen)
Trainable parameters: 2ΓdΓr (dramatic reduction from original dΓd)
Inference: merge as W_new = W + (Ξ±/r)ΓAB β zero additional compute cost
Pros
- ✓ Massive GPU memory savings (1/3 to 1/10 of Full FT)
- ✓ Improved training speed
- ✓ Multi-purpose usage by swapping task-specific adapters
- ✓ No additional inference cost (can be merged)
- ✓ Original model preserved
Cons
- ✗ Performance may be slightly lower than Full Fine-tuning
- ✗ Rank (r) selection affects performance
- ✗ Need to decide whether to apply to all layers or only some
- ✗ Limitations for complex domain shifts