PPO Algorithm › The Clipped Objective

Michael BrenndoerferDecember 27, 20258 min read
Language AI HandbookAll chapters
Part 37 of 67Alignment and RLHF
Chapter 278PPO Algorithm › The Clipped Objective
Reading section 5 of 14 · The Clipped Objective · 8 minSection 5 of 14 · 8 min

Book contents

Section 5 of 14 · 8 min read

PPO Algorithm › The Clipped ObjectiveOne section · Sections in this chapter5 / 14 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

PPO's key innovation is straightforward: clip the probability ratio to remove incentives for excessive policy changes. Rather than imposing a hard constraint requiring complex optimization machinery, PPO modifies the objective function itself, so large policy changes provide no additional benefit. The clipping mechanism is self-limiting: once the policy has changed enough to fall outside the allowed range, the gradient signal turns off, and the optimizer cannot push the policy further in that direction.

Think of the clipped objective as a reward system with diminishing returns for policy changes. The policy earns credit for adjusting action probabilities in the direction indicated by the advantage, but only up to a point. Beyond the clip threshold, additional changes earn no extra credit. This is like an employer who rewards employees for working overtime, but only up to a cap: you can work as many hours as you want, but you only get paid extra for the first few hours of overtime. The cap prevents extreme behavior without eliminating the incentive entirely.

The clipped surrogate objective is:

LCLIP(θ)=Et[min⁡(rt(θ)At,clip(rt(θ),1−ϵ,1+ϵ)At)]L^{\text{CLIP}}(\theta) = \mathbb{E}_t\left[\min\left(r_t(\theta) A_t, \text{clip}(r_t(\theta), 1-\epsilon, 1+\epsilon) A_t\right)\right]

where ϵ\epsilon is a hyperparameter, typically set between 0.1 and 0.2, that defines the trust region width. This single parameter controls how much the policy can change in each update. Larger ϵ\epsilon allows more aggressive updates. Smaller ϵ\epsilon enforces tighter constraints and slower learning.

To understand precisely how clipping constrains the ratio, we need to examine the clip function itself. The clip function constrains the probability ratio to remain within the interval [1−ϵ,1+ϵ][1-\epsilon, 1+\epsilon], defined as:

