Direct Preference Optimization

Layer 2 · Mechanics

Direct Preference Optimization

The mechanics of the DPO loss: log-probability ratios, the implicit reward, and how the objective is derived conceptually.

8 min read70 XP

  1. Prompt + chosen + rejected

  2. Score both under policy

  3. Score both under frozen reference

  4. Compare the two log-ratios

  5. Push chosen's advantage up

What actually happens inside one DPO training step.

Recall from the RLHF derivation that the optimal KL-constrained policy has the form . Solving this for gives an *implicit reward* defined entirely by how much more likely the policy makes a response than the reference does:

Go deeper: L3 Code