Lesson 8.3advanced4 h

Alignment: RLHF, PPO, DPO, GRPO and Constitutional AI

Turning 'predict the next token' into 'be helpful, honest and harmless'

Pretraining produces a model that imitates the internet; alignment produces one that behaves the way people want. The methods — reward models, PPO, DPO, GRPO — are where the reinforcement learning of 4.11 Reinforcement learning essentials and the KL divergence of 1.9 Information theory: entropy, cross-entropy and KL divergence become the decisive tools of the field. They are also the engine of reasoning models (8.6 Reasoning models and test-time compute) and the reason evaluation (8.7 Evaluating LLMs) and safety (8.12 Safety, risks and responsible AI) are so hard: what gets optimized is a learned proxy for what we want.

You'll be able to

  • Explain why preference data is easier to collect than demonstrations and how a Bradley–Terry reward model is trained
  • Write the KL-regularized RLHF objective and explain the role of β and the reference model
  • Derive the DPO loss from the closed-form optimal policy
  • Describe GRPO and RL with verifiable rewards, and contrast them with PPO-based RLHF
  • State what alignment training does and does not guarantee

Key ideas

  1. Comparisons are easier to collect than demonstrations; a Bradley–Terry reward model turns them into a scalar score via P(y_w ≻ y_l) = σ(r_w − r_l).
  2. RLHF maximizes expected reward minus β·KL(π‖π_ref); the KL term prevents exploiting the reward model's errors.
  3. PPO-based RLHF needs four large models (policy, reference, reward, critic) and is prone to over-optimization and sycophancy.
Show 4 more key ideas
  1. DPO substitutes the closed-form optimal policy into the Bradley–Terry likelihood, so the partition function cancels and alignment becomes a classification loss on preference pairs.
  2. GRPO drops the critic by normalizing rewards within a group of sampled responses; with verifiable rewards it is the engine of reasoning models.
  3. Constitutional AI / RLAIF replace many human labels with model critiques guided by explicit principles.
  4. Alignment shapes behavior on-distribution; jailbreaks, reward hacking, sleeper agents and alignment faking show its limits.

Suggested path through this lesson