# What Is DPO?

> What Direct Preference Optimization (DPO) is, how it learns from pairs of answers without a reward model, and where it falls short, explained simply for your AI interview.

**In short:** DPO, or Direct Preference Optimization, trains a language model on pairs of answers to the same prompt, one preferred and one rejected, with no separate reward model or reinforcement learning loop. It is simpler than RLHF, but it is only as good as its pairs.

AI and LLM interview question Q291, Fine-tuning and adaptation. Advanced, common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/what-is-dpo

## Say it in 30 seconds

DPO stands for Direct Preference Optimization. You give the model pairs of answers to the same prompt, one that people preferred and one they rejected. Training pushes the model toward the preferred answer, measured against a frozen copy of the starting model. So there is no separate reward model and no reinforcement learning loop. It is simpler than RLHF, the older method that uses a reward model and reinforcement learning, but the pairs have to be good, because the model learns from them exactly as they are.

## Say it in 2 minutes

Imagine a bank's support bot that sometimes quotes an old late fee. The team already has the right answers, and staff have marked which of two replies they prefer for each question. That marked data is called preference data, and DPO is a way to train a model on it directly.

Older methods, called RLHF, first train a reward model to score answers. Then they use reinforcement learning to make the model chase high scores, while keeping it from drifting too far from where it started. That loop is complex and can be unstable. DPO skips the scorer and the reinforcement learning. Its loss is a simple score: it mostly lowers the odds of the rejected answer and lifts the preferred one, measured against a frozen copy of the starting model. A setting called beta controls how tightly the model is held to that copy: a higher beta keeps it closer to its start.

The trade-offs are what an interviewer will test. DPO is simpler to implement and train. The DPO paper says DPO does as well as or better than existing methods, and that it beats RLHF built on PPO, a common reinforcement learning method, at controlling sentiment. But DPO learns what the labellers preferred, including their mistakes. OpenAI's guide also suggests a supervised step first, training on good answers before the preference step. OpenAI is winding down its fine-tuning platform, so treat that guide as one vendor's dated example, not a standing rule.

So my answer is this: DPO aligns a model with preferences from pairs of answers, without a reward model. I would check the pairs carefully, measure the bot's wrong-fee rate before and after, and keep a person reviewing anything that touches money.

## What is DPO, in plain words?

A language model can write fluent text. Alignment is the work of making its answers match what people actually want, such as correct facts, a clear tone and a safe refusal when needed. DPO is one way to do that.

DPO takes pairs of answers to the same prompt. A person has picked the better one, and training nudges the model toward the kind of answer that was picked.

Think of a new hire at a bank's call centre who learns from a senior colleague's red pen. The senior does not write a manual of scores. They mark two draft replies to the same customer, one better than the other, and the new hire adjusts. Here, a support bot gets two replies to a late-fee question: one with the current fee, one with last year's. The labeller picks the current one, and that pick is the training signal.

- **Preference pair:** Two answers to the same prompt, with one marked as the one people prefer.
- **Reward model:** A separate model that scores answers. RLHF needs one, DPO does not.
- **Reference model:** A frozen copy of the starting model, used as the anchor during training.
- **RLHF:** Reinforcement learning from human feedback: a reward model plus a reinforcement learning loop.

## How does DPO learn from a pair of answers?

Each training update uses a batch of pairs, plus the frozen reference copy. The diagram follows one pair through the update, and the training compares how each copy treats the two answers.

*Diagram, How one preference pair trains the model: One pair goes to two copies of the model: the one being trained and a frozen reference. The margin compares how each treats the two answers. Training moves the model so the preferred answer gains ground.*
1. The pair goes to the model being trained.
2. The same pair goes to the frozen copy too.
3. The trained model's view of both answers goes into the margin.
4. The reference's view joins it, so the update stays close to the start.
5. Training mostly lowers the rejected answer's odds, and lifts the preferred one's.

DPO's loss is built from that margin. If the trained model prefers the good answer more than the reference does, the loss falls. The beta setting controls how tightly the model is held to the reference. OpenAI's guide describes beta as a number that controls how strictly the new model adheres to its previous behaviour, versus aligning with the provided preferences.

> **Tip:** Asked what DPO trains on, say the pair. Asked what it removes, say the reward model and the reinforcement learning loop.

## How is DPO different from RLHF?

- **RLHF: Two moving parts.** A reward model is trained first. Then reinforcement learning tunes the model against it. Both need careful settings, and training can become unstable.
- **DPO: One training step.** The model learns straight from the pairs with a simple loss. No reward model, and no sampling loop during training.
- **The catch: Pairs decide the result.** DPO is only as good as its pairs. If labellers prefer the wrong answer, the model learns the wrong habit.

> "allowing us to solve the standard RLHF problem with only a simple classification loss" (Rafailov et al., the DPO paper)
>
> "In practice, this is typically achieved by suppressing the likelihood of dispreferred completions rather than by increasing the likelihood of preferred ones." (Hugging Face TRL documentation)

The DPO paper says its experiments show DPO can align models with human preferences as well as or better than existing methods. It reports that DPO matches or improves response quality in summarisation and single-turn dialogue. PPO is a common reinforcement learning method used inside RLHF, and the paper says DPO exceeds PPO-based RLHF at controlling sentiment.

## What does one DPO training step look like?

Here is a small, made-up example of the loss for one pair from the bank's bot. The numbers stand in for how likely the model finds each answer. We pretend the reference holds the starting view, and the training moves the answers apart.

