14. Post-training: SFT, RLHF and DPO
A pretrained model completes text; it does not answer questions. Turning a document-completer into an assistant is a separate stage, and it is where most of the behaviour you interact with comes from.
By the end of this lesson you can
- Explain why a base model is not usable as an assistant
- Describe supervised fine-tuning and what data it needs
- Explain the RLHF pipeline including the reward model and PPO
- Explain how DPO removes the reward model, and what alignment tax means
What a base model does
Ask a raw pretrained model "What is the capital of France?" and a very plausible continuation is:
What is the capital of France?
What is the largest city in Germany?
What is the currency of Japan?
It is not being unhelpful. It is doing its job perfectly: on the internet, a question is frequently followed by more questions — a quiz, an FAQ, an exercise list. Answering is only one of many likely continuations.
The base model contains the knowledge and the ability. What it lacks is the convention that a user turn should be followed by a helpful assistant turn. Post-training installs that convention, along with tone, refusal behaviour, formatting and much else.
Stage 1: supervised fine-tuning
SFT is ordinary next-token training on a curated dataset of conversations. Examples look like:
<|user|> Explain photosynthesis to a 10-year-old.
<|assistant|> Plants make their own food using sunlight…<|end|>
Loss is usually computed only on the assistant tokens — you want the model to learn to produce responses, not to produce user turns. Special role tokens delimit the turns and are what let the model track who is speaking. (This is also why prompt-injection attacks are structurally interesting: everything is ultimately one token stream, and the role boundaries are a learned convention rather than a hard barrier.)
Data volume is modest: tens of thousands of examples is often enough, and quality dominates quantity. The LIMA result — strong instruction-following from 1,000 carefully curated examples — is the canonical evidence that SFT is teaching a format the model already has the substance for, not teaching new knowledge.
Stage 2: learning from preferences
SFT can only imitate demonstrations. But for many questions, writing an ideal answer is hard while comparing two answers is easy. RLHF exploits that asymmetry.
- Collect comparisons. Sample two responses to the same prompt; a human labels which is better. Repeat for tens or hundreds of thousands of prompts.
- Train a reward model. A separate network (often initialised from the LLM) learns to output a scalar score, trained so that preferred responses score higher. It is a learned, automatable stand-in for human judgement.
- Optimise the policy. Use reinforcement learning — PPO — to update the LLM to produce responses the reward model scores highly, with a KL-divergence penalty that punishes drifting too far from the SFT model.
That KL penalty is essential. Without it the policy finds adversarial nonsense that the reward model happens to love — classic reward hacking. The reward model is an approximation of human preference, and any optimiser pushed hard enough will find where the approximation breaks.
Label preference pairs
Play the annotator: pick the better response, then see what signal your choices give a reward model.
DPO and what comes after
PPO-based RLHF is fiddly: four models in memory at once — the policy being trained, a value network, the reward model and the frozen reference — plus unstable training and many hyperparameters. Direct Preference Optimisation showed that the RLHF objective can be rewritten as a simple classification loss directly on preference pairs — no reward model, no RL loop.
The intuition: increase the log-probability of the preferred response and decrease it for the rejected one, each measured relative to a frozen reference model. One model to train, standard supervised machinery, dramatically simpler. DPO and its variants (IPO, KTO, ORPO) are now the default for most open-model post-training, though carefully done PPO can still edge it out at the frontier.
Other things that live in post-training:
- Constitutional AI / RLAIF — a model critiques and revises its own outputs against a written set of principles, replacing much of the human labelling.
- RLVR — reinforcement learning from verifiable rewards: for maths and code you can check the answer automatically, giving a clean, unhackable reward signal. This is the engine behind current reasoning models.
- Reasoning training — rewarding long chains of thought that reach verified-correct answers, which produces models that spend far more tokens thinking before answering.
The alignment tax. Post-training can reduce raw capability and diversity: models become more cautious, more formulaic, and sometimes over-refuse. It also produces sycophancy, because human raters prefer agreement — an incentive built directly into the objective. There is a genuine trade-off here, not just an engineering bug.
Lesson in one breath
SFT teaches the format by imitating good demonstrations. RLHF trains a reward model on human preference comparisons and optimises the policy against it. DPO derives a direct loss on preference pairs, skipping the reward model entirely. Post-training changes behaviour far more than knowledge.
Practice
Answers are checked in your browser and saved to this device. Get one wrong and you can retry as many times as you like.
Why does a base pretrained model often respond to a question with more questions?
Order the stages of a classic RLHF pipeline.
What does the KL-divergence penalty in RLHF prevent?
What is the main practical advantage of DPO over PPO-based RLHF?
Which are real, documented side effects of post-training? Select all.
What does the acronym SFT stand for in post-training?
Done with this lesson?
A lesson counts as complete once it is marked read and every exercise is solved.
Tip: press ← and → to move between lessons.