DPO Guide - Tinker Documentation

Direct Preference Optimization (DPO)

DPO trains a model to prefer chosen responses over rejected ones using a classification loss — no separate reward model needed.

Preference Data

chosen vs rejected

→

Reference Policy π_ref (frozen)

→

DPO Loss β-weighted

→

Aligned Model π_θ

The DPO Loss

Lθ=−Ex,y_chosen,y_rejected∼D[log⁡σ(βlog⁡πθ(ychosen∣x)πref(ychosen∣x)−βlog⁡πθ(yrejected∣x)πref(yrejected∣x))]

\mathcal{L}{\theta} = -\mathbb{E}{x, y_{\text{chosen}}, y_{\text{rejected}} \sim \mathcal{D}}\left[\log\sigma\left(\beta\log \frac{\pi_{\theta}(y_{\text{chosen}}|x)}{\pi_{\text{ref}}(y_{\text{chosen}}|x)} - \beta\log \frac{\pi_{\theta}(y_{\text{rejected}}|x)}{\pi_{\text{ref}}(y_{\text{rejected}}|x)}\right)\right]

Lθ​=−Ex,y_chosen​,y_rejected​∼D​[logσ(βlogπref​(ychosen​∣x)πθ​(ychosen​∣x)−βlogπref​(yrejected​∣x)πθ​(yrejected​∣x))]

DPO vs RLHF

DPO eliminates the need for a separate reward model by directly optimizing the policy. Simpler and cheaper than classical RLHF, but requires the base model to already be in-distribution with the preference data.

Available Datasets

Dataset Source Description
hhh Anthropic Helpful-Harmless-Honest pairwise preferences
helpsteer3 NVIDIA HelpSteer3 preference dataset
ultrafeedback UltraFeedback Binarized preference comparisons

Key Hyperparameters

Training Metrics

Learn More