Explain PPO in the RLHF context. Why is there a KL penalty against a reference model?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
Conceptual level (which is what's expected): in RLHF, the policy is the LLM; an "action" is emitting a token, an episode is generating a full response, and reward comes from the reward model, usually assigned at the end of the sequence. PPO (proximal policy optimization) is a policy-gradient method whose defining feature is conservative updates: it optimises a clipped surrogate objective that limits how far the new policy's probability ratios can move from the sampling policy in a single update, so you can safely take several gradient steps per batch of expensive generations without the policy collapsing. In practice it also brings a learned value function (critic) and advantage estimation (GAE) to reduce gradient variance. The loop: sample responses from the current policy → score with the RM → compute advantages → clipped policy update → repeat.
Full worked answer with diagram
Conceptual level (which is what's expected): in RLHF, the policy is the LLM; an "action" is emitting a token, an episode is generating a full response, and reward comes from the reward model, usually assigned at the end of the sequence. PPO (proximal policy optimization) is a policy-gradient method whose defining feature is conservative updates: it optimises a clipped surrogate objective that limits how far the new policy's probability ratios can move from the sampling policy in a single update, so you can safely take several gradient steps per batch of expensive generations without the policy collapsing. In practice it also brings a learned value function (critic) and advantage estimation (GAE) to reduce gradient variance. The loop: sample responses from the current policy → score with the RM → compute advantages → clipped policy update → repeat.
The KL penalty is a separate, RLHF-specific constraint: the objective is approximately
$$\max_\pi; \mathbb{E}{y\sim\pi}\big[r(x,y)\big] - \beta,\mathrm{KL}\big(\pi(\cdot|x),|,\pi{ref}(\cdot|x)\big)$$
where $\pi_{ref}$ is the frozen SFT model. It exists for two reasons:
- The RM is a proxy, not the truth. It's only accurate near the distribution it was trained on. Unconstrained optimisation drives the policy off-distribution into text the RM mis-scores - reward goes up, actual quality goes down (reward hacking). The KL term keeps the policy where the RM is trustworthy.
- Capability preservation. The reference model anchors fluency, knowledge, and diversity; without it the policy can degenerate (repetition, weird phrasings, entropy collapse) while "reward" climbs.
β sets the tradeoff: too high and the model barely changes; too low and you get hacking. Teams monitor the KL-vs-reward frontier during training and treat rising reward with exploding KL as a red flag, not progress. The KL is usually implemented per-token as $\log\pi(y_t) - \log\pi_{ref}(y_t)$ folded into the reward.
Worth sketching. it separates the PPO loop from the KL leash, which are two independent ideas people fuse.
flowchart LR
A["Policy"] -->|"sample responses"| B["Reward model scores them"]
B --> C["Advantages from<br/>critic and GAE"]
C --> D["Clipped policy update"]
D --> A
E["Frozen reference,<br/>the SFT model"] -->|"per-token KL penalty"| B
D --> F{"Reward rising,<br/>KL exploding?"}
F -->|"yes"| G["Hacking, not progress:<br/>raise beta or stop"]
What a good answer covers
- Conceptual level (which is what's expected)
- PPO (proximal policy optimization) is a policy-gradient method whose defining feature is conservative updates
- In practice it also brings a learned value function (critic) and advantage estimation (GAE) to reduce…
- The loop: sample responses from the current policy → score with the RM → compute advantages → clipped…
- The KL penalty is a separate, RLHF-specific constraint: the objective is approximately
Key terms: KL penalty · Capability preservation
In the glossary: RLHF · Reward model · PPO · KL penalty · SFT · Reward hacking
Interviewer follow-ups to expect
What do you monitor during a PPO run to catch failure early?
Why does PPO clip probability ratios instead of just taking a bigger learning rate?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep