Robots Atlas>ROBOTS ATLAS
Alignment

DPO

2023ActivePublished: 9 June 2026Updated: 9 June 2026Published
Key innovation
Eliminates the separate reward model and reinforcement learning loop of RLHF — shows that KL-constrained reward maximisation reduces analytically to simple binary classification on preference pairs. The same alignment quality is achieved with a single, stable supervised-training step.
Category
Alignment
Abstraction level
Pattern
Operation level
Post-trainingTrainingModel
Use cases
Open-source LLM alignment: Llama 2 Chat → Llama 3 Instruct, Mistral 7B Instruct, Zephyr 7B, Tulu 2Toxicity and hallucination reduction without the full RLHF pipelineCheaper and more stable fine-tuning on proprietary enterprise preferences (domain alignment)Starting point for the whole preference-optimisation family: IPO, KTO, ORPO, SimPO, RPOAlignment of reasoning models — e.g. early SFT+DPO variants before full RL

How it works

Mathematical derivation (the paper's key contribution): RLHF maximises E[r(x,y)] - β·KL(π||π_ref), where r is the reward model, π_ref is the reference model (usually SFT), β is the KL-regularisation strength. The optimal policy of this maximisation has a closed form: π*(y|x) = (1/Z(x))·π_ref(y|x)·exp(r(x,y)/β). Inverting: r(x,y) = β·log(π*(y|x)/π_ref(y|x)) + β·log Z(x). Substituting this into the Bradley-Terry preference model P(y_w > y_l) = σ(r(x,y_w) - r(x,y_l)), Z(x) cancels and we get a DIRECT loss without a reward model:

L_DPO = -E[(x,y_w,y_l)] log σ(β log π_θ(y_w|x)/π_ref(y_w|x) - β log π_θ(y_l|x)/π_ref(y_l|x))

Where π_θ is the trained policy (LLM), π_ref is the frozen SFT model. Training: standard backprop on batches of (prompt, chosen, rejected) triples; π_θ starts from π_ref; β controls the strength of departure from π_ref (typically 0.01–0.5). Inference: a plain LLM, no runtime overhead. Empirically requires 1–3 epochs on high-quality preference data — versus days of RL with PPO.

Problem solved

Classical RLHF has three steps: (1) supervised fine-tuning, (2) training a separate reward model on preference data, (3) optimising the LLM policy via PPO against that reward model. Each step adds cost, risks instability (PPO can be finicky), and accumulates errors: the reward model overfits and is hacked by the policy (reward hacking), and the RL optimisation itself requires careful tuning of KL penalty, learning rate, and quality control. DPO removes steps (2) and (3) — one supervised training run on (y_w, y_l) pairs replaces the whole RL pipeline, eliminates reward hacking, and dramatically lowers the entry barrier (a regular ML team instead of RL specialists).

Components

Policy network π_θOptimisation target — the post-alignment model

The LLM updated by the DPO loss. Initialised from π_ref. After training it is the final product — used standardly at inference, with no trace of DPO.

INStandard LLM tokens-in/tokens-out.
OUTSequence log-probabilities of y_w and y_l needed for the loss.
Reference policy π_ref (frozen)KL reference — keeps the policy close to a safe distribution

Usually the SFT model — the starting version of π_θ before DPO. Stays frozen throughout training and serves as the denominator in the log-ratio: log(π_θ/π_ref). Implementation-wise: the same model in eval mode, a second forward pass per batch.

Full π_ref forwardA second forward pass per batch — simple but 2× GPU memory.
LoRA-only π_θπ_θ = π_ref + LoRA adapter — toggle the adapter instead of keeping two model copies in VRAM.
SimPO (without π_ref)A variant dropping π_ref entirely at the cost of slightly worse stability.

Official

DPO loss (Bradley-Terry on log-ratios)Training signal — forces the log-probability of the preferred response to grow relative to π_ref

Sigmoid binary cross-entropy on the difference of log-ratios for the (chosen, rejected) pair. The direct equivalent of a Bradley-Terry classifier, without a separate reward model.

sigmoid (vanilla DPO)Original form from the paper.
IPO lossSquared loss instead of sigmoid — resistant to overfitting.
KTO lossPointwise instead of pair-wise — allows learning from single good/bad labels.

Official

Preference dataset (x, y_w, y_l)Preference signal — the only external input to the DPO process

A set of response pairs with preference labels — y_w (winning) preferred over y_l (losing) for a given prompt x. May come from humans, LLM-as-judge, or be synthetic.

Implementation

Implementation pitfalls
Too high learning rate → mode collapseCritical

DPO tolerates high learning rates much worse than SFT — π_θ quickly drifts from the π_ref distribution and the model loses coherence/generation quality. A frequently reported issue.

Fix:Use LR in 1e-7 to 5e-6 (10–100× lower than SFT). Monitor KL(π_θ || π_ref) during training.
Low-quality preference pairs → harmful alignmentHigh

(y_w, y_l) pairs with unclear quality difference inject noise that DPO directly learns. "Noisy" preference data is worse for DPO than for RLHF (the reward model filters some noise).

Fix:Use high-quality preference datasets (UltraFeedback with LLM-as-judge, Anthropic HH-RLHF) and filter pairs with unclear difference.
Confused π_ref and SFT modelHigh

π_ref MUST be the starting model of π_θ (usually SFT), not a different checkpoint. Otherwise KL regularisation makes no sense and the model breaks.

Fix:Initialise π_θ from π_ref weights at the start of DPO; keep π_ref frozen throughout training.
Too many epochs → quality degradationMedium

DPO overfits much faster than SFT. After 3–5 epochs quality starts dropping even though loss keeps decreasing (overfitting in preference space).

Fix:Validate on a held-out preference set every 100–500 steps; 1 epoch usually suffices. Consider IPO (regularised variant) for small datasets.

Evolution

Original paper · 2023 · NeurIPS 2023 (Stanford University) · Rafael Rafailov
Direct Preference Optimization: Your Language Model is Secretly a Reward Model
Rafael Rafailov, Archit Sharma, Eric Mitchell, Stefano Ermon, Christopher D. Manning, Chelsea Finn
2017
PPO (Schulman et al., OpenAI) — RL alignment foundation

Proximal Policy Optimization — the RL algorithm that becomes the default RLHF optimiser.

2022
InstructGPT / RLHF (Ouyang et al., OpenAI)

OpenAI publishes the full RLHF pipeline (SFT → reward model → PPO) applied to GPT-3.5. The LLM alignment standard for the next 18 months.

2022
Constitutional AI (Bai et al., Anthropic)

Anthropic replaces human preference labels with LLM-as-judge. One legacy of this idea will later be synthetic preference data for DPO.

2023
DPO — Stanford paper
Inflection point

Rafailov, Sharma, Mitchell, Ermon, Manning, Finn publish DPO (arXiv:2305.18290, NeurIPS 2023). They prove a formal equivalence: the optimal policy of KL-constrained RLHF parametrises its own implicit reward model. The result — a single supervised loss replaces the whole RLHF pipeline.

2023
Zephyr 7B / Tulu 2 — first production DPO deployments

Hugging Face Zephyr 7B and Allen AI Tulu 2 demonstrate that SFT+DPO yields RLHF-competitive alignment quality at a fraction of the cost. The open-source community adopts en masse.

2024
IPO / KTO / ORPO / SimPO — successor family

Azar et al. (IPO) and Ethayarajh et al. (KTO) introduce variants addressing overfitting and the pair requirement. Hong et al. (ORPO) merge SFT+DPO into a single loss. Meng et al. (SimPO) drop π_ref. DPO becomes part of a broader "direct preference optimisation" field.

2024
Llama 3 Instruct, Mistral, Qwen — DPO as industry standard

Meta Llama 3, Mistral, and Alibaba Qwen use DPO (or its variants) as the main chat-alignment mechanism. RLHF with PPO remains mainly in OpenAI/Anthropic internal pipelines.

Hyperparameters (configurable axes)

KL strength (β)Critical

Controls how far policy π_θ can drift from reference model π_ref. Too small β = drift from π_ref and quality degradation; too large = no alignment. Practical range 0.01–0.5; the original paper uses 0.1–0.3.

0.01
0.1
0.3
Reference policy (π_ref)Critical

Frozen base model (usually SFT on the same instruction set). Determines the starting point and the KL-regularisation range. The choice of π_ref affects final quality more than β.

SFT model
instruction-tuned model
Preference dataset qualityCritical

The single strongest factor in the outcome. (Chosen, rejected) pairs must have clearly different quality; noise in preferences hurts the model. Typical datasets: Anthropic HH-RLHF, UltraFeedback, Nectar, OpenAssistant.

Training epochsHigh

DPO overfits faster than SFT — typically 1–3 epochs suffice. The paper recommends 1 epoch on large datasets.

1
3
Learning rateHigh

Drastically lower than in SFT — typically 1e-7 to 5e-6. Too high = π_θ drifts from π_ref and loses generative capability (mode collapse).

5e-7
5e-6
Loss variantMedium

After DPO a family of variants emerged: vanilla DPO (sigmoid), IPO (regularised against overfitting), KTO (pointwise preferences instead of pairs), ORPO (joint SFT+DPO), SimPO (without π_ref).

sigmoid
IPO
KTO
ORPO
SimPO

Computational complexity

Time complexity: O(2 · T · |θ|) per krok (dwa forward passes per para). Space complexity: O(2 · |θ|) parametrów (π_θ + π_ref) lub O(|θ| + |LoRA|) z adapterem.

Compute bottleneck

VRAM for two model copies

For 7B+ models, keeping both π_θ and π_ref in VRAM at once is the main constraint. Hence the popularity of DPO+LoRA and variants without π_ref (SimPO, ORPO).

Depends on
model size |θ|sequence length

Execution paradigm

Primary mode
Dense

DPO modifies only the training loss function, not the model structure. The π_θ policy remains a dense network; π_ref is frozen but also dense.

Activation pattern
All paths active

Parallelism

Parallelism level
Fully parallel

The DPO loss is a standard supervised cross-entropy with two forward passes (chosen + rejected) per pair. It scales like SFT via DDP/FSDP, ZeRO, tensor parallelism — without special RL constraints. Inference after DPO is a plain LLM forward pass.

Scope
TrainingAcross tokensAcross devicesAcross layers

Hardware requirements

Primary

Standard supervised training on GPU — same profile as SFT. Two forward passes (chosen + rejected) per pair; π_ref is frozen, so only inference for it.

Good fit

TRL and Axolotl support TPU/JAX for DPO. With no specific RL requirements, scaling is straightforward.

Good fit

DPO is a pure loss modification — works on any hardware supporting SFT.