# What Is PPO in RLHF, Simply?

> What PPO is, how its capped steps and drift penalty fit into RLHF, and where newer methods differ, for your AI interview.

**In short:** PPO, short for proximal policy optimisation, is the reinforcement learning method that does the update step in RLHF (reinforcement learning from human feedback). It nudges a language model toward replies a reward model scores highly, in small capped steps, and keeps the model close to where it started.

AI and LLM interview question Q290, Fine-tuning and adaptation. Advanced, occasional (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/what-is-ppo-in-rlhf-simply

## Say it in 30 seconds

PPO stands for proximal policy optimisation. In RLHF it is the step that actually changes the model. The model writes replies, a reward model scores them, and PPO nudges the model toward the high scores. It moves in small steps, and a penalty stops it drifting far from where it started. Newer methods such as DPO avoid sampling fresh replies, but PPO is still the classic method to explain.

## Say it in 2 minutes

In RLHF, the language model is what reinforcement learning calls a policy. A policy is a set of settings that decides what the model writes next. Training changes those settings. PPO is the method that makes the change. Its name hints at the key idea: each change stays close to the last one. Schulman and colleagues proposed it in 2017.

Each round goes like this. The model writes replies to real prompts. The reward model gives each reply a score. PPO compares each reply with a baseline estimate for its prompt, and the gap is the advantage. It nudges the model toward the better ones. The clip limits how much one batch of replies can change the model. In RLHF, a drift penalty adds a second brake that keeps the model close to its starting version.

The limits matter in an interview. PPO needs fresh replies from the current model every round, which adds real cost, and it has several moving parts that can go unstable. Take a bank's support bot. If the scorer rewards long, sorry-filled replies, PPO can drift toward them, and the drift penalty and human review have to catch it.

PPO is the optimiser in RLHF. It changes the model with small capped steps and a drift penalty. I would check its replies with people, because a higher score does not prove a better bot.

## What is PPO, in plain words?

In RLHF (reinforcement learning from human feedback), the language model is a policy: a set of settings that decides what it writes next. Training changes those settings. PPO, short for proximal policy optimisation, is the method that makes that change safely. Proximal means near, so each update stays near the last one.

Think of a bank's quality team fixing a support script. They change a few lines, test them on real calls, and keep the change only if the scores go up. They never rewrite the whole script after one bad week. PPO works the same way on a model: small changes, a score check, then repeat.

Here is the real case behind it. A support bot answers fee questions. It writes four replies, and a reward model, a second model trained to score replies, gives each one a score. PPO raises the odds of the better replies and lowers the odds of the bad ones, but only by a capped amount, so one lucky batch cannot wreck the bot.

- **Policy:** The model's settings, seen as a rule for what it writes next.
- **Advantage:** How much better a reply turned out than the baseline the training expects for that prompt.
- **Ratio:** For each word the model writes, how much more or less likely the new model is to pick it than the old one.
- **Drift penalty:** A charge for moving too far from the model's starting version.

## Where does PPO fit into RLHF?

RLHF has three stages: people write good answers, people rank replies to train a reward model, and the model is then tuned against that reward model. PPO is the tool for the third stage. The InstructGPT paper from 2022 names it directly.

> "Step 3: Optimize a policy against the reward model using PPO." (InstructGPT paper, step 3)

*Diagram, One PPO round in RLHF: One round of PPO in RLHF. A question gets replies, the reward model scores them, and PPO nudges the model toward higher scores. The drift penalty keeps each nudge small, and the updated model starts the next round.*
1. A customer's question starts the round.
2. The four replies go to the reward model.
3. The scores feed the update step.
4. The nudge moves the model toward higher scores.
5. The penalty pulls the update back toward the start.
6. The next round samples from the updated model.

1. **Sample:** The current model writes several replies to real prompts.
2. **Score:** The reward model gives each reply a score, learned from people's earlier rankings.
3. **Compare:** Each score is set against a baseline estimate for its prompt. Above the baseline means a positive advantage.
4. **Update:** PPO nudges the weights toward the better replies, with the clip and the drift penalty holding the step back.

Then the loop starts again from the updated model. Each round needs fresh replies, which adds real cost to that stage.

## What do the clip and the drift penalty do?

The clip works on the ratio. Word by word, it compares how likely the new model is to write each word with how likely the old one was. If the ratio moves past a small range, PPO stops giving extra credit for the change. The PPO paper was submitted in July 2017. OpenAI's PPO post describes its variant as a novel objective function not typically found in other algorithms.

Schulman's paper says PPO keeps some of the benefits of trust region policy optimization (TRPO), but is much simpler to implement.

The clip version of PPO drops the separate KL penalty of the earlier variant. InstructGPT's RLHF setup added one back: a per-token KL penalty against the starting model. KL is a score for how different two models' outputs are, so the penalty charges the model for moving too far. In RLHF, this drift penalty is the second brake.

> "we add a per-token KL penalty from the SFT model at each token to mitigate over-optimization of the reward model." (InstructGPT paper, on the penalty)

The DPO paper describes the RL step as maximising a learned reward "without drifting too far from the original model". It also calls RLHF "a complex and often unstable procedure". The cost is the catch: PPO samples fresh replies every round, and DPO's paper says it avoids "eliminating the need for sampling from the LM during fine-tuning".

## What does the clip do to four bank replies?

Say the new model has changed how often it writes four replies, and the reward model rates each one against a baseline. The clip keeps the ratio in a small range, so a big jump earns less credit, and a big drop is not softened, because the clip keeps the larger penalty. The example uses one ratio per reply to keep the numbers small, and the numbers are made up.

```python
# A simplified PPO clip for a bank's support bot. Each reply has a ratio (how much
# more the new model likes it than the old one) and an advantage (how much better
# than its expected baseline, as the reward model rates it). The clip stops one update from earning
# extra credit for a big jump.
EPS = 0.2  # made-up clip range: the ratio is kept between 0.8 and 1.2

REPLIES = [
    ("Explains the fee, offers a review", 1.5, 1.0),
    ("Blames the customer", 1.4, -1.0),
    ("Quotes an old fee", 0.5, -0.8),
    ("Short polite reply", 1.0, 0.2),
]

def clipped(ratio, adv):
    # Keep the smaller value: a big gain is capped, and a big drop is never softened.
    clip_ratio = max(1 - EPS, min(ratio, 1 + EPS))
    return min(ratio * adv, clip_ratio * adv)

total = 0
for text, ratio, adv in REPLIES:
    value = clipped(ratio, adv)
    total += value
    print(f"{text}: ratio {ratio:.2f}, advantage {adv:+.1f}, objective {value:+.2f}")
print(f"Average objective: {total / len(REPLIES):+.2f}")
```

Output:

```text
Explains the fee, offers a review: ratio 1.50, advantage +1.0, objective +1.20
Blames the customer: ratio 1.40, advantage -1.0, objective -1.40
Quotes an old fee: ratio 0.50, advantage -0.8, objective -0.64
Short polite reply: ratio 1.00, advantage +0.2, objective +0.20
Average objective: -0.16
```

> **Tip:** In an interview, say the clip caps the credit for a change in one batch. Don't say it makes the reward model right. It only limits how fast the model can chase the scores.

### How would you stop a PPO-tuned bot from gaming its reward model?

Suppose the scores keep rising, but customers complain more and the replies grow long and fawning. The reward model has become the target, and the bot is gaming it. This failure has a name: reward hacking, and it is what the drift penalty and human review are there to catch.

1. **Check the goal, not the score:** Score a fixed set of real calls with people, and track complaints and resolution, not only the reward.
2. **Raise the drift penalty:** A stronger penalty holds the model nearer its start, which limits how far it can chase the scorer.
3. **Refresh the reward model:** Add new human rankings from recent calls, so the scorer stops rewarding the new habit.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] PPO is the optimiser in RLHF's third stage, in plain words.
- [ ] The loop: sample, score, compare with the average, update.
- [ ] The clip and the drift penalty, and what each one stops.
- [ ] The cost: fresh samples every round, and possible instability.
- [ ] Honest limits: a higher score can be gamed, so check with people.
- [ ] Newer options, such as DPO, and what they skip.

