TL;DR
Policy gradient methods improve an agent's behaviour by nudging its action probabilities toward actions that turned out well. The catch is that a single batch of experience can suggest updates that are too large, and one bad step can wreck the policy. Trust-region methods fix this with a hard limit on how far the policy may move, but they need second-order machinery that is hard to build. PPO keeps the simple first-order update, and it clips the probability ratio between the new and old policy so that moving an action's probability far outside a small band earns no extra reward. The paper shows this beats the alternatives it compares on continuous control and learns faster than A2C and ACER on Atari (though ACER often ends higher), while needing only a few lines of change to a standard policy gradient implementation.
Where you'll see it: PPO is the default policy optimizer for many reinforcement learning systems, including robot control and the reinforcement learning stage of large language model fine-tuning.
The problem
Policy gradient methods were simple and general, but they were fragile. The paper's introduction names three contenders in 2017: deep Q-learning, vanilla policy gradients, and trust-region methods. The paper says Q-learning with function approximation fails on many simple problems and is poorly understood. Vanilla policy gradients had poor data efficiency and robustness. Trust-region policy optimization (TRPO) was reliable, but it was complicated. It solved a constrained optimization problem with conjugate gradients, and it did not work with architectures that have dropout or share parameters between the policy and the value function.
The question was whether an algorithm could match TRPO's data efficiency and reliability using only first-order optimization, so that it could be trained with ordinary minibatch SGD or Adam.
Key idea
Suppose an update changes an action's probability from to . Their ratio is 1 before the update. An advantage says whether the action was better than average. The useful signal is "make bigger when is positive", but only up to a point. PPO adds a clip: once moves beyond in the helpful direction, the objective stops rewarding further change. The paper takes the minimum of the clipped and unclipped objectives, so the result is a pessimistic bound: the policy is never credited for improvements that a large step would only fake.
flowchart LR A[Run current policy in parallel actors] --> B[Compute advantage estimates] B --> C[Build clipped surrogate loss] C --> D[K epochs of minibatch Adam on the same data] D --> E[Copy new weights to old policy] E --> A
The key difference from vanilla policy gradients is step D. Several epochs over the same batch are now safe, because the clip keeps the policy from drifting far from the one that collected the data.
The method
Policy gradient and its problem
The standard estimator is , where is an estimate of the Advantage Function at timestep . Implementations differentiate the loss to obtain this gradient. Taking several gradient steps on this loss with the same trajectory is not justified, and in practice it causes very large policy changes.
The TRPO surrogate
Let , so that . The conservative policy iteration surrogate is
TRPO maximizes this objective subject to a constraint on the average Kullback–Leibler Divergence between old and new policies. The paper notes that the penalty form is theoretically justified, but a single fixed works badly across problems, which motivates the constraint in TRPO and the adaptive variant below.
The clipped objective
The paper's main proposal is
with a hyperparameter, typically 0.2. The clip removes the incentive to push outside . Taking the minimum means the objective ignores the change in ratio exactly when that change would make the objective look better. The clipped objective agrees with to first order around and differs once the policy moves away from the old one.
- A > 0
- A < 0
The adaptive KL penalty
The paper also gives a penalty alternative. Optimize for several epochs. Then measure the average KL divergence . If , halve . If , double . The paper found it worse than the clipped objective, but it is a useful baseline.
Value function, entropy and the full loss
When the policy and value function share parameters, the paper combines three terms:
where is a squared-error value loss, and is an Entropy bonus that encourages exploration. The advantage estimates are usually built from a learned value function with Generalized Advantage Estimation (GAE), using the one-step error (here is the reward at step ; the paper writes it as , the same letter it uses for the probability ratio) and a truncated, exponentially weighted sum of these errors.
The algorithm
Each iteration, parallel actors run the current policy for timesteps. The advantages are computed, and then the surrogate is optimized for epochs with minibatch size , using SGD or, more often, Adam Optimizer. The old policy is then set to the new one.
Worked examples
Take and advantage . Compare the unclipped term with the clipped term , and keep the smaller.
- Ratio : unclipped , clipped . The minimum is , and the gradient is active.
- Ratio : unclipped , clipped . The minimum is .
- Ratio : unclipped , clipped . The minimum is , which is constant in . The gradient is zero.
- Ratio : unclipped , clipped . The minimum is , and the gradient is active, pushing back up.
Interpretation: once the ratio passes , the objective earns nothing more for making the action more likely in this batch. Below the gradient still flows and pulls the probability back toward the band.
Set and . Then an update measures an average KL of .
- Compare with the upper threshold: .
- , so the update was too large. Double the coefficient: .
- The next iteration uses the stronger penalty. If instead , then , so halves to .
Interpretation: the coefficient keeps the policy step near the target without a hand-tuned constant. The paper says this scheme is not sensitive to the factors 1.5 and 2.
Results
On seven MuJoCo robotics tasks, with one million timesteps each and 21 runs per setting, the clipped objective with scored 0.82 on the normalized average (random policy 0, best result 1). The unclipped objective scored , because it collapsed on the half cheetah task. The clip with scored 0.76 and with scored 0.70. The best adaptive KL setting scored 0.74, and the best fixed penalty scored 0.72.
Against other methods on continuous control, PPO was best on almost all of the MuJoCo tasks, ahead of TRPO, the cross-entropy method, A2C and A2C with trust region. The paper also trained a 3D humanoid to run, steer toward moving targets and get up while being hit by cubes.
On the Atari benchmark, over 49 games and three trials, PPO won the most games when scored by average reward across all of training (30 games, against 18 for ACER and 1 for A2C, with 0 ties). When scored by the last 100 episodes, which favors final performance, ACER won 28 games, PPO won 19, A2C won 1, and one game was a tie (Table 2). So PPO learned faster on average, while ACER reached higher final scores on more games.
Counting winners from the appendix's per-game table of mean final scores (Table 6, same last-100-episode metric) gives a slightly different split: ACER 27, PPO 19, A2C 1, and 2 ties. The difference is the game Pong, where Table 6 shows 20.7 for both ACER and PPO. Table 2 presumably uses unrounded scores and gives Pong to ACER, but the paper does not say. Table 2 is the number the paper reports, and the one-game gap does not change the conclusion.
The Atari runs used far smaller updates per batch than the MuJoCo runs: 3 epochs, horizon 128, 8 actors and clip parameter , where is annealed linearly from 1 to 0 (Table 5). The MuJoCo benchmark used 10 epochs, horizon 2048, minibatch 64 and Adam step size (Table 3).
Why it mattered
PPO became the default policy optimizer in much of applied reinforcement learning. Its appeal was that it asked little of the implementer: a standard policy gradient loop with a clipped loss, a few epochs per batch, and a value function. It also became the workhorse for reinforcement learning from human feedback, where a language model's outputs are the actions and a learned reward model scores them. Many later methods, including those used to fine-tune large language models, take PPO's clipped ratio as a starting point.
Reading guide
- Section 1, introduction. Needs Reinforcement Learning and Markov Decision Process. The three-way comparison of Q-learning, vanilla policy gradients and TRPO is the motivation.
- Section 2.1, policy gradients. Needs Policy Gradient and Advantage Function. Equations 1 and 2 are the baseline that PPO fixes.
- Section 2.2, trust regions. Needs Trust Region Policy Optimization (TRPO) and Kullback–Leibler Divergence. Equations 3 to 5 explain what PPO replaces with a clip.
- Section 3, clipped objective. Needs Importance Sampling, since the ratio reweights samples from the old policy. Figures 1 and 2 are the best intuition.
- Section 4, adaptive KL penalty. Needs Kullback–Leibler Divergence and Stochastic Gradient Descent. Read it as the alternative the clip replaces.
- Section 5, algorithm. Needs Generalized Advantage Estimation (GAE), Value Function, Entropy and Mean Squared Error. Algorithm 1 is the loop to implement.
- Section 6, experiments. Needs Proximal Policy Optimization (PPO) for the setup, and reads best with Table 1 open.
Check yourself
QuestionWhy does the clipped objective stop rewarding larger probability ratios once a positive advantage has been reached past the clip?Show answer
Above the upper clip, the clipped term is 1 plus epsilon times the advantage, which is a constant with respect to the new policy. The minimum of the unclipped and clipped terms is therefore the constant, so the gradient is zero. The objective only pays for the change until the probability has grown by a factor of about 1 plus epsilon, which keeps one batch from pushing the policy far away.
QuestionWith epsilon = 0.2 and advantage -1, what is the one-term objective at ratio r = 0.5, and is the gradient active?Show answer
The unclipped term is 0.5 times minus 1, which is minus 0.5. The clipped term uses clip(0.5, 0.8, 1.2) = 0.8, giving minus 0.8. The minimum is minus 0.8, which is the clipped term and is constant in r, so the gradient is zero. Interpretation: the action is bad, and the objective stops rewarding further decreases once the probability has fallen below 0.8 times its old value.
QuestionWhy does PPO take several epochs of minibatch updates on the same batch when vanilla policy gradients do not?Show answer
Vanilla policy gradients use the same gradient estimate from a batch, and repeated steps move the policy far from the one that generated the data, which can cause destructively large updates. PPO's clipped objective removes the incentive for large ratio changes, so the repeated steps stay near the old policy, and the batch can be reused for better sample efficiency.
QuestionA team is training a robot policy and sees the policy collapse after a few updates. The clip is set to 0.2. Name three things to check before changing the algorithm.Show answer
First, check the advantage estimates: a bad value function or a missing normalization of advantages can give huge or wrong advantages, which the clip alone cannot fix. Second, check the learning rate and the number of epochs K, since a very large step size or many epochs on a small batch can still move the policy too far, especially if the policy and value function share parameters without an entropy bonus. Third, if the average KL between old and new policy is logged, check whether it is drifting well beyond what a clip of 0.2 normally allows (the paper's Figure 2 shows a KL of about 0.02 at the best point of a typical update).
Sources
- John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, Oleg Klimov. Proximal Policy Optimization Algorithms. 2017. arxiv.org/abs/1707.06347
- John Schulman, Sergey Levine, Philipp Moritz, Michael Jordan, Pieter Abbeel. Trust Region Policy Optimization. 2015. arxiv.org/abs/1502.05477
- John Schulman, Philipp Moritz, Sergey Levine, Michael Jordan, Pieter Abbeel. High-Dimensional Continuous Control Using Generalized Advantage Estimation. 2015. arxiv.org/abs/1506.02438