DPO and ORPO: preference tuning without a reward model
Direct preference optimization turns the KL-penalized RLHF objective into a classification loss on preference pairs. ORPO folds preferences into supervised tuning with an odds-ratio term and no reference model.
What runs in CodeSplash
- LNG065Direct Preference Optimization (DPO) Runs as a notebook
- LNG066Odds Ratio Preference Optimization (ORPO) Explained here
You will be able to
- Write the DPO loss and say what the reference model and β do in it
- Explain why DPO needs no separate reward model or RL loop
- Describe ORPO's two terms and why it needs no reference model
- Name the failure modes to check after preference tuning
The shortcut
ReadRLHF fits a reward model, then runs reinforcement learning against it with a KL penalty. The KL-penalized objective has a known best policy: the reference model's probabilities reweighted by the exponential of reward over β. Turn that around and the reward can be written in terms of the policy itself:
Put that into the Bradley–Terry loss on preference pairs and the reward model disappears. That is DPODirect preference optimization (DPO)Preference tuning without a separate reward model: a loss on preferred versus rejected answers, held near a frozen reference..
The DPO loss
ReadFor a chosen answer and a rejected one :
It is a logistic loss on how much more the policy has raised the chosen answer than the rejected one, both measured against the frozen reference. In the reference's example, with β set to a fifth, the loss is 0.616: the policy already prefers the chosen answer a little more than the reference does.
β plays the KL weight's role. Small β lets the policy move far from the reference; large β keeps it close.
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 can go wrong
ReadDPO only cares about the gap between chosen and rejected. The gap can grow while both likelihoods fall, so the model gets worse at producing the chosen answers themselves. It also inherits the preference data's biases: if raters favored longer answers, DPO learns length.
And there is no reward model left to inspect. Check the tuned model on held-out prompts, for answer length, and on tasks it handled before tuning.
ORPO: one stage, no reference
ReadORPOORPOOne-stage preference tuning: the usual likelihood loss on the chosen answer plus a log-odds-ratio penalty against the rejected one. skips the separate supervised stage and the reference model. Its loss is the ordinary likelihood loss on the chosen answer plus a weighted penalty on the log-odds ratio between chosen and rejected:
The first term keeps the chosen answers likely, which guards against DPO's falling-likelihood problem. In the reference's example the total is 0.536.
What runs here
ReadPredict: raising β
PredictPredict first
You rerun DPO with β ten times larger, everything else the same. Where does the tuned model end up?
Reveal
Closer to the reference. β scales how much each log-ratio counts; a larger β reaches the same preference margin with smaller moves away from the reference model.
Common mistakes
ReadCheck: DPO and ORPO
CheckpointCheck yourself
Why does DPO need no separate reward model?
Show the answer
Answer: a
The KL-penalized optimum links reward and policy; substituting it into Bradley–Terry removes the reward model.
Check yourself
What role does the reference model play in DPO?
Show the answer
Answer: a
Each answer's log-ratio compares the policy with the reference, so preference gains are measured as changes from it.
Check yourself
After DPO, the chosen answers' likelihood has dropped, though the chosen–rejected gap grew. Which change targets that directly?
Show the answer
Answer: a
DPO only rewards the gap. ORPO's supervised term keeps the chosen answers themselves likely.
Check yourself
Which two terms make up the ORPO loss?
Show the answer
Answer: a
ORPO is one-stage: supervised tuning and preference shaping in the same loss, with no reference model.
Check yourself
What does ORPO save compared with DPO?
Show the answer
Answer: a
DPO evaluates both the policy and the reference on each pair; ORPO uses only the policy's own odds.
Recap
Recap- DPO writes the reward as β·log(π/π_ref) and fits preference pairs with a logistic loss: no reward model, no RL loop.
- β sets how far the policy may move from the reference.
- The chosen–rejected gap can grow while both likelihoods fall; ORPO's supervised term guards against that.
- DPO's loss runs as a notebook; ORPO is explained here.
Concepts in this lesson