Proximal Policy Optimization (PPO)

2 min read

PPO is the default policy gradient algorithm for practical RL, including RLHF.

The problem PPO solves: standard policy gradients can make destructively large updates that ruin the policy. Trust region methods (TRPO) constrain the update size but are complex.

PPO-Clip objective:

LCLIP(θ)=Et[min(rt(θ)A^t,  clip(rt(θ),1ϵ,1+ϵ)A^t)]L^{\text{CLIP}}(\theta) = \mathbb{E}_t\left[\min\left(r_t(\theta)\hat{A}_t, \; \text{clip}(r_t(\theta), 1-\epsilon, 1+\epsilon)\hat{A}_t\right)\right]

where rt(θ)=πθ(atst)πθold(atst)r_t(\theta) = \frac{\pi_\theta(a_t|s_t)}{\pi_{\theta_\text{old}}(a_t|s_t)} is the probability ratio and A^t\hat{A}_t is the GAE advantage.

The ratio rtr_t comes from off-policy reuse: rollouts are sampled once from πθold\pi_{\theta_\text{old}} and reused for several gradient steps, with rtr_t acting as an importance-sampling correction. Clipping keeps the approximation valid as long as πθ\pi_\theta hasn't moved too far from πθold\pi_{\theta_\text{old}}.

How clipping works:

  • If A^t>0\hat{A}_t > 0 (good action): rtr_t is clipped at 1+ϵ1+\epsilon → limits how much we increase the probability
  • If A^t<0\hat{A}_t < 0 (bad action): rtr_t is clipped at 1ϵ1-\epsilon → limits how much we decrease the probability
  • Typical ϵ=0.2\epsilon = 0.2

The four cases (clipping is asymmetric — it only stops you when already moving the way the advantage points):

  • rt>1+ϵ, At>0r_t > 1+\epsilon,\ A_t > 0 → use (1+ϵ)At(1+\epsilon)A_t, gradient 0: stop pushing an already-boosted good action further
  • rt<1ϵ, At<0r_t < 1-\epsilon,\ A_t < 0 → use (1ϵ)At(1-\epsilon)A_t, gradient 0: stop pushing an already-suppressed bad action down
  • rt>1+ϵ, At<0r_t > 1+\epsilon,\ A_t < 0 → use rtAtr_t A_t, gradient flows: still allowed to correct a bad action
  • rt<1ϵ, At>0r_t < 1-\epsilon,\ A_t > 0 → use rtAtr_t A_t, gradient flows: still allowed to recover a good action

Why PPO is the default:

  • Simple to implement (just a clipped objective, no constraint optimization)
  • Stable — prevents catastrophic policy collapses
  • Good sample efficiency with multiple epochs over the same batch
  • Works across diverse domains (games, robotics, LLM alignment)

In RLHF: PPO optimizes the LLM policy against a learned reward model, with a KL Penalty to prevent reward hacking.

See also: Actor-Critic Methods, Policy Gradient Theorem, RLHF Pipeline

Linked from