Log inStart free
LESSON 12.07 · 6 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW

RLHF with PPO

Watch PPO tune a policy toward a reward model while a KL penalty holds it.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 2 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 12.07 · RLHF WITH PPOROUND 0 · MEAN SCORE 1.45 · KL 0.00
01
Stage 1 of 6 · RLHF loop
RLHF tunes the policy to raise the reward model's score. The policy starts as the reference policy.
Explain it simply

On the left you see 4 prompts, each with 4 answers. The number after each answer is its score from the reward model of lesson 12.06. The bar shows how likely the policy is to write that answer. At the start, each bar fills the dashed outline of the reference policy.

4 prompts with 4 answers each. Each answer shows its reward-model score and a bar for its chance under the policy, which equals the reference. The mean score is 1.45. A loop links the policy, the answers, the reward model and the PPO update.

prompts, answers, samplesscores, policy, advantage, ratio, log-ratio ureward model, clip bandwrong words, KL, negative advantagereference policy, unlabelled answers
answerscore rpolicy π (dashed: π_ref)12 + 3 =2Capital of France?3Opposite of hot?47 × 6 =✓Itis5.2.240.30✗6−0.740.20?51.700.35?Sure,itis6,thanks!2.380.15✓Sure!Paris.2.990.25✗IthinkitisRome.0.340.15?Paris1.700.45?Lyon,thanks.0.550.15✓Itiscold,thanks.3.530.25✗Cold.1.700.30?Warm,sure.0.550.15?Hot−0.740.30✓Sure,42.2.990.20✗Itis48,thanks.1.090.30?421.700.25?Ithinkitis48.0.340.25writesscoresadvantagesnew πKL penaltypolicy πanswersreward modelPPO updatereference π_refthe RLHF loopanswerscore rpolicy π (dashed: π_ref)12 + 3 =2Capital of France?3Opposite of hot?47 × 6 =✓Itis5.2.240.30✗6−0.740.20?51.700.35?Sure,itis6,thanks!2.380.15✓Sure!Paris.2.990.25✗IthinkitisRome.0.340.15?Paris1.700.45?Lyon,thanks.0.550.15✓Itiscold,thanks.3.530.25✗Cold.1.700.30?Warm,sure.0.550.15?Hot−0.740.30✓Sure,42.2.990.20✗Itis48,thanks.1.090.30?421.700.25?Ithinkitis48.0.340.25writesscoresadvantagesnew πKL penaltypolicy πanswersreward modelPPO updatereference π_refthe RLHF loop
Toy: 4 prompts, 4 answers each, 40 PPO rounds
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
max⁡θ Ey∼πθ[r(x,y)]−β KL(πθ ∥ πref)\max_{\theta}\ \mathbb{E}_{y\sim \sy{pi}{out}{\pi_\theta}}\big[\sy{r}{out}{r(x,y)}\big] - \sy{b}{param}{\beta}\,\mathrm{KL}\big(\sy{pi}{out}{\pi_\theta}\,\|\,\sy{ref}{out}{\pi_{\text{ref}}}\big)
E[r]=1.45, KL=0, β=1\mathbb{E}[r] = 1.45,\ \mathrm{KL} = 0,\ \beta = 1

Raise the mean score, minus β times the distance from the reference.

Common mix-ups

MYTHPPO should push the policy to the highest-scoring answer.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With β 0 and the clip at 0.2, which answer does prompt 1 favor?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 2 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.