From text predictor to assistant: instruction and preference tuning
A pretrained model continues text; an assistant follows instructions and prefers helpful, harmless answers. Survey the steps that get there, FLAN and T0, RLHF, Constitutional AI, DPO and ORPO, and what each optimizes.
What runs in CodeSplash
- LNG061FLAN instruction tuning Explained here
- LNG062T0 prompted multitask training Explained here
- LNG063InstructGPT / RLHF pipeline Explained here
- LNG064Constitutional AI Explained here
- LNG065Direct Preference Optimization (DPO) Runs as a notebook
- LNG066Odds Ratio Preference Optimization (ORPO) Explained here
- Paired comparisons (Bradley–Terry, Thurstone, Davidson, Crowd-BT) Verified in Python and R
You will be able to
- Explain what instruction tuning on many tasks changes, and why template wording matters
- Lay out the RLHF pipeline: supervised tuning, a reward model, then a KL-penalized policy update
- Compare DPO and ORPO with RLHF in what they need and what they optimize
- Say what preference tuning does and doesn't guarantee about a model's answers
Tasks as instructions
ReadA pretrained model asked "Translate to French: good morning" may continue with more English. Instruction tuningInstruction tuningFine-tune a language model on many tasks written as instructions with answers, so it follows new instructions. fine-tunes it on many tasks, each written as an instruction and an answer. FLAN used dozens of task clusters and showed that the tuned model follows instructions for task types it never saw.
The training mix is a choice: the reference program weights three task losses into one objective of 1.06. Large, common tasks can crowd out rare ones, so mixtures are capped or balanced.
Wording matters: T0
ReadT0 trained on many tasks, each with several hand-written prompt templates, and found that more prompt variety helped models handle new phrasings. It also measured how much results swing between templates for the same task.
In the reference program, three templates give the right answer probabilities that lead to a mean loss of 0.550, but the losses span 0.693 from best to worst template. The same sensitivity applies to CodeSplash's Label with AI: try a few wordings of your instructions and labels, and check each against known labels.
RLHF: learn what people prefer
ReadRLHFReinforcement learning from human feedback (RLHF)Tuning a model with a reward model fit to people's pairwise preferences, then optimizing against it with RL such as PPO., as in InstructGPT, has three steps. Tune the model on demonstrations. Collect pairs of answers that people ranked, and fit a reward modelReward modelA model trained on human preference pairs to score responses; RLHF then trains the policy to raise that score. with a Bradley–TerryBradley–Terry modelA model of pairwise judgments: the difference in two items' log-worths sets the log odds that one is preferred to the other. loss: the preferred answer should score higher. Then update the model to raise reward, minus a KL penaltyKL penalty to a reference modelA cost for drifting from the starting model's token probabilities, so preference tuning can't trade everything for reward. that keeps it close to the tuned starting point.
In the reference program the reward model's pairwise loss is 0.371; the policy's KL divergence from the reference is 0.0823, and reward minus the penalty gives 0.752. Without the penalty, the policy drifts toward whatever fools the reward model.
DExplorable · Preference optimization: reward models and DPO
How do pairwise preferences turn into a policy, and what does β protect against?
Small β lets the policy move far from the reference; large β keeps it close.
Comparisons simulated from hidden true rewards with a Bradley–Terry model.
Full-batch gradient steps on the DPO loss.
Step size on the implicit reward β(θ − θ_ref), so β doesn't change the speed.
- Reference policy
- DPO policy
- True optimum π_ref·exp(r*/β)
- Reward model + optimum (dots)
- KL from the reference (nats)
- 1.240
- Expected true reward
- 1.802
- Largest response probability
- 0.814
- Final DPO loss
- 0.4230
- Puzzle: Get within 0.1 of the true optimum's expected reward while staying under 1 nat from the reference.
- Puzzle: Make the policy put more than 90% on a single response.
After 500 steps on 100 pairs with β = 0.50, the policy gives “Correct and helpful” 81% and sits 1.24 nats from the reference. Its expected true reward is 1.80, against 0.34 for the reference and 1.71 for the true KL-regularized optimum. In this toy, DPO's policy is exactly what a fitted Bradley–Terry reward model plus the KL-regularized optimum would give.
Feedback from principles: Constitutional AI
ReadConstitutional AIConstitutional AIPreference tuning where a model critiques and ranks responses against written principles instead of human raters. replaces most human harm labels with AI feedback guided by a short written list of principles. The model critiques and revises its own answers against the principles, and an AI rater compares answers to produce preference pairs for training.
The reference program weights three principles to rate two responses: 0.83 and 0.75. The principles become an explicit, inspectable part of training, and the rater's own biases become part of the data.
Without a reward model: DPO and ORPO
ReadDPODirect preference optimization (DPO)Preference tuning without a separate reward model: a loss on preferred versus rejected answers, held near a frozen reference. skips the reward model and the reinforcement learning loop. It raises the log-probability of the preferred answer relative to a frozen reference model, and lowers the rejected one's, in one classification-style loss:
With β = 0.2 the reference program's loss is 0.616. ORPOORPOOne-stage preference tuning: the usual likelihood loss on the chosen answer plus a log-odds-ratio penalty against the rejected one. drops the reference model too: it adds an odds-ratio preference term to the ordinary supervised loss, giving 0.536 in the reference program.
DExplorable · Preference optimization: reward models and DPO
How do pairwise preferences turn into a policy, and what does β protect against?
Small β lets the policy move far from the reference; large β keeps it close.
Comparisons simulated from hidden true rewards with a Bradley–Terry model.
Full-batch gradient steps on the DPO loss.
Step size on the implicit reward β(θ − θ_ref), so β doesn't change the speed.
- Reference policy
- DPO policy
- True optimum π_ref·exp(r*/β)
- Reward model + optimum (dots)
- KL from the reference (nats)
- 1.240
- Expected true reward
- 1.802
- Largest response probability
- 0.814
- Final DPO loss
- 0.4230
- Puzzle: Get within 0.1 of the true optimum's expected reward while staying under 1 nat from the reference.
- Puzzle: Make the policy put more than 90% on a single response.
After 500 steps on 100 pairs with β = 0.50, the policy gives “Correct and helpful” 81% and sits 1.24 nats from the reference. Its expected true reward is 1.80, against 0.34 for the reference and 1.71 for the true KL-regularized optimum. In this toy, DPO's policy is exactly what a fitted Bradley–Terry reward model plus the KL-regularized optimum would give.
What preference tuning promises
PredictPredict first
After preference tuning, raters prefer a model's answers. What has improved?
Reveal
Its answers look more like what raters preferred. Raters reward clarity, confidence and length as well as correctness, so a tuned model can sound more convincing without being more accurate. Measure correctness separately.
Where it stands in CodeSplash
Read| Entry | In CodeSplash |
|---|---|
| FLAN, T0 (LNG061, LNG062) | Explained here |
| RLHF, Constitutional AI (LNG063, LNG064) | Explained here; the pairwise idea runs as Paired comparisons |
| DPO (LNG065) | Runs as a notebook (its reference program) |
| ORPO (LNG066) | Explained here |
The Training, adaptation and compression track goes deeper into each of these methods.
Check: instruction and preference tuning
CheckpointCheck yourself
What was FLAN's main finding?
Show the answer
Answer: a
Breadth of instruction-formatted tasks, not any single task, produced the zero-shot gains.
Check yourself
Why do instruction-tuning mixtures cap the share of very large tasks?
Show the answer
Answer: b
The mixture weights decide which skills the tuned model learns most; uncapped, data size alone would decide.
Check yourself
T0 trained each task with several prompt templates. What did that buy?
Show the answer
Answer: b
Seeing many phrasings during training made the model less dependent on one exact wording.
Check yourself
You label texts with an AI model and two wordings of the instruction give accuracy 81% and 68% on known labels. What should you report?
Show the answer
Answer: b
Prompt sensitivity is real and measurable. Report it, and choose the wording on data separate from the final check.
Check yourself
Put the classic RLHF pipeline in order.
Show the answer
The order:
- Tune the pretrained model on demonstrations
- Collect ranked pairs of answers and fit a reward model
- Update the model to raise reward, with a KL penalty to the tuned model
Supervised tuning, then a reward model from preference pairs, then a penalized reinforcement-learning update.
Check yourself
What does the KL penalty in RLHF protect against?
Show the answer
Answer: b
The reward model is only an approximation of preferences. Staying close to the reference model limits how far the policy can game it.
Check yourself
What replaces most human harm labels in Constitutional AI?
Show the answer
Answer: b
The model critiques and revises answers against principles, and an AI rater produces the preference pairs.
Check yourself
What risk comes with using an AI rater to make preference data?
Show the answer
Answer: b
AI feedback scales, but it inherits the rater model's judgments. Spot-check with people.
Check yourself
What does DPO need that ORPO doesn't?
Show the answer
Answer: a
DPO's loss uses log-ratios to a reference policy; ORPO folds preference into the supervised loss with odds ratios and needs no reference.
Check yourself
What does DPO's β control?
Show the answer
Answer: b
β plays the role of RLHF's KL penalty strength, scaling the log-ratio margin inside the sigmoid.
Check yourself
How does ORPO combine supervised tuning and preference tuning?
Show the answer
Answer: b
One stage, no reference model: the odds-ratio term pushes the preferred answer's odds above the rejected one's.
Check yourself
ORPO's preference term compares what between the chosen and rejected answers?
Show the answer
Answer: b
The log odds ratio inside a sigmoid gives a pairwise loss without a reference model.
Recap
Recap- Instruction tuning on many tasks (FLAN, T0) teaches instruction following; template wording still moves results.
- RLHF: demonstrations, a Bradley–Terry reward model, then a KL-penalized policy update. Constitutional AI swaps in principle-guided AI feedback.
- DPO needs a reference model but no reward model; ORPO needs neither.
- Preference tuning makes answers look preferred, not necessarily true.
Concepts in this lesson