clip(r,1−ϵ,1+ϵ)={1−ϵif r<1−ϵrif 1−ϵ≤r≤1+ϵ1+ϵif r>1+ϵ\text{clip}(r, 1-\epsilon, 1+\epsilon) = \begin{cases} 1-\epsilon & \text{if } r < 1-\epsilon \\ r & \text{if } 1-\epsilon \leq r \leq 1+\epsilon \\ 1+\epsilon & \text{if } r > 1+\epsilon \end{cases}

Each component of this piecewise function serves a specific purpose:

  • rr: the input value to be clipped; in PPO, this is rt(θ)r_t(\theta), the probability ratio
  • 1−ϵ1-\epsilon: the lower bound of the allowed range
  • 1+ϵ1+\epsilon: the upper bound of the allowed range
  • The function returns rr unchanged if it's within the bounds, otherwise returns the nearest bound

The key intuition is that this clipping removes the gradient signal when the ratio moves outside the trust region. Consider what happens during optimization: you want the optimizer to adjust parameters to increase the objective. If the new policy is already making an action much more likely, with a ratio greater than 1+ϵ1+\epsilon, or much less likely, with a ratio less than 1−ϵ1-\epsilon, than the old policy, clipping prevents the optimizer from pushing it even further in that direction. The clipped term becomes constant with respect to the parameters, meaning its gradient is zero, so there is no signal encouraging further movement in that direction.

This clipped ratio is then used in computing the clipped surrogate objective. Returning to the full LCLIP(θ)L^{\text{CLIP}}(\theta) formula and examining it in detail:

LCLIP(θ)=Et[min⁡(rt(θ)At,clip(rt(θ),1−ϵ,1+ϵ)At)]L^{\text{CLIP}}(\theta) = \mathbb{E}_t\left[\min\left(r_t(\theta) A_t, \text{clip}(r_t(\theta), 1-\epsilon, 1+\epsilon) A_t\right)\right]

Each component plays a specific role in creating stable policy updates:

  • LCLIP(θ)L^{\text{CLIP}}(\theta): the clipped surrogate objective that PPO maximizes
  • Et\mathbb{E}_t: expectation over all timesteps in the collected batch
  • min⁡(⋅,⋅)\min(\cdot, \cdot): takes the smaller of the two arguments (the pessimistic bound)
  • rt(θ)r_t(\theta): the probability ratio πθ(at∣st)πθold(at∣st)\frac{\pi_\theta(a_t|s_t)}{\pi_{\theta_{\text{old}}}(a_t|s_t)}
  • AtA_t: the advantage estimate at timestep tt
  • ϵ\epsilon: the clipping parameter, typically 0.1 to 0.2, that defines the trust region
  • clip(rt(θ),1−ϵ,1+ϵ)\text{clip}(r_t(\theta), 1-\epsilon, 1+\epsilon): constrains the ratio to the interval [1−ϵ,1+ϵ][1-\epsilon, 1+\epsilon]

Understanding the Clipping Mechanism

The min⁡\min operation is important. It selects the smaller of the unclipped and clipped objectives. This keeps a pessimistic (conservative) bound on the improvement. By always choosing the lower value, we prevent the optimizer from being overly optimistic about improvements that would require large policy changes. We will analyze both cases based on the sign of the advantage.

Case 1: Positive Advantage (At>0A_t > 0)

When an action is better than expected (positive advantage), we want to increase its probability. The unclipped objective's gradient pushes the policy to make this action more likely, but PPO limits the extent.

  • If rt(θ)>1+ϵr_t(\theta) > 1 + \epsilon: The clipped term (1+ϵ)At(1+\epsilon) A_t is smaller than rt(θ)Atr_t(\theta) A_t, since At>0A_t > 0 and 1+ϵ<rt(θ)1+\epsilon < r_t(\theta). The min⁡\min selects the clipped term (1+ϵ)At(1+\epsilon) A_t, which is constant with respect to θ\theta, so the gradient is zero and provides no incentive for us to increase the ratio further.
  • If rt(θ)≤1+ϵr_t(\theta) \leq 1 + \epsilon: Both terms are equal or the unclipped term is smaller, so normal optimization proceeds.

This means that once the probability ratio exceeds 1+ϵ1+\epsilon, the optimizer receives no additional reward for increasing it further. The policy has already been sufficiently encouraged to take this good action. Importantly, the policy can still take that action at a higher probability than the old policy, it just does not receive additional credit for pushing the probability even higher.

Case 2: Negative Advantage (At<0A_t < 0)

When an action is worse than expected (negative advantage), we want to decrease its probability. The unclipped objective's gradient encourages this, but PPO limits the extent:

  • If rt(θ)<1−ϵr_t(\theta) < 1 - \epsilon: Since At<0A_t < 0, multiplying by smaller values makes the product more negative. The clipped term (1−ϵ)At(1-\epsilon) A_t is larger (less negative) than the unclipped term rt(θ)Atr_t(\theta) A_t because rt(θ)<1−ϵr_t(\theta) < 1-\epsilon. The min⁡\min selects the more negative unclipped term. Since the clipped term (1−ϵ)At(1-\epsilon) A_t is constant, its gradient is zero and the objective becomes flat once rt(θ)r_t(\theta) drops below 1−ϵ1-\epsilon, preventing the policy from decreasing the probability further.
  • If rt(θ)≥1−ϵr_t(\theta) \geq 1 - \epsilon: Normal optimization proceeds.

This prevents the policy from becoming too averse to actions that happened to have negative advantage. Such actions might still be valuable in other states, and excessively penalizing them could harm overall performance. The clipping protects both ends: it prevents overconfidence about good actions and overpunishment of bad ones.

The following figure illustrates this behavior:

Out[6]:
Visualization
Line chart of the PPO clipped objective for positive advantage with the objective increasing linearly between red dotted clip bound lines at 0.8 and 1.2 and plateauing outside those bounds.
PPO clipped objective for positive advantage shows how clipping prevents overoptimization of good actions. The objective increases linearly as the probability ratio grows from 0.8 to 1.2, encouraging the policy to make good actions more likely. Beyond ratio 1.2, the objective plateaus and the gradient becomes zero, stopping further increases. This self-limiting behavior prevents the policy from becoming overly deterministic on actions that were good in the training batch but may not generalize.
Line chart of the PPO clipped objective for negative advantage with the objective decreasing linearly between red dotted clip bound lines and flattening outside those bounds.
PPO clipped objective for negative advantage shows how clipping prevents overpenalizing bad actions. The objective decreases linearly as the probability ratio drops from 1.2 to 0.8, encouraging the policy to make bad actions less likely. Below ratio 0.8, the objective plateaus and the gradient becomes zero, preventing excessive suppression of actions that were bad in this batch but may be valuable in other contexts.
The Key Insight

Clipping creates a "pessimistic bound" on the objective. When the policy tries to change too much, the objective flattens and provides no gradient signal to continue. This self-limiting behavior makes PPO stable without requiring the complex second-order optimization of TRPO. The min⁡\min operation is the mechanism: it always selects whichever value is more conservative, preventing the optimizer from exploiting large policy changes that might not generalize.