Full Fine-Tuning
Adjusting all model parameters – maximum control
In full fine-tuning, all parameters of the base model are trained and adjusted. Maximum expressiveness, but maximum memory requirements.
Pros and cons
✓ Advantages
- Maximum adaptability
- Best possible performance
- No extra overhead from adapters
- Good for fundamental domain shifts
✗ Disadvantages
- Huge VRAM requirement (~28GB for 7B)
- Catastrophic forgetting possible
- Needs much more data
- Every checkpoint = full model size
Catastrophic forgetting – the main risk
During full fine-tuning, the model can "forget" its general prior knowledge if trained too aggressively on new data. This happens when new knowledge overwrites the old weights.
Countermeasures against catastrophic forgetting:
1. Low learning rate (1e-5 or lower)
→ Small updates preserve existing knowledge
2. Few epochs (1–3)
→ Don't grind the model too long into new data
3. Elastic Weight Consolidation (EWC)
→ Penalizes large changes to important parameters
→ More complex, but effective
4. Replay (mixed training)
→ Mix of old (general) and new (specific) data
→ e.g. 80% new task + 20% general textFull fine-tuning vs. LoRA: when to use which?
Full fine-tuning checklist
LoRA In Depth
Low-Rank Adaptation – the key to efficient fine-tuning
LoRA (Low-Rank Adaptation), introduced in 2022 by Hu et al. (Microsoft), is the most important technique for efficient LLM fine-tuning. It reduces trainable parameters by 99%+ with minimal performance loss.
The mathematical core idea
Instead of changing the entire weight matrix W (d×d), LoRA freezes W and adds two small matrices A (d×r) and B (r×d) whose product represents the change:
Standard fine-tuning: W_new = W + ΔW (ΔW is the same size as W!) 7B model: ΔW ≈ 7 billion parameters to train LoRA: W_new = W + B·A (W stays frozen) A: d×r (down-projection) B: r×d (up-projection) Example (d=4096, r=16): Original matrix: 4096 × 4096 = 16.7M parameters LoRA matrices: 4096×16 + 16×4096 = 131K parameters Reduction: 99.2% fewer trainable parameters! During fine-tuning: only A and B are trained B is initialized to 0 → at the start: BA = 0 → no effect
LoRA architecture: frozen base model + trainable adapters
LoRA hyperparameters explained
rank (r)
4, 8, 16, 32, 64Determines the "capacity" of the LoRA adapters. Higher rank = more trainable parameters = more expressiveness, but more memory and overfitting risk.
💡 r=8 for simple tasks/little data. r=16 as a standard. r=32–64 for complex tasks with lots of data.
Memory: r=8: ~2× fewer parameters than r=16
alpha (α)
Typical: equal to r or 2×r (e.g. 16 or 32)Scaling factor for the LoRA update: actual update = (α/r) × B·A·x. Alpha/r determines the "learning strength" of the adapters.
💡 α = r (update strength = 1) or α = 2r (stronger updates). Start with α=16 (for r=16).
Memory: No memory effect (just a scaling constant)
dropout
0.0 to 0.1Dropout within the LoRA adapter matrices. Prevents adapter overfitting, especially on small datasets.
💡 0.05 as standard. Below 500 examples: 0.1. Above 5,000 examples: 0.0
Memory: No memory effect
target_modules
q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_projWhich layers of the transformer are extended with LoRA. More modules = more trainable parameters = better performance, but more memory.
💡 Minimum: q_proj + v_proj. Standard: all attention layers. Maximum: all linear layers including FFN.
Memory: Each target_module adds ~2×r parameters per layer
bias
"none" (default), "all", "lora_only"Whether bias parameters are also trained. "none" = only LoRA matrices. "all" = biases too.
💡 "none" is the default and is almost always enough.
Memory: "all" adds minimal extra parameters
LoRA for different model types
QLoRA (4-bit Fine-Tuning)
Even more efficient: quantization + LoRA combined
QLoRA (Dettmers et al., 2023) combines 4-bit quantization of the base model with LoRA adapters at full precision. Result: fine-tune a 7B model in ~4 GB VRAM!
How QLoRA works
QLoRA = quantized base model + LoRA Step 1: Load the base model in 4-bit (NF4 quantization) → 7B model: 28 GB (fp32) → ~4 GB (NF4) Step 2: Add LoRA adapters in bf16/fp16 → Adapters stay at full precision for quality Step 3: During training: → Forward pass: 4-bit weights "dequantized" to bf16 on the fly → Gradients only for LoRA adapters (bf16) → Base model stays frozen and 4-bit Total memory for 7B: Base model (NF4): ~4 GB LoRA adapters (bf16): ~0.3 GB Activations: ~1 GB Optimizer states: ~0.6 GB Total: ~6 GB → an RTX 3070 is enough!
NF4 quantization – the innovation behind QLoRA
Standard int4 quantization quantizes weights uniformly. NF4 (4-bit NormalFloat) takes into account that transformer weights are normally distributed – it assigns bit values to boundaries that optimally partition the normal distribution:
Int4 (uniform steps):
Bit values: -8, -7, -6, ..., 7, 8 (16 levels)
Problem: most weights lie near 0,
extreme values are rare → poor resolution
NF4 (normally distributed steps):
Bit values: -1, -0.69, -0.52, ..., 0.52, 0.69, 1
(quantiles of the normal distribution)
Advantage: better resolution where most weights lie
Result: noticeably better quality than int4QLoRA vs. LoRA vs. Full FT compared
| Method | VRAM (7B) | Quality (rel.) | Speed | Recommendation |
|---|---|---|---|---|
| Full FT (fp32) | ~60 GB | 100% | ⭐⭐⭐ | A100/H100 cluster |
| Full FT (bf16) | ~40 GB | 99% | ⭐⭐⭐ | A100 40GB |
| Full FT (8-bit) | ~30 GB | 97% | ⭐⭐ | A100/2× RTX 3090 |
| LoRA (bf16) | ~16 GB | 97% | ⭐⭐⭐⭐ | RTX 3090 / A6000 |
| QLoRA (4-bit) ⭐ | ~6 GB | 93–96% | ⭐⭐⭐ | RTX 3070/4060 Ti |
| QLoRA (4-bit, GC) | ~4–5 GB | 92–95% | ⭐⭐ | GTX 1660 Ti or better |
GC = gradient checkpointing enabled. Quality relative to full FT fp32.
QLoRA: democratizing LLM training
PEFT Methods Overview
Parameter-efficient fine-tuning compared
PEFT (Parameter-Efficient Fine-Tuning) is the umbrella term for methods that train only a fraction of the model parameters. LoRA is the most popular, but there are others.
All PEFT methods compared
LoRA ⭐ (Low-Rank Adaptation)
Trains low-rank matrices alongside frozen attention weights. Standard for almost all LLM fine-tuning jobs since 2023.
💡 When: Standard recommendation for most cases
QLoRA (Quantized LoRA)
4-bit quantized base model + LoRA adapters in bf16. Minimal VRAM for maximum model size.
💡 When: When VRAM is very limited (< 12 GB for 7B)
Prefix Tuning
Inserts trainable "prefix" tokens at the start of every transformer layer. No modification of model weights themselves.
💡 When: When model weights must not be changed
Prompt Tuning
Only "soft prompts" (trainable input embeddings) are learned. Very efficient, but weaker performance on smaller models.
💡 When: Only for very large models (> 10B) or when speed is the top priority
Adapter Layers
Small feed-forward networks inserted between transformer layers. Older method (pre-LoRA), still solid.
💡 When: Historically important, mostly surpassed by LoRA today
IA³ (Infused Adapter by Inhibiting and Amplifying)
Trains only scaling vectors for keys, values, and feed-forward. Extremely few parameters with good quality.
💡 When: Very little data, extremely fast iteration desired
Which Fine-Tuning Method When?
The complete decision tree
The choice of fine-tuning method depends on VRAM, amount of data, quality requirements, and training speed. This decision tree leads you to the optimal choice.
Step-by-step decision tree
How much GPU VRAM do you have?
How many training examples do you have?
What should the model learn?
Quick-reference table
| Scenario | Method | Rank | LR | Epochs |
|---|---|---|---|---|
| 7B LoRA, RTX 3070 | QLoRA | 16 | 2e-4 | 3–5 |
| 7B LoRA, RTX 3090 | LoRA (bf16) | 16 | 2e-4 | 3–5 |
| 1B full FT, RTX 3080 | Full FT (bf16) | — | 5e-5 | 2–3 |
| BERT classification | Full FT or LoRA | 8 | 2e-5 | 3 |
| Little data (< 300) | QLoRA rank=4 | 4 | 1e-4 | 5–10 |
| Lots of data (> 10K) | LoRA rank=32 | 32 | 2e-4 | 1–3 |
FrameTrain recommendation for 90% of cases