Fine-tuning

Layer 2 · Mechanics

Fine-tuning

Building a real SFT dataset with chat templates and loss masking, LoRA's mechanics, adapter hyperparameters, and forgetting/eval tradeoffs.

10 min read70 XP

Supervised fine-tuning is next-token prediction on curated data

SFT uses the exact same loss and optimizer as pretraining — cross-entropy on next-token prediction. What differs entirely is the data: instead of raw web text, examples are structured conversations, and what determines success or failure is almost entirely dataset construction, plus two mechanical details: the chat template and loss masking.

Go deeper: L3 Code