Learn › Training & Alignment
·★ MEMBER·PAPER·13 min read

DPO and What Came After — The Lineage That Simplified RLHF

Derives DPO one line at a time, starting from the closed-form solution to KL-constrained reward maximization, to show why no separate reward model is needed. Then organizes IPO (which explains DPO's overfitting mathematically), KTO (which drops the pairing requirement), and GRPO (which drops the value model and goes back online) by what each one deleted — and gives a rule for choosing based on the shape of the data you actually have.

Key points

  • RLHF trains a reward model from comparison data, then uses reinforcement learning to push the language model toward responses the reward model scores highly.
  • In RLHF, four models sit on the GPU at once: the policy being trained, a frozen reference model, the reward model, and the value model PPO needs.
  • DPO, from 2023, claims the judge is already written into the policy itself, so no separate reward network needs to be built.
  • The KL-penalized reward maximization problem has an exact closed-form solution, and the reward can be written as a log ratio between the policy and the reference model.
  • In the Bradley-Terry model only the difference of rewards enters, so the uncomputable log Z(x) term cancels by subtraction, while the reference model remains.
ModalitytextTasktraining

Direct Preference Optimization: Your Language Model is Secretly a Reward Model

Primary source — what this article is built on

undefined2023-05-29→undefined2026-08-273y 3mo later

Direct Preference Optimization: Your Language Model is Secretly a Reward ModelRafael Rafailov, Archit Sharma, Eric Mitchell et al. · 2023-05-29 · v3arXiv:2305.18290Paper page·PDF
A General Theoretical Paradigm to Understand Learning from Human PreferencesarXiv:2310.12036Paper page·PDF
KTO: Model Alignment as Prospect Theoretic OptimizationarXiv:2402.01306Paper page·PDF
DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language ModelsarXiv:2402.03300Paper page·PDF
ORPO: Monolithic Preference Optimization without Reference ModelarXiv:2403.07691Paper page·PDF
undefined

While large-scale unsupervised language models (LMs) learn broad world knowledge and some reasoning skills, achieving precise control of their behavior is difficult due to the completely unsupervised nature of their training. Existing methods for gaining such steerability collect human labels of the relative quality of model generations and fine-tune the unsupervised LM to align with these preferences, often with reinforcement learning from human feedback (RLHF). However, RLHF is a complex and often unstable procedure, first fitting a reward model that reflects the human preferences, and then fine-tuning the large unsupervised LM using reinforcement learning to maximize this estimated reward without drifting too far from the original model. In this paper we introduce a new parameterization of the reward model in RLHF that enables extraction of the corresponding optimal policy in closed form, allowing us to solve the standard RLHF problem with only a simple classification loss. The resulting algorithm, which we call Direct Preference Optimization (DPO), is stable, performant, and computationally lightweight, eliminating the need for sampling from the LM during fine-tuning or performing significant hyperparameter tuning. Our experiments show that DPO can fine-tune LMs to align with human preferences as well as or better than existing methods. Notably, fine-tuning with DPO exceeds PPO-based RLHF in ability to control sentiment of generations, and matches or improves response quality in summarization and single-turn dialogue while being substantially simpler to implement and train.


The Detour Called a Reward Model

Say you want to get better at cooking. The obvious approach is to ask the people eating: "A or B — which was better?" and let the answer shape the next dish.

RLHF (reinforcement learning from human feedback) inserts a step in between. First you collect a pile of "A beats B" comparisons, and you use them to train a judge: a neural network that takes a dish and returns a score. That's the reward model. Then you use reinforcement learning to push the cook (the language model) toward dishes the judge scores highly. That three-stage pipeline is the InstructGPT recipe covered in Instruction Tuning and RLHF.

The reason for the detour is clear enough. RL runs "try, get scored, adjust" tens of thousands of times, and you cannot ask a human on every one of those steps. So you need a stand-in.

The cost is just as clear. Four models sit on the GPU at once: the policy being trained, a frozen reference model, the reward model, and the value model PPO needs. On top of that, RL is finicky. All of this to express "we'd like the model to match human preferences."

DPO (Direct Preference Optimization), from 2023, landed a clean hit here. You don't need the judge. More precisely: the judge is already written into the policy itself, so there is no reason to stand up a separate network for it.

The Intuition: The Scorecard Is Already Inside the Policy

The core claim fits on one line. Fix a scoring rule (a reward function) and the cook optimized for it is uniquely determined — and the reverse holds too. Watch how a cook behaves and you can work backward to the scoring rule they were optimized against. If that's true, there's no need to learn the scoring rule first. Apply the comparison data straight to the cook.

One caveat: working backward requires a reference point. If a cook salts heavily, you can't tell in isolation whether that's because salt scored well or because it was always their habit. Only by comparing against the pre-training version can you read off the shift that training pushed. That's why the reference model stays with DPO to the end. What disappears is the reward model and the value model — not the reference.

The Mechanism: Three Lines That Delete the Reward Model

We start from the problem RLHF is actually trying to solve.

max⁡πθ  Ex∼D,  y∼πθ(⋅∣x)[r(x,y)]  −  β DKL(πθ(⋅∣x) ∥ πref(⋅∣x))\max_{\pi_\theta}\; \mathbb{E}_{x\sim\mathcal{D},\; y\sim\pi_\theta(\cdot\mid x)}\big[r(x,y)\big] \;-\; \beta\, D_{\mathrm{KL}}\big(\pi_\theta(\cdot\mid x)\,\|\,\pi_{\mathrm{ref}}(\cdot\mid x)\big)
(1)

Here xx is the input (prompt), yy the output (response), πθ\pi_\theta the policy being trained, πref\pi_{\mathrm{ref}} the reference model frozen before training, r(x,y)r(x,y) the reward, and DKLD_{\mathrm{KL}} the KL divergence measuring the gap between two distributions. Said in words, the whole line reads: "score as high as you can on average, but hand back β\beta times whatever distance you put between yourself and the model you started from." β\beta is the dial for how much wandering is allowed.

This is where the road forks. The old approach solved this approximately, with PPO. But a problem of this shape has an exact solution in closed form.

π∗(y∣x)  =  1Z(x) πref(y∣x) exp⁡ ⁣(1β r(x,y))\pi^{*}(y\mid x) \;=\; \frac{1}{Z(x)}\,\pi_{\mathrm{ref}}(y\mid x)\,\exp\!\left(\frac{1}{\beta}\,r(x,y)\right)
(2)

Unpacked in words, the optimal policy is just "take how likely the original model was to say it, multiply by the exponential of the reward, and divide so everything sums to one." Z(x)Z(x) is the normalizing constant (the partition function) used for that division, one value per xx. High-reward responses get lifted by the exponential — but a response the original model almost never produces has a tiny πref\pi_{\mathrm{ref}}, so it won't suddenly appear. That is exactly what the KL penalty is.

Now solve that equation for rr. Take logs and rearrange; that's all.

r(x,y)  =  βlog⁡π∗(y∣x)πref(y∣x)  +  βlog⁡Z(x)r(x,y) \;=\; \beta\log\frac{\pi^{*}(y\mid x)}{\pi_{\mathrm{ref}}(y\mid x)} \;+\; \beta\log Z(x)
(3)

This is the decisive line. The reward is now written as a log ratio between the policy and the reference model. It is a sentence which says: a response's reward is nothing more than "how many times more likely the trained model is to say this than the original model was," taken in logs and scaled by β\beta — with log⁡Z(x)\log Z(x) an offset that lands on every response for a given prompt equally. You don't need to hold a reward function separately — the policy doubles as one. The paper's subtitle, "Your Language Model Is Secretly a Reward Model," is pointing at this equation.

What's left is log⁡Z(x)\log Z(x), a sum over every possible response, which you cannot compute. Here the shape of preference data saves us. Humans never gave absolute scores; they gave comparisons — "between A and B, A." The classical way to turn a comparison into a probability is the Bradley-Terry model.

p(yw≻yl∣x)  =  σ(r(x,yw)−r(x,yl))p(y_w \succ y_l \mid x) \;=\; \sigma\big(r(x,y_w) - r(x,y_l)\big)
(4)

ywy_w is the response the human chose, yly_l the one they didn't, and σ\sigma is the sigmoid. Put in words: push the two responses' score gap through the sigmoid and out comes the probability a human picks the winner — the bigger the gap, the closer that probability sits to one, exactly like a sports rating system.

FIG 1Read the horizontal axis as "reward gap between the winning and losing response" and the vertical axis as "probability a human picks accordingly," and this curve *is* the Bradley-Terry model. A gap of zero is a coin flip; a few ticks apart and the probability pins to 0 or 1, after which widening the gap barely moves the curve — that flat region is the villain of the second half

The thing to notice about equation (4) is that it only takes the difference of rewards. Substitute equation (3) and βlog⁡Z(x)\beta\log Z(x) appears identically on both sides, so the subtraction cancels it outright. The term we couldn't compute vanishes because of how the problem was posed.

Substituting and tidying up gives the DPO loss.…

What's behind this

§

Members-only from here

449 walkthroughs, 42 textbook chapters, 48 student units and 6 close readings — all included for $4.99/mo, with about three new explainers a day on average. Cancel any time; access runs to the end of the period.

Already a member? Sign in to keep reading

References

  1. Rafael Rafailov, Archit Sharma, Eric Mitchell, Stefano Ermon et al.. (2023-05-29) Direct Preference Optimization: Your Language Model is Secretly a Reward Model. arXiv:2305.18290Paper page·PDF
  2. A General Theoretical Paradigm to Understand Learning from Human Preferences. arXiv:2310.12036Paper page·PDF
  3. KTO: Model Alignment as Prospect Theoretic Optimization. arXiv:2402.01306Paper page·PDF
  4. DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models. arXiv:2402.03300Paper page·PDF
  5. ORPO: Monolithic Preference Optimization without Reference Model. arXiv:2403.07691Paper page·PDF

This article is written from the source paper above. Where they differ, the original is authoritative.

Published by TechAthletes · Editorial policy · How we cite · Corrections

Comments

Sign in to comment