PPO (Proximal Policy Optimization) is a common way to run the RL part of RLHF. The practical story: sample answers with a policy, score them, update carefully for a few epochs, and keep the new model close to a reference model.
The last lesson said: raise probability when advantage is positive. PPO is a careful way to do that without the policy leaping into strange wording overnight.
Updating every step from fresh samples is expensive. A common PPO-style pattern:
Dog-on-a-leash picture:
| Step | What happens |
|---|---|
| Sample | Generate responses with the current / old policy |
| Score | Get rewards / advantages for those responses |
| Update | Improve the policy for a few epochs on that cached experience |
| Constrain | Keep behavior near the reference model (KL leash) |
You do not always need two live full copies updating at once — caching trajectories and reusing them is part of the efficiency story.
Tiny sketch (concept only):
# 1) sample once, reuse a few times
answers = old_policy.sample(prompts)
advantages = score_and_advantage(answers)
for epoch in range(few_epochs):
pg_loss = ppo_policy_loss(policy, answers, advantages)
kl = kl_divergence(policy, reference, answers) # how far from home
loss = pg_loss + kl_coef * kl # leash
loss.backward()
optimizer.step()
few_epochs on cached answers is the efficiency move: you do not resample a brand-new batch for every tiny update.
KL divergence measures how far one probability distribution has moved from another. In alignment:
If KL is over-tight, the model barely moves — almost no alignment progress. If KL is missing, fluent nonsense that “scores well” can win.
The reference is usually the SFT model you started from: the intern who already writes decent answers, before preference optimization.
Reward hacking means the model finds shortcuts that raise the score without truly solving the user’s need — for example, overly flattering text, empty verbosity, or patterns the reward model wrongly likes.
If the reward signal is imperfect, RL will exploit the cracks.
Same prompt, two “high score” answers:
The training loop only sees the number. If verbosity or sycophancy inflates the score, the policy learns that habit.
That is why later lessons still check human preference, not only the automatic reward.
PPO improves the policy on sampled answers with careful updates; KL limits drift; reward hacking is cheating the score instead of helping the user.