Fine-Tuning, and When Not ToLesson 41 of 84

Module 5 · Objectives beyond next-token prediction

DPO, from first principles

In this lesson

  • 10 min read
  • 7 reading sections
  • Knowledge check
  • Lesson 3 of 9 in this chapter

This chapter’s goalChoose between supervised fine-tuning, a preference method such as DPO or KTO, a verifiable-reward method such as GRPO, and continued pretraining, and state the data each needs, the memory each costs, and the way each is gamed.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available
The two reward statistics, and what they usually doWhat you expectrewards/chosen risesrewards/rejected fallsthe margin widensgood answers stay likelyWhat you frequently seerewards/chosen falls as wellrewards/rejected falls fasterthe margin widens all the samethe model drifts towards something neitherchosen nor rejected: shorter, blander,sometimes degenerateThe loss only cares about the difference, so reducing the chosen response is acceptable to it as longas the rejected one falls faster. Watch rewards over chosen and stop when it has been falling for afew hundred steps.
The loss only cares about the difference, so reducing the chosen response is acceptable to it as long as the rejected one falls faster. Watch rewards over chosen and stop when it has been falling for a few hundred steps.

Figure

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 8Free · no account needed
Lesson steps

The problem DPO removed

The classical approach to learning from preferences trains a separate reward model on the pairs, then uses reinforcement learning to maximise that reward while staying close to the original model. Four models in memory, an unstable optimisation, and a reward model that can be gamed.

Direct Preference Optimisation’s contribution is an algebraic observation: for that KL-constrained objective, the optimal policy has a closed form in terms of the reward, and that relationship can be inverted. The reward is therefore expressible in terms of the policy itself, which means you can optimise directly on preference pairs and never build a reward model at all.

The loss that falls out is a binary classification loss:

Text
L = -log σ( β · [ log π(y_w|x)/π_ref(y_w|x)  −  log π(y_l|x)/π_ref(y_l|x) ] )

Read it in pieces:

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the Running Models Yourself exam.

Stuck on something?Ask Rafael, your AI tutor

How to cite: Addaly (2026) ‘DPO, from first principles’, in Fine-Tuning, and When Not To. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/fine-tuning/dpo-from-first-principles (Accessed: 29 November 2026).