DPO Training
Direct Preference Optimization aligns models with human preferences without reward modeling.What is DPO?
DPO (Direct Preference Optimization) is a simpler alternative to RLHF. Instead of training a separate reward model, DPO directly optimizes the model to prefer chosen responses over rejected ones.Quick Start
Python API
Data Format
DPO requires preference pairs: a prompt with chosen and rejected responses.Multiple Turns
For multi-turn preference data, provide theprompt as a messages list. The prompt marks where the shared context ends — everything after is the diverging chosen/rejected trajectory.
Parameters
Beta
The beta parameter controls how much the model can deviate from the reference:0.01-0.05: Aggressive optimization (may overfit)0.1: Standard (recommended)0.5-1.0: Conservative (stays close to reference)
Reference Model
Whenmodel_ref is None (the default), DPO uses the initial model as the reference. You can specify a different one:
Training Tips
Use LoRA
DPO works well with LoRA:Lower Learning Rate
DPO is sensitive to learning rate:Fewer Epochs
DPO typically needs fewer epochs:Example: Helpful Assistant
Create a more helpful assistant:DPO vs ORPO
Collecting Preference Data
Human Annotation
- Generate multiple responses per prompt
- Have annotators rank responses
- Create chosen/rejected pairs
LLM-as-Judge
Next Steps
ORPO Training
Combined SFT + alignment
Reward Modeling
Train reward models