AI ENGVisual Encyclopedia

MODULE 4: PREFERENCE & ALIGNMENT · SCENE 11

RLHF: Reward Models & PPO with KL Anchors

Training a reward model from pairs, then PPO's clipped objective, GAE, and the KL penalty tethering π to π_ref.

LOG-RATIOKL DRIFTρ = 0.30 (CLIPPED)
POLICY (TRAIN)REFERENCE (FROZEN)REWARD MODELVALUE (TRAIN)SURROGATE min(ρA, clip(ρ,0.8,1.2)A) = 0.241 (A = 0.8)KL PENALTY −β·KL = -0.100 — DRIFT RENT OK

Healthy PPO step: ratio inside the trust region, drift rent affordable.

TECHNICAL BREAKDOWNModule 4: Preference & Alignment

RLHF: PPO with a KL tether

With a trained reward model, PPO optimizes the policy to maximize reward — but an unconstrained optimizer will exploit every flaw in the reward model. The KL penalty against the frozen reference policy is what keeps alignment optimization honest.

Four Models in Memory

Policy (training), reference (frozen), reward model (frozen), value/critic (training). That quadruple memory bill is why PPO is expensive.

Clipped Objective

PPO clips the probability ratio to [1−ε, 1+ε] so one batch cannot move the policy far enough to escape the trust region.

GAE

Generalized Advantage Estimation blends multi-step TD residuals with parameter λ, trading bias against variance in the credit assignment.

MATHEMATICAL FORMULATION · PPO OBJECTIVE + PENALTY
L = E[ min( ρ·A, clip(ρ, 1−ε, 1+ε)·A ) ] − β·KL(π ‖ π_ref), ρ = π(a)/π_old(a)

The clip keeps updates local; the KL term pays a per-token rent for drifting from the reference policy. β is the dial between alignment gains and reward-model exploitation.

REAL-WORLD PRODUCTION ENGINEERING
  • InstructGPT used β around 0.01–0.1; too small and responses drift into reward-hacked degeneracy within a few hundred steps.
  • PPO at scale typically runs the reward model and reference policy on separate GPUs and batches rollouts — the pipeline is a mini distributed-systems project.