DPO (Direct Preference Optimization)
Direct Preference Optimization (DPO, Rafailov et al., NeurIPS 2023) is a simpler alternative to RLHF for aligning language models with human preferences. DPO eliminates the need for a separate reward model by deriving an equivalent training objective that directly optimizes the policy on preference data — reducing RLHF's three-stage pipeline to a single supervised fine-tuning step. It became the dominant open-source alignment method almost immediately, though by 2025–2026 it shares the post-training stage with newer, verifiable-reward RL methods for reasoning-specific alignment.
Aligning AI without a reward model.
Category: Model Training & Optimization
The DPO insight
RLHF requires training three separate models (SFT → RM → PPO policy). DPO's key insight: the optimal RLHF policy has a closed-form relationship to the reference policy, letting you eliminate the RM entirely and derive a single supervised loss:
\mathcal{L}_{\text{DPO}} = -\mathbb{E}\!\left[\log \sigma\!\left(\beta \log\frac{\pi_\theta(y_w|x)}{\pi_{\text{ref}}(y_w|x)} - \beta \log\frac{\pi_\theta(y_l|x)}{\pi_{\text{ref}}(y_l|x)}\right)\right]
Why this works mathematically: The RLHF objective (maximize reward − β·KL) has a closed-form optimum: π*(y|x) ∝ π_ref(y|x)·exp(r*(y|x)/β). DPO rearranges this to express the implicit reward as a ratio of policy to reference log-probs, then substitutes into the Bradley-Terry preference model — deriving the loss directly without ever training r* explicitly.
DPO vs RLHF in practice
| Dimension | RLHF (PPO) | DPO |
|---|---|---|
| Pipeline stages | 3 (SFT → RM → PPO) | 1 (SFT → DPO fine-tune) |
| Separate reward model | ✅ Required | ❌ Not needed |
| GPU memory | High — policy + ref + RM + value head | Medium — policy + frozen ref only |
| Training stability | ⚠️ PPO is finicky — reward scale, KL coefficient | ✅ Stable — standard cross-entropy-style loss |
| Online vs offline | Online — policy generates new rollouts each step | Offline — trains on fixed preference dataset |
| Iterative improvement | ✅ Natural — policy generates better data as it improves | ⚠️ Can stagnate — needs fresh data for best results |
| Who uses it | Closed labs for large-scale alignment | Dominant open-source method (Zephyr, OpenHermes-style Llama/Mistral/Qwen fine-tunes) |
DPO dataset construction
from datasets import load_dataset
from trl import DPOTrainer, DPOConfig
from transformers import AutoModelForCausalLM, AutoTokenizer
# Standard DPO dataset format: {"prompt", "chosen", "rejected"}
dataset = load_dataset("trl-lib/ultrafeedback_binarized")
# Example row:
# {
# "prompt": "Explain quantum entanglement simply.",
# "chosen": "Quantum entanglement means two particles...[clear explanation]",
# "rejected": "Quantum entanglement is a phenomenon...[jargon-heavy, unclear]"
# }
# Popular DPO datasets:
# - HH-RLHF (Anthropic): 160K human preference pairs
# - UltraFeedback (OpenBMB): 250K GPT-4-rated pairs
# - Nectar (Berkeley): 182K human+AI preference pairs
model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.1-8B-Instruct")
ref_model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.1-8B-Instruct")
trainer = DPOTrainer(
model=model,
ref_model=ref_model,
args=DPOConfig(
beta=0.1, # KL regularization strength
loss_type="sigmoid", # original DPO loss
learning_rate=5e-7, # very small LR — DPO is sensitive
per_device_train_batch_size=4,
num_train_epochs=1,
),
train_dataset=dataset["train"],
)
trainer.train()
Data quality dominates: 1,000 high-quality human preference pairs consistently outperform 100,000 AI-labeled pairs. Key quality signals: (1) Clear margin between chosen and rejected — avoid borderline pairs. (2) Diversity — cover the full range of task types. (3) Consistency — all raters would agree. The Zephyr model (2023) showed that 200K AI-labeled UltraFeedback pairs + DPO beat much larger models trained with RLHF.
DPO variants: IPO, KTO, ORPO
| Variant | Year | Key change vs DPO | Main advantage | Use when |
|---|---|---|---|---|
| DPO (original) | 2023 | Baseline — Bradley-Terry preference loss | Simple, no RM | Default starting point |
| IPO (Identity PO) | 2023 | Regularises log-ratio to prevent overconfidence | Less overfitting on small datasets | Small preference datasets |
| KTO (Kahneman-Tversky) | 2024 | Uses unpaired pos/neg examples — no preference pairs needed | Easier data collection | When paired comparisons are hard to obtain |
| ORPO (Odds Ratio PO) | 2024 | Combines SFT + DPO in one pass, no ref model | Simpler one-stage training | Limited compute/memory |
| SimPO | 2024 | Average log-prob reward, no ref model | Eliminates ref model inference overhead | Inference-efficient training |
| Online / Iterative DPO | 2024 | Regenerate rejected responses from current policy | Addresses offline stagnation — near-PPO quality | Maximum quality when time allows |
Constitutional AI and RLAIF
Constitutional AI (Anthropic, 2022) scales alignment without large human annotation by using AI feedback against a written constitution of principles:
| Stage | Process | Output |
|---|---|---|
| 1. SL-CAI (supervised) | Model critiques and revises its own outputs guided by the constitution (e.g. "be helpful, harmless, honest") | Self-improved (prompt, revised_response) pairs for SFT |
| 2. RL-CAI (reinforcement) | AI judge (not humans) rates which of two responses better follows the constitution | AI-generated preference labels at scale |
| 3. RLHF / DPO on AI labels | Train on AI preferences via PPO or a DPO-style objective | Final aligned model |
RLAIF at scale: With ~100 constitutional principles and an AI judge, you can generate millions of preference pairs covering rare edge cases that human raters would rarely encounter. The tradeoff: AI judge biases embed into the model. Later Claude generations use multiple rounds of critique and revision with increasingly refined constitutions.
DPO's place in 2025–2026 post-training pipelines
DPO remains the standard tool for straightforward preference alignment, but it is no longer the only method in the post-training toolkit. Reasoning-focused open models — starting with DeepSeek-R1 and the wave of open reasoning models that followed through 2025 — instead lean on Group Relative Policy Optimization (GRPO, introduced by Shao et al. in the DeepSeekMath paper, 2024) for the reasoning-training stage: rather than a single preferred/rejected pair, GRPO samples a group of candidate responses per prompt, scores each with a verifiable reward (did the code pass its unit tests, is the math answer correct), and updates the policy toward the group's relatively better outputs — without training a reward model or using a DPO-style reference-ratio loss at all.
DPO vs GRPO — which to use: DPO and its variants (SimPO, ORPO, KTO) are still the right default for style, tone, and safety alignment, where "better" is a subjective judgment made by a human or AI rater. GRPO and other RL-from-verifiable-reward methods are the right choice specifically for reasoning tasks (math, code, formal logic) where correctness can be checked automatically. That's the real axis to choose on — not simply "old method vs new method."
Practice questions
- What is the mathematical objective of DPO training? (Answer: DPO minimizes: -E_{x,y_w,y_l}[log σ(β(log π_θ(y_w|x)/π_ref(y_w|x) - log π_θ(y_l|x)/π_ref(y_l|x)))] where y_w is the preferred (winning) response, y_l is the dispreferred (losing) response, π_ref is the frozen reference model, and β controls divergence from reference. This directly maximizes the probability that the model prefers y_w over y_l relative to the reference model, without requiring a separate reward model.)
- What is the fundamental difference between RLHF (PPO) and DPO? (Answer: RLHF/PPO: (1) Train a reward model on preference data. (2) Run PPO reinforcement learning using the reward model as reward signal. Requires 3 models: policy, reward, value function. DPO: directly optimize the policy on preference pairs without training a reward model or running RL. Derives from RLHF's objective but shows that the optimal policy can be expressed analytically in terms of preference data, bypassing RL entirely. DPO is simpler (standard supervised training), more stable, but less flexible.)
- Why does DPO sometimes produce models that are overly 'safe' or that diverge from the base model too much? (Answer: DPO maximizes log-ratio of winning vs losing responses but can ignore the absolute probability of the winning response — if both winning and losing responses have very low probability under the reference model, DPO may assign extreme ratios to strange outputs. With high β, the model stays close to reference (over-constrained). With low β, it can diverge significantly. DPO variants like IPO (Identity Preference Optimization) and KTO (Kahneman-Tversky Optimization) address this with modified objectives.)
- What is the 'distribution of dispreferred responses' problem in DPO? (Answer: DPO training decreases probability of the dispreferred (losing) response. Ideally it decreases probability of specifically bad aspects. In practice, DPO may decrease probability of the ENTIRE response format of dispreferred examples — including good parts that happen to appear in the losing response. If winning responses tend to be longer and losing shorter, DPO may learn to favor length over quality. Careful data curation (ensure winning and losing responses differ only in the relevant quality dimension) is essential.)
- Why do 2025–2026 reasoning models generally use GRPO rather than DPO for their core capability training? (Answer: DPO needs a fixed dataset of paired (chosen, rejected) responses, typically judged by subjective human or AI preference — well suited to style/safety, poorly suited to "is this proof correct." GRPO instead samples multiple candidate solutions per problem and scores them with an automatically verifiable reward (unit tests passing, a checkable final numeric answer), which scales far better for math/code/logic where correctness — not taste — is the target, and avoids the reward-hacking risk of a learned preference model being gamed on tasks that have an objectively checkable answer.)
You never interact with DPO directly on LumiChats, but its fingerprints are on every model in the lineup: post-training method is a large part of why Claude Opus 5.5 tends to be more cautious on a sensitive prompt than Grok 4.7, or why GPT-6 Sol follows formatting instructions more literally than a lighter, less heavily-aligned open model. If two models on LumiChats give noticeably different answers to the same careful prompt, part of what you're seeing is a difference in preference data and alignment method (DPO variants, RLHF, Constitutional AI, or GRPO for reasoning) — not just a difference in raw capability.