![This diagram visualizes how PPO’s clipped objective constrains the policy update using the probability ratio. Updates are unclipped in the trust region [1 - ε, 1 + ε], while ratios outside this band are clipped to limit overly large probability changes and stabilize learning.](https://aiml.com/wp-content/uploads/2026/01/PPO_cover.png)
Source: AIML.com Research
How to Train Agents Without Breaking Them?
In reinforcement learning, an agent learns a policy, its action-selection behavior, and training works by repeatedly updating that policy from experience. The catch is that each update changes the agent’s behavior, which also changes the data it will collect next. If one update is too large, the policy can shift abruptly, the agent starts visiting different states and taking different actions than before, and the next batch of trajectories no longer matches what the update “expected.” That hurts data quality (the experience becomes less useful for the skill you were trying to refine) and corrupts the learning signal (the gradient/advantage you compute from that experience becomes noisy or misleading), which can spiral into more bad updates.
Imagine you are training a dog not to jump on the bed. In RL terms, the dog’s “policy” is its habit when it sees the bed, a “policy update” is how that habit changes after feedback, and “rewards” are treats or attention. If you leave for a week and a caretaker accidentally gives treats whenever the dog jumps on the bed, the dog’s habit quickly shifts toward “jumping is good.” During that week it practices the wrong behavior, and the treats provide a strong but misleading learning signal that reinforces it, so when you return, you are undoing a reinforced habit rather than correcting a small mistake.
This is exactly the kind of problem Proximal Policy Optimization (PPO) is designed to prevent. PPO limits how far the policy is allowed to move in a single update, like putting a speed limit on habit change. So a short burst of misleading feedback is less likely to overwrite what the agent had learned.

Source: AIML.com Research
Trust Region: How Does PPO Limit Updates?
To keep updates from becoming too large, PPO optimizes a clipped surrogate objective. The idea is to improve the policy, but stop rewarding changes once they exceed a small safe range (the “trust region”). This gives PPO its practical stability: learning continues, but extreme one-step updates become unattractive.
A natural question is why we use a surrogate objective instead of optimizing the true RL objective directly. The true objective is long-term reward, but it is hard to differentiate and optimize from finite, noisy trajectories, especially because every policy update changes the data distribution the agent will generate next. A surrogate objective is a practical training target we can compute from the current batch of experience that still pushes the policy in the right direction.
In our dog example, clipping is like making the dog’s habit change gradually: even if it gets an unusually large treat one day, its behavior shifts only a little. So a temporary period of rewarding bed-jumping does not prevent you from training the dog back to the right behavior.
The Clipped Objective in One Line
It combines three elements:
- The ratio : measures how much the new policy changes the action probability relative to old policy .
- The advantage : measures whether the sampled action was better or worse than the baseline expectation for that state (typically computed using an actor-critic setup).
- The clipping operator : caps the effective ratio inside a trust region.
PPO defines a small tolerance and treats the interval as the allowable local neighborhood for updates. When moves outside this band, PPO suppresses the incentive to push it further.

Source:J. Schulman, F. Wolski, P. Dhariwal, A. Radford, and O. Klimov, “Proximal Policy Optimization Algorithms”
In code, PPO computes both the unclipped and clipped surrogate terms and then takes the more conservative one:
surr1 = ratios * batch_advantages
surr2 = torch.clamp(ratios, 1.0 - clip_ratio, 1.0 + clip_ratio) * batch_advantages
policy_loss = -torch.min(surr1, surr2).mean()Here, surr1 is the unclipped term , and surr2 is the clipped term . The min(·)makes the update conservative: once the ratio would push beyond the clip boundary (in the direction that would increase the objective), PPO uses the clipped value instead, so there is no additional benefit from making the policy change even larger. The leading minus sign turns the maximization objective into a loss to minimize.
Ratio: How Much Did the Policy Change?
In our dog example, we said the dog has its own steady “sense of what’s right”, so its behavior should not change too much from one update to the next. In PPO, we measure this change with the . This ratio compares the new policy to the old policy by looking at the probability they assign to the same action in the same state. In other words, it tells us how much the update increased or decreased that action’s probability.
- If > 1, the action is assigned higher probability under the updated policy.
- If < 1, the action is assigned lower probability under the updated policy.
- If = 1, no change for action at that state.
Advantages: Where the Advantage Comes From?
In common PPO implementations, the advantage is computed using an actor – critic setup:
- Actor : the policy network used to select actions.
- Critic : estimates the state value and serves as the baseline.
The advantage is then constructed by comparing realized returns against the critic’s baseline:
- If > 0, the action performed better than expected increases its probability (subject to clipping).
- If < 0, the action performed worse than expected decreases its probability (subject to clipping).
Case Breakdown: What Happens for in Different Cases?
| Advantage (A) | Ratio (r) | Operation | Effect on update | Intuition |
|---|---|---|---|---|
| Positive (> 0) Action was good | r > 1 + ε | Clip | No additional gain beyond the clip bound | Avoid overconfidence |
| Positive (> 0) Action was good | r <= 1 + ε | Update | Increase the probability | Safe to improve policy |
| Negative (<0) Action was bad | r < 1 - ε | clip | No additional gain beyond the clip bound | Prevent collapse |
| Negative (<0) Action was bad | r >= 1 - ε | Update | Decrease the probability | Safe to penalize policy |
How does ratio clipping looks Like in Practice: Ratio Stability During Training

Source: AIML.com Research
The plot tracks the 95th percentile of the policy ratio across training updates,
where values near 1 mean the policy barely changed for the sampled actions, and large deviations indicate aggressive probability shifts. We focus on the 95th percentile to summarize the “large-change tail” without letting a single extreme outlier dominate.
The practical lesson is that clipping changes what the optimizer is rewarded for: without clipping, large ratios can keep improving the objective whenever the advantage agrees, so updates sometimes push probabilities far from the behavior policy (green spikes). With PPO, once the ratio approaches the boundary, further pushes stop providing extra objective gain, so extreme updates become unattractive. This reduces the distribution shift between the data used to compute the gradient and the rollouts collected afterward, making advantage estimates more reliable and producing steadier learning rather than sudden swings.
Summary
PPO is widely used because it directly targets a common instability in policy-gradient training: updates that change the policy too much in one step, shifting the data distribution and weakening the learning signal.
The clipped surrogate objective provides a pragmatic trust region effect. It allows policy improvement when supported by the advantage signal, while preventing excessive probability shifts that can trigger collapse. In actor-critic settings, the critic supplies the baseline needed to make those updates directionally meaningful and clipping keeps the resulting policy updates safely bound.
Video Explanation
- In this video titled “Proximal Policy Optimization | ChatGPT uses this” by CodeEmporium, you’ll learn how PPO works and the fundamental knowledge needed to understand it. The video also includes three small quizzes to help you test your understanding. (Runtime: 13min)
- “Proximal Policy Optimization Explained By Edan Meyer” provides a solid background on reinforcement learning and compares PPO to other algorithms like DQN and TRPO. It also briefly introduces PPO with KL-divergence, noting that it is less commonly used in the industry compared to the standard clipped version. (Runtime: 18min, the most relevant section explaining PPO mechanics, 08:30 – 13:30)
- In the video “Proximal Policy Optimization (PPO) – How to train Large Language Models“ by Serrano Academy, you will be walked through the mechanics of PPO using clear, illustrative examples. The most critical segment is from 33:00 to 37:00, where the core concept of clipping is explained in detail (Runtime: 4 mins starting at 33 mins)