**Common traps**

- Trap: "PPO is the whole of RLHF." Better: It is one step. People's rankings of replies train the reward model first.
- Trap: "The clip makes the model always correct." Better: The clip only limits how far one update moves. It can't fix a bad reward model.
- Trap: "A higher reward score means a better bot." Better: Not always. The model can learn to please the scorer, so check replies with people.

## Can you spot the wrong step?

**Spot the wrong step:** Which sentence about PPO in RLHF is wrong?

A. PPO updates the language model, using scores from the reward model.
B. PPO trains the reward model on the pairs of ranked replies.
C. The clip stops one update from moving the model too far.
D. The drift penalty keeps the model close to its starting version.

**Answer:** B. Labelled pairs train the reward model in stage two. PPO comes after, in stage three, and only updates the language model.

**Quick check:** A bank's bot gets a higher reward score each week, but its replies grow longer and more fawning. What is the best first fix?

A. Train for more steps with the same setup
B. Check a sample of real calls with people
C. Raise the clip range so updates can go further
D. Remove the drift penalty so the model can learn faster

**Answer:** B. A rising score with worse replies means the scorer is being gamed. Checking real calls with people tests the real goal. A wider clip or no drift penalty lets the model chase the scorer harder.

## Can you answer these from memory?

**Flash cards**

- **What does PPO stand for?** Proximal policy optimisation.
- **Where does PPO fit in RLHF?** The third stage: it tunes the model against the reward model.
- **What is the clip for?** It caps the credit one update can earn, through the ratio.
- **What is the drift penalty?** A KL charge for moving too far from the starting model.
- **What is the main cost of PPO?** Fresh replies from the current model every round.
- **Newer method that skips the loop?** DPO, which solves RLHF with only a simple classification loss.

## Likely follow-up questions

- Q288 What is RLHF? https://designervenkat.online/interview/ai/what-is-rlhf
- Q289 What is a reward model? https://designervenkat.online/interview/ai/what-is-a-reward-model
- Q291 What is DPO? https://designervenkat.online/interview/ai/what-is-dpo
- Q292 What is RL from verifiable rewards? https://designervenkat.online/interview/ai/what-is-rl-from-verifiable-rewards
- Q241 What is reward hacking? https://designervenkat.online/interview/ai/what-is-reward-hacking
