Skip to main content
Interactive AI Lesson 2 min

The Alignment Problem & Preference Optimization

Comparing SFT (Supervised Fine-Tuning), RLHF with PPO, and Direct Preference Optimization (DPO).

Live — computed in your browser
Yesz=4.284.3%
Noz=2.110.3%
Maybez=1.03.4%
Perhapsz=0.41.9%
Low temperature sharpens the distribution towards the highest-scoring token; high temperature flattens it, making unlikely tokens reachable. At T=0 the model becomes deterministic.

The Alignment Triad: Helpful, Honest, Harmless (HHH)

A raw base LLM trained only on internet text predicts the most probable continuation—which may be toxic, biased, or untruthful. Alignment steers models to follow user intent safely.


Evolution of Alignment Methods:

  1. SFT (Supervised Fine-Tuning): Training on curated (Instruction, Ideal Answer) pairs.
  2. RLHF (Reinforcement Learning from Human Feedback):
    • Humans rank multiple model responses (y_win > y_lose).
    • A Reward Model is trained to score responses.
    • PPO (Proximal Policy Optimization) optimizes the LLM policy against the reward model with a KL-divergence penalty.
  3. DPO (Direct Preference Optimization - Rafailov et al., 2023):
    • Derives a closed-form mathematical substitution that optimizes the policy directly on preference pairs without needing a separate reward model or complex reinforcement learning loops!
Example — text
DPO Loss Formulation:
L_DPO(pi_theta; pi_ref) = -E_{(x, y_w, y_l)} [ log sigma( beta * log( pi_theta(y_w|x) / pi_ref(y_w|x) ) - beta * log( pi_theta(y_l|x) / pi_ref(y_l|x) ) ) ]

Where:
- x: Input prompt
- y_w: Winning (preferred) response
- y_l: Losing (rejected) response
- pi_ref: Frozen reference policy model
- beta: Regularization parameter controlling deviation from reference
Knowledge Checkpoint

What major architectural advantage does Direct Preference Optimization (DPO) have over traditional RLHF with PPO?

Read to the end of the lesson