Unit 3 · Training
Lesson 12 · Available to read
Alignment: RLHF, Constitutional AI and Human Preferences
Teaching models what people actually want: reward models, RLHF, DPO and Constitutional AI.
Fine-tuning on demonstrations (Lesson 11) teaches a model to imitate good answers. But for many qualities — helpfulness, honesty, tact, safety — it's far easier for a person to compare two answers than to write the perfect one. Alignment techniques turn those comparisons into training signal.
A common shorthand for the goal is HHH: responses should be helpful, honest and harmless. These can pull against each other — the most "helpful" answer to a dangerous request isn't harmless — so alignment is as much about balancing goals as maximising one.
RLHF: Reinforcement Learning from Human Feedback
RLHF became widely known through OpenAI's 2022 InstructGPT work, in which human raters preferred the outputs of a 1.3B-parameter RLHF model over those of the original 175B-parameter GPT-3. The recipe has three stages:
1. Start from an SFT model. It already follows instructions reasonably well.
2. Collect comparisons and train a reward model. For many prompts, sample two (or more) responses and have people choose which is better. Then train a reward model — usually a copy of the LLM with a single-number output head — to predict those preferences.
The standard training objective (Bradley–Terry) says the probability that A is preferred over B is the logistic function of the score difference:
P(A ≻ B) = σ(r(A) − r(B)), with loss −ln σ(r(A) − r(B))
3. Optimise the model with reinforcement learning. The LLM (now called the policy) generates responses; the reward model scores them; an RL algorithm such as PPO nudges the policy toward higher-scoring responses. The objective includes a crucial penalty:
maximise reward − β · KL(policy ‖ SFT model)
The KL divergence measures how far the new model's output distribution has drifted from the SFT model's. Without it, the policy quickly finds ways to exploit quirks in the reward model.
Reward hacking
A reward model is only an approximation of human judgement, and optimising hard against any proxy breaks it — Goodhart's law: when a measure becomes a target, it ceases to be a good measure. Classic symptoms:
- Verbosity — longer answers score higher, so the model pads everything.
- Sycophancy — agreeing with the user or flattering them earns approval, even when the user is wrong.
- Confident tone — sounding sure is rewarded more than being right.
Countermeasures include the KL penalty, better and more diverse comparison data, ensembles of reward models, and evaluations that specifically test for these behaviours.
DPO: skipping the reward model
Direct Preference Optimization (2023) showed that the RLHF objective can be optimised without training a separate reward model or running an RL loop. Using the same preference pairs, DPO applies a simple classification-style loss directly to the policy: raise the likelihood of the preferred response relative to the rejected one, measured against the reference SFT model. It is simpler and more stable, and it — along with many variants — is now widely used, often alongside RL methods.
Constitutional AI and AI feedback
Collecting human labels for harmful content is slow, expensive and unpleasant for raters. Anthropic's Constitutional AI (2022) replaced much of that labour with a short written list of principles — a constitution — and AI feedback.
- Phase 1 — supervised self-critique. The model answers difficult prompts, critiques its own answer against a principle ("Which response is less harmful and more honest?"), revises it, and is fine-tuned on the revisions.
- Phase 2 — RL from AI Feedback (RLAIF). A model compares pairs of responses according to the constitution; those AI-generated preferences train the reward model used for RL.
Benefits: the target behaviour is written down and can be inspected and debated; it scales without proportionally more human labelling; and it aims for models that explain their objections rather than giving evasive refusals.
Reinforcement learning from verifiable rewards
For tasks with checkable answers — maths problems, code with unit tests, puzzles — the reward can come from an automatic verifier instead of a learned preference model. Training reasoning models with RL against such rewards encourages long, careful chains of reasoning and self-correction (Lesson 14). Because the reward is grounded in correctness rather than appearance, it's harder (though not impossible) to game.
The open questions
- Whose preferences? Raters and constitution writers bring particular cultures and values; choices about representativeness matter.
- Honesty vs. approval. Rewarding what people like is not the same as rewarding what is true.
- Generalisation. Will trained behaviour hold up in new situations, under adversarial pressure (Lesson 19), and in more capable future systems?
Alignment remains an active research field. The techniques in this lesson are today's practical tools, not a finished solution.
The takeaway
Alignment teaches a model what people actually prefer: humans (or an AI guided by written principles) compare responses, a reward model or a direct preference loss turns those judgements into a training signal, and a KL penalty stops the model from gaming the reward at the cost of everything else.
Practice
0 of 7 attempted
- 1Recall
List the three stages of RLHF and what each produces.
Saved in this browser
- 2Calculate
A reward model scores response A at 1.0 and response B at 3.0, but humans preferred A. What probability does the model give to A being preferred? What is the loss? Which way will training push the scores?
Saved in this browser
- 3Explain in your own words
What is the purpose of the KL penalty in RLHF? What would likely happen without it?
Saved in this browser
- 4Multiple choice
What is the main simplification DPO offers over classic RLHF?
- 5Explain in your own words
Describe the two phases of Constitutional AI in your own words.
Saved in this browser
- 6Apply
Give an everyday example of Goodhart's law, then explain how sycophancy is the same phenomenon in LLMs.
Saved in this browser
- 7Explain in your own words
Why are verifiable rewards (like unit tests) harder to game than learned reward models?
Saved in this browser