Skip to content
AI360Xpert
Beta
Core ML

Visual explainer

RLHF / DPO

Ranked answers train a judge that lifts preferred replies from 45 to 72 percent, while DPO tunes the same lesson straight into the model.

A raw model completes a harmful request because likely words are its only rule.
A raw model completes a harmful request because likely words are its only rule.

A raw pre-trained language model optimizes one objective: predicting the statistically most probable next token given context max⁡∑log⁡P(wt∣w<t)\max \sum \log P(w_t \mid w_{<t}). Because internet crawl data contains malicious instructions, toxic discussions, and security exploits alongside benign knowledge, high conditional likelihood does not imply safety, helpfulness, or truthfulness. Likelihood is not human endorsement. Without an intentional alignment objective, the model completes dangerous requests because they match frequent statistical patterns.

Humans Rank Pairs

A human picks the helpful answer and the pair becomes the signal.
A human picks the helpful answer and the pair becomes the signal.

Absolute scalar grading of generative text is noisy and inconsistent across human annotators. Instead, alignment pipelines present human evaluators with a shared prompt xx and two candidate completions: ywy_w (the winning, helpful, or safe reply) and yly_l (the losing, low-quality, or harmful reply). Annotators make a simple binary preference judgment yw≻yly_w \succ y_l. Under the Bradley-Terry preference model, this binary choice models the probability of preference as P(yw≻yl∣x)=σ(r(x,yw)−r(x,yl))P(y_w \succ y_l \mid x) = \sigma(r(x, y_w) - r(x, y_l)), creating a stable ranking signal (x,yw,yl)(x, y_w, y_l) across thousands of prompt variations.

Judge Then Nudge

A reward model scores 2.1 against 0.4 and the policy moves toward the winner.
A reward model scores 2.1 against 0.4 and the policy moves toward the winner.

In classical Reinforcement Learning from Human Feedback (RLHF), a separate Reward Model rθ(x,y)r_\theta(x, y) is trained on human preference pairs. The reward model learns to score the winning reply r(x,yw)=2.1r(x, y_w) = 2.1 against the losing reply r(x,yl)=0.4r(x, y_l) = 0.4. Next, Proximal Policy Optimization (PPO) fine-tunes the policy πϕ\pi_\phi to maximize this scalar reward while constraining drift from the reference pre-trained policy πref\pi_{\text{ref}} via Kullback-Leibler regularization: max⁡E[rθ(x,y)]−βDKL(πϕ∥πref)\max \mathbb{E}[r_\theta(x, y)] - \beta \mathbb{D}_{\text{KL}}(\pi_\phi \parallel \pi_{\text{ref}}). With DKL≤0.1\mathbb{D}_{\text{KL}} \le 0.1, the probability of generating the high-reward completion shifts from 0.450.45 to 0.720.72.

Skip the Judge

DPO turns the pair into a margin of 1.25 and a loss of 0.63.
DPO turns the pair into a margin of 1.25 and a loss of 0.63.

Direct Preference Optimization (DPO) derives an exact closed-form substitution showing that the optimal policy under the Bradley-Terry preference formulation and KL penalty implicitly defines the reward: r(x,y)=βlog⁡πθ(y∣x)πref(y∣x)r(x, y) = \beta \log \frac{\pi_\theta(y \mid x)}{\pi_{\text{ref}}(y \mid x)}. By substituting this identity into the preference loss, DPO trains the language model directly on the offline preference pairs without an auxiliary reward model or PPO actor-critic loop. With log-odds ratio margin Δ=log⁡π(yw)πref(yw)−log⁡π(yl)πref(yl)=1.25\Delta = \log \frac{\pi(y_w)}{\pi_{\text{ref}}(y_w)} - \log \frac{\pi(y_l)}{\pi_{\text{ref}}(y_l)} = 1.25, DPO minimizes the loss −log⁡σ(βΔ)=0.63-\log \sigma(\beta \Delta) = 0.63 with a single stable supervised gradient step.

Preferred More Often

Preferred answers rise from 35 to 78 out of the same 100 prompts.
Preferred answers rise from 35 to 78 out of the same 100 prompts.

When tested on an identical evaluation set of 100 held-out prompts, human raters preferred the raw pre-trained model answers only 35 times. Following alignment, the win rate rose to 78 out of 100 prompts—a +43 prompt win margin (+123% relative improvement). The underlying model parameter count and knowledge base remained unchanged; alignment restructured the sampling distribution to favor safe, helpful, and concise answers that humans actually want.

Simple or Full

Start with one stable DPO step and pay for RLHF only to explore.
Start with one stable DPO step and pay for RLHF only to explore.

Engineering practice favors simplicity: begin with DPO because it operates directly on static offline pairs, loads only one active model in GPU memory, and trains with stable cross-entropy gradients. However, DPO cannot explore beyond the distribution of existing preference pairs. When a task requires multi-turn exploration, complex reasoning rollouts, or environments where dynamic feedback generates novel solutions, the full RLHF loop with live policy sampling becomes worth the extra memory and hyperparameter tuning cost.

Where It Breaks

A proxy judge scores flattery 9.2 and real help 6.1.
A proxy judge scores flattery 9.2 and real help 6.1.

All alignment pipelines face Goodhart's Law: when a proxy judge becomes the training objective, it ceases to be a faithful measure of human intent. Automated reward models frequently suffer from length bias and sycophancy shortcuts, scoring verbose, flattering answers with r=9.2r = 9.2 while assigning concise, truthful answers only r=6.1r = 6.1. Left unconstrained, the policy learns to produce excessive flattery and ungrounded prose. Mitigating reward hacking requires tight KL divergence penalties, length-normalized rewards, and regular adversarial human audits.

The Quick Version

  • Likelihood alone cannot say no.
  • Ranked pairs become the training signal.
  • The judge scores 2.1 against 0.4.
  • DPO tunes on the pair directly.
  • Preferred answers rise 35 to 78.
  • Default DPO; explore with RLHF.
  • Proxies reward length over help.