# Direct preference optimization (DPO)

> Canonical: https://skillalmanac.com/glossary/dpo | Last verified: 2026-11-25 | Index status: index-eligible

Direct preference optimization (DPO) is a method for tuning a language model on pairs of answers with a preferred and a dispreferred response, using a simple classification-style loss instead of a separate reward model and reinforcement learning.

Also called: DPO, DPO training, direct preference optimisation.

## In plain language

DPO trains a model from pairs labelled as preferred and dispreferred; people or another process can supply the labels. You collect many examples: one question, a better answer and a worse answer. Training then pushes the model toward the better kind and away from the worse kind, like a writing coach who only ever says 'this draft, not that one'. It skips the extra scoring program that RLHF builds, so the setup is simpler. The limits are the same as for any preference training: the preference labels can be mistaken or reflect the biases of the process that supplied them, and the preference data still has to be collected and checked. It does not make a model correct.

## Technical definition

The DPO paper (arXiv 2305.18290, first submitted 29 May 2023) introduces a new parameterization of the reward model in RLHF that allows the optimal policy to be extracted in closed form, so the problem is solved with a simple classification loss, without sampling from the model during fine-tuning. Hugging Face's TRL documentation describes training on a preference dataset where each example has a prompt, a chosen and a rejected completion. The objective widens the margin between the log-likelihoods of preferred and dispreferred completions relative to a reference model, without an explicit reward model. The beta parameter sets regularization strength relative to the reference policy in the underlying KL-regularized objective; it is not a hard maximum on model movement.

## How it shows up when you use agents

DPO happens before you meet the model. The DPO paper describes tuning a language model with preference pairs, and TRL, a Hugging Face library, includes a trainer for it. If you run a [self-hosted model](/glossary/self-hosted-llm) or pick an open model from a hub, its description may say it was tuned with DPO. That tells you how it was shaped, not how well it works on your task.

If you tune a model yourself, the quality of the chosen and rejected pairs decides most of the result. Pairs that differ in length or style rather than quality can teach the wrong lesson. Your own graded cases, kept apart from the training pairs, are a good way to see whether the tuning helped. Compare against the untouched model before you adopt the new one.

What breaks when DPO is misunderstood: treating it as a replacement for evaluation, or assuming it removes the need for human judgement. People still decide which answer is better, and the method does not say whether that judgement was good. See [RLHF](/glossary/rlhf) for the older recipe it simplifies and [fine-tuning](/glossary/fine-tuning) for the wider family.

## Common confusions

- **DPO versus RLHF.** RLHF fits a [reward model](/glossary/reward-model) and then runs reinforcement learning. DPO uses preference pairs directly with a classification-style loss.
- **DPO versus supervised fine-tuning.** Supervised tuning learns from single example answers. DPO learns from pairs where one answer is preferred.
- **DPO versus prompting.** Prompting changes the input. DPO changes the model's weights.
- **Myth.** DPO needs no human preferences. It needs preference data, which people or another process must supply.

## Worked examples in this catalogue

### [llm-eval-test-sets](https://skillalmanac.com/skills/skill-almanac/llm-eval-test-sets)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: An eval dataset for an LLM feature, with a checker for duplicates, missing graders, imbalance and leakage.

Why it exercises the concept: The catalogue has no training skills. What it does have is the check you need after any tuning: a graded test set that was not used for training, so you can see whether behaviour changed.

### [reproducibility-package-checklist](https://skillalmanac.com/skills/skill-almanac/reproducibility-package-checklist)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A check of whether a project folder has what a stranger needs to rerun an analysis, including data provenance and licence, pinned software versions and random seeds.

Why it exercises the concept: A preference-tuning run depends on its data, library versions and seeds. The skill is written for research analyses, not model training, but the same missing pieces make a tuning run impossible to repeat.

### [What Is an LLM? The Facts Agent Users Need](https://skillalmanac.com/learn/what-is-an-llm-for-agent-users)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: The current guide contrasts the original Transformer decoder’s autoregressive generation with BERT’s masked pretraining, and distinguishes runtime context from learned parameters.

Why it exercises the concept: It supplies background on training objectives and runtime behavior, including worked objective examples. It is not a DPO training tutorial or evidence that a tuning run was executed.

## Related terms

- [Reinforcement learning from human feedback (RLHF)](https://skillalmanac.com/glossary/rlhf.md)
- [Reward model](https://skillalmanac.com/glossary/reward-model.md)
- [Fine-tuning](https://skillalmanac.com/glossary/fine-tuning.md)
- [Reinforcement learning](https://skillalmanac.com/glossary/reinforcement-learning.md)
- [AI alignment](https://skillalmanac.com/glossary/ai-alignment.md)
- [Large language model (LLM)](https://skillalmanac.com/glossary/large-language-model.md)

## Sources

- [Direct Preference Optimization: Your Language Model is Secretly a Reward Model](https://arxiv.org/abs/2305.18290), arXiv (Rafailov et al.) (accessed 2026-11-24)
- [DPO Trainer](https://huggingface.co/docs/trl/dpo_trainer), Hugging Face (TRL documentation) (accessed 2026-11-24)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-25. [Glossary index](https://skillalmanac.com/glossary.md).
