Pretraining, SFT & RLHF
A base model finishes pretraining knowing how to continue text. It takes two more stages to make it useful.
The model is trained on a huge corpus (web text, books, code) with one objective: predict the next token given everything before it. No labels, no human curation of individual examples — the "label" for every position in every document is just the next token that actually appears there. This is why it scales: the training signal is free, limited only by how much text exists and how much compute is spent processing it.
# the entire pretraining loss function, conceptually
loss = -sum(log P(token_i | token_1, ..., token_{i-1}) for i in sequence)
# minimize this over trillions of tokens
The base model is further trained on a much smaller, curated dataset of (instruction, ideal response) pairs, written or selected by humans. This teaches the model the format of being an assistant — answering questions instead of continuing them, following the system/user/assistant turn structure, refusing certain requests — using the same next-token objective as pretraining, just on different data.
SFT teaches the model to imitate good responses it was shown; it doesn't teach it to distinguish a good response from a slightly-worse one on its own. Preference alignment closes that gap: humans (or a trained model acting as a judge) rank multiple candidate responses to the same prompt, and that ranking signal is used to further shift the model's output distribution toward what's preferred.
| Approach | Mechanism |
|---|---|
| RLHF (classic) | Train a separate reward model on the ranking data, then use reinforcement learning (PPO) to optimize the LLM against that reward model |
| DPO (Direct Preference Optimization) | Skip the separate reward model and RL loop entirely — a closed-form loss derived to have the same optimum, trained directly like supervised learning |
All three stages above are what the model vendor does before shipping the model. When this track later talks about "fine-tuning" as something you do, it means starting from the already-aligned model and running a much smaller, task-specific version of stage 2 — typically with LoRA rather than updating every weight. See Fine-Tuning vs. RAG vs. Prompting for when that's actually the right tool.