Finetuning

When to change the weights, what it costs in memory, and the cheap way to do it.

Reference · Chapter 7

Decide

Memory math

FormatBytes / value7B weights
FP32428 GB
FP16 / BF16214 GB
INT817 GB
INT4 / NF4½3.5 GB

Techniques

TechniqueTrainableNote
Full finetuningAllBest quality; most memory and data
Partial finetuningSome layersParameter-inefficient (~25% needed to match full)
Adapters (Houlsby)~3%Within 0.4% of full; adds inference latency
LoRA≪ 1%W frozen; train A (n×r) and B (r×m); merge → no latency; r = 4–64 usually enough
QLoRA≪ 1%4-bit NF4 base + LoRA; 65B on one 48 GB GPU; slower training
Soft promptsPrompt vectorsTrainable tokens, not human-readable; less common

Tactics

← Lesson 8AgentsGlossary

Related ideas