DPO (Direct Preference Optimization)
Summary
DPO is a fine-tuning method where the model learns from pairs of 'good/bad' responses. It is simpler and cheaper than classical RLHF, making it very popular.
What is it?
DPO (Direct Preference Optimization) is a method of fine-tuning a language model based on preferences. Instead of complex reinforcement learning, the model directly learns to increase the probability of good responses and decrease the probability of bad ones.
Why is it needed?
After SFT, the model can already respond in a certain format, but its responses do not always please people: sometimes too harsh, sometimes too long, and sometimes irrelevant.
To 'polish' the behavior, a preference-based learning phase is needed. The classical approach is RLHF, but it is complex: it requires a separate reward model and reinforcement learning.
DPO solves the same problem more simply.
How does it work?
The dataset for DPO consists of triples:
| Request | Good Response | Bad Response |
|---|---|---|
| Explain what a token is | Simple explanation with an example | Too academic explanation |
| Write a polite refusal | Polite and warm response | Abrupt and dry response |
| Help with code | Solution with explanation | Only code without explanation |
During training, the model:
- receives both responses;
- increases the probability of the chosen good response;
- decreases the probability of the rejected bad response.
Why is DPO popular?
- Simpler: no separate reward model is needed.
- Cheaper: fewer computations and data.
- More stable: no unstable reinforcement learning.
- Works well with LoRA and QLoRA on regular hardware.
Limitations
- quality depends on preference labeling;
- bad or contradictory 'better/worse' pairs can harm the model;
- does not replace SFT — usually DPO is done after it.