Direct Preference Optimization (DPO)
Preference alignment as a plain classification loss — no reward model, no RL loop; the model's own log-ratios against a frozen reference act as the implicit reward.
Summary
Preference alignment as a plain classification loss — no reward model, no RL loop; the model's own log-ratios against a frozen reference act as the implicit reward.
It is the default way to teach a local model *your* judgments ("this answer over that one") after SFT, using data that never leaves your infrastructure: an offline dataset of chosen/rejected pairs plus one training job. RLHF's reward-model-plus-PPO stack is what it removes; online RL methods like GRPO are what it now shares the field with for reasoning tasks.
- DPO still needs a reference model in the loop — that's roughly two models' worth of memory unless you precompute reference log-probs (
precompute_ref_log_probs) or use a PEFT adapter (base model doubles as reference). - In practice the objective mostly suppresses the rejected completion's likelihood rather than raising the chosen one's (per TRL docs) — pairs where "rejected" is merely mediocre teach little.
- "Preference pairs" both being bad (or both good) breaks conversions to unpaired formats; chosen must be genuinely good and rejected genuinely bad before unpairing.
- The original sigmoid loss has a documented length bias;
sigmoid_norm(SimPO-style) and LD-DPO exist specifically to counter it.
used_byHugging Face TRL — DPOTrainer is the canonical implementation; 15 loss variants, PEFT/QLoRA and VLM support.augmentsParameter-Efficient Fine-Tuning (LoRA / QLoRA) — DPO-on-adapters is the documented consumer-GPU path (and sidesteps the second-model memory cost).constrained_byCatastrophic Forgetting — the KL-anchored reference model andbetaexist to bound drift from the base model's capabilities.augmentsSynthetic Training Data Generation — preference datasets like UltraFeedback are built from model completions and model/AI annotation rather than purely human labels.
Definition
DPO is a method for aligning a language model to preference data — pairs of a "chosen" and a "rejected" completion for the same prompt — without training a separate reward model or running reinforcement learning. The 2023 paper ("Your Language Model is Secretly a Reward Model," Rafailov et al.) showed the RLHF objective has a closed-form optimal policy, so the whole pipeline collapses into a simple classification loss: widen the log-likelihood margin between chosen and rejected completions relative to a frozen reference model, with a beta hyperparameter controlling how far the policy may drift from that reference.
Classic RLHF needs a trained reward model, online sampling from the policy during training, and RL machinery the paper describes as "complex and often unstable" — infrastructure that pushes alignment toward hosted pipelines. DPO is offline and single-job: one policy, one reference model (whose log-probs can even be precomputed to save memory), and a static dataset of preference pairs you built yourself. That is what makes alignment on private data practical on hardware you control — the pairs never leave your machines, and TRL's implementation composes with LoRA/QLoRA (peft_config + quantization_config) for consumer-GPU budgets. The trade-off is that preference-pair quality becomes the whole game, and offline pairs can't teach what online exploration can.
Connections9
Outbound5
scoped_to1used_by1constrained_by1Inbound4
Resources4
The original DPO paper — the closed-form-policy insight that removed the reward model from alignment.
Current practice in one page: loss formula, all 15 variants, beta/label-smoothing semantics, PEFT/QLoRA and memory options.
Exact preference-pair dataset shapes (explicit/implicit prompt, conversational, unpaired) and conversion recipes for your own data.
DeepSeek-R1 — the result behind GRPO's rise as the online counterpart to offline DPO.