Skip to content

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.

Advanced ~14 min9 steps

What runs in CodeSplash

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

Read first

01

The shortcut

Read

RLHF 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:

r(x,y)=βlog⁡π(y∣x)πref(y∣x)+const.r(x, y) = \beta \log \frac{\pi(y \mid x)}{\pi_{\text{ref}}(y \mid x)} + \text{const}.

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..

02

The DPO loss

Read

For a chosen answer ywy_w and a rejected one yly_l:

L=−log⁡σ ⁣(β[log⁡π(yw)πref(yw)−log⁡π(yl)πref(yl)]).L = -\log \sigma\!\Big(\beta \Big[\log \tfrac{\pi(y_w)}{\pi_{\text{ref}}(y_w)} - \log \tfrac{\pi(y_l)}{\pi_{\text{ref}}(y_l)}\Big]\Big).

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?

0.50

Small β lets the policy move far from the reference; large β keeps it close.

100

Comparisons simulated from hidden true rewards with a Bradley–Terry model.

500

Full-batch gradient steps on the DPO loss.

0.50

Step size on the implicit reward β(θ − θ_ref), so β doesn't change the speed.

Correct and helpful0.81Correct but curt0.12Polite but vague0.05Confident and wrong0.01Off topic0.00Refuses0.00
  • 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.

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.

03

What can go wrong

Read

DPO 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.

04

ORPO: one stage, no reference

Read

ORPOORPOOne-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:

L=−log⁡p(yw)  −  λlog⁡σ ⁣(log⁡p(yw)1−p(yw)−log⁡p(yl)1−p(yl)).L = -\log p(y_w) \;-\; \lambda \log \sigma\!\Big(\log \tfrac{p(y_w)}{1 - p(y_w)} - \log \tfrac{p(y_l)}{1 - p(y_l)}\Big).

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.

05

What runs here

Read
Reference · LNG065 · Runs as a notebookDirect Preference Optimization (DPO)Trains a policy directly from preferred/rejected response pairs relative to a reference policy, avoiding an explicit separately optimized reward model in the standard formulation.
06

Predict: raising β

Predict

Predict first

You rerun DPO with β ten times larger, everything else the same. Where does the tuned model end up?

It moves further from the referenceIt stays closer to the referenceβ has no effect on the result
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.

07

Common mistakes

Read
08

Check: DPO and ORPO

Checkpoint

Check 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.

09

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