```python
# One made-up preference pair from a bank's support bot. The numbers are made up too: each is how
# likely the model finds an answer, on a log scale. The reference is a frozen copy of the start.
import math

BETA = 0.1  # how tightly the model is held to its start: higher keeps it closer

def dpo_loss(model_good, model_bad, ref_good, ref_bad):
    # Did the model move toward the good answer more than the reference did?
    margin = (model_good - ref_good) - (model_bad - ref_bad)
    chance_right = 1 / (1 + math.exp(-BETA * margin))  # sigmoid: squashes to 0..1
    return -math.log(chance_right)  # small when the good answer is clearly ahead

ref_good, ref_bad = -12.5, -10.5  # the frozen reference's view of the two answers
print("Start, model equals reference:", round(dpo_loss(ref_good, ref_bad, ref_good, ref_bad), 3))
for shift in [1.0, 2.0]:
    # Training moves probability toward the good answer and away from the bad one.
    loss = dpo_loss(ref_good + shift, ref_bad - shift, ref_good, ref_bad)
    print(f"After training, shift {shift}: loss {loss:.3f}")
```

Output:

```text
Start, model equals reference: 0.693
After training, shift 1.0: loss 0.598
After training, shift 2.0: loss 0.513
```

At the start, the trained model equals the reference, so the margin is zero and the loss is about 0.69. Each shift makes the good answer more likely and the rejected one less likely, so the loss falls to about 0.60 and then 0.51. A real run has many pairs and thousands of steps, but the logic is the same.

### How would you choose between DPO and RLHF for a bank's bot?

The bank wants fewer wrong fee answers, and it has staff who can mark pairs. A sensible plan starts with the data and ends with a person checking the result.

1. **Start with good answers:** Supervised training on preferred responses before a DPO job can help, as OpenAI's guide suggests. OpenAI is winding down its fine-tuning platform, so check that your provider still runs DPO jobs before you plan around one.
2. **Check every pair:** Compare each pair with the current fee sheet. A pair that marks an old fee as preferred would teach the wrong fact.
3. **Train with a careful beta:** Hold back some pairs for testing, and try more than one beta value rather than trusting the first run.
4. **Measure, then keep a person in the loop:** Count wrong fee answers before and after. Keep human review for anything that touches money or a customer's account.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] A plain definition: learn from pairs of answers, one preferred, one rejected.
- [ ] What it removes: the reward model and the reinforcement learning loop in RLHF.
- [ ] The reference model: a frozen copy that anchors the update.
- [ ] The beta setting: how strictly the model keeps its old behaviour.
- [ ] The limit: it is only as good as its pairs, and the data needs checking.
- [ ] Practical steps: a supervised start, clean pairs, held-out tests.

**Common traps**

- Trap: "DPO always beats RLHF." Better: The DPO paper says DPO performs as well as or better than existing methods on the tasks it tested. Results depend on the data and the task.
- Trap: "More pairs always means a better model." Better: Pairs only help when they are correct and cover the real cases. Noisy labels teach the wrong habit.
- Trap: "With no reward model, the data needs no checks." Better: Without a reward model, the pairs still decide the result, so check them before training.

## Can you spot the problem in the pairs?

**Spot the bad pair:** Your team is building DPO pairs for a bank's fee-answer bot. Which pair should not go into training?

A. Preferred: quotes the fee from the 2026 fee table. Rejected: a vague reply that sends the customer to the branch.
B. Preferred: quotes the 2024 late fee, which the bank has since changed. Rejected: the reply that quotes the 2026 fee table.
C. Preferred: says it is unsure and offers a call-back. Rejected: a reply that invents a fee.
D. Preferred: a short reply with the correct fee and a policy link. Rejected: a longer reply with the same fee and a typo.

**Answer:** B. DPO learns whatever the labellers preferred. Here the preferred answer is out of date, so the model would learn a wrong fact. Check every pair against the current source before training.

**Quick check:** A bank wants its support bot to prefer correct answers, and it has staff-marked pairs of answers. Which method learns straight from those pairs, without a separate reward model?

A. RLHF with a reward model and a reinforcement learning loop
B. DPO
C. Supervised fine-tuning on the best answers only
D. A longer system prompt

**Answer:** B. DPO trains directly on preference pairs with a simple loss. RLHF needs a reward model and a reinforcement learning loop. Supervised fine-tuning uses only good answers, and a longer prompt changes no weights.

## Can you answer these from memory?

**Flash cards**

- **What is DPO?** Direct Preference Optimization: training a model on pairs of answers, one preferred, one rejected.
- **What does it skip?** The separate reward model and the reinforcement learning loop that RLHF needs.
- **What is the reference model?** A frozen copy of the starting model. It anchors the update, so the model stays close to its start.
- **What does beta do?** Sets how strictly the model keeps its old behaviour. A high number is more conservative.
- **What is the main risk?** It learns from the pairs, so bad labels produce a bad model.
- **What often comes first?** A supervised step on good answers before DPO, as one vendor's guide suggests.

## Likely follow-up questions

- Q288 What is RLHF? https://designervenkat.online/interview/ai/what-is-rlhf
- Q289 What is a reward model? https://designervenkat.online/interview/ai/what-is-a-reward-model
- Q307 How do you collect preference data? (full answer coming)
- Q290 What is PPO in RLHF, simply? (full answer coming)
- Q294 How do you prepare a fine-tuning dataset? https://designervenkat.online/interview/ai/how-to-prepare-a-fine-tuning-dataset
- Q297 How do you spot overfitting during fine-tuning? https://designervenkat.online/interview/ai/how-do-you-spot-overfitting-during-fine-tuning
