liveBook · Manning

Proximal Policy Optimization

As explained in Reinforcement Learning from Human Feedback

PPO is a policy-gradient reinforcement-learning algorithm that constrains policy updates to remain near a reference policy.

Proximal Policy Optimization (PPO) is a policy-gradient algorithm that uses a clipped objective to discourage overly large policy updates. In reinforcement learning from human feedback (RLHF), it updates a language model using recently generated completions and estimated advantages, while a learned value function supplies a baseline for those estimates. section 6.1 section 6.2.7

PPO can reuse a batch for multiple gradient steps by comparing the current policy with the policy that generated it. The importance ratio ρ is the current probability of a sampled action divided by its probability under the rollout policy. The objective multiplies this ratio by the action’s advantage A, then takes the minimum of that term and a version whose ratio is clipped to [1 − ε, 1 + ε]. Maximizing the objective favors beneficial actions and disfavors harmful ones without rewarding unlimited movement in either direction. section 6.2.5

Equation 6.30
\[\label{eq:PPO_EQN_EXPECTED} \begin{aligned}[b] J(\theta) &= \mathbb{E}_{t}\left[ \min\left(\rho_t(\theta)A_t,\ \text{clip}(\rho_t(\theta),1-\varepsilon,1+\varepsilon)A_t\right) \right], \\[5pt] \rho_t(\theta) &= \frac{\pi_\theta(a_t\mid s_t)}{\pi_{\theta_{\text{old}}}(a_t\mid s_t)}. \end{aligned}\]

The expected surrogate objective defines the per-step ratio, advantage, and clipping interval. section 6.2.5

Clipping depends on the advantage

With ε = 0.2 and A = 2, a ratio of 1.3 gives an unclipped objective of 2.6 and a clipped objective of 2.4; the minimum is 2.4. With A = −2 and a ratio of 0.7, the minimum is −1.6 rather than −1.4. Clipping removes the incentive to push these ratios further in the favorable direction; it is not a hard bound on every policy change. section 6.2.5 section 6.4.2

For language models, the policy objective is computed per token. A value model predicts future return at each token, typically including reward adjustments such as a KL penalty. Generalized advantage estimation uses multistep prediction errors to estimate advantages; a simpler alternative uses Monte Carlo returns, with Aₜ = Gₜ − V(sₜ). The value model has its own training loss, separate from the policy loss. section 6.2.5 section 6.2.7

A practical PPO update follows this pipeline:

  • Generate completions with the rollout policy, score them, and subtract a per-token KL penalty from rewards. section 6.3.5
  • Compute masked returns and value predictions, then form and normalize detached advantages. section 6.3.5
  • Compute per-token ratios from new and rollout log probabilities. Minimize the maximum of the negative unclipped and clipped objectives, combine it with value loss, and mask completion tokens. section 6.3.5

The rollout policy in the ratio is not necessarily the fixed reference model used for the KL penalty. These provide different regularizers: clipping moderates updates relative to the rollout policy, while KL penalizes distance from the original policy. With just one gradient step per freshly sampled batch, clipping may not activate; multiple updates make it more consequential. Clip fraction measures ratios outside the interval, but does not mean all those samples have zero gradient. section 6.3.5 section 6.4.2

Compared with REINFORCE, PPO adds a learned value function and clipped importance ratios, increasing memory and implementation complexity. GRPO instead estimates advantages relative to groups of completions and removes the value function. PPO has also been used with binary correctness rewards for mathematical reasoning. section 6.2.11 section 6.6 section 7.3.1

How Reinforcement Learning from Human Feedback covers it

How deep it goes
Derives the clipped objective and elaborates per-token policy and critic losses, including a simpler Monte Carlo alternative to GAE.
Examples
Uses a per-token PPO loss implementation and reasoning systems trained with binary math-correctness rewards.
What you can do after
Evaluate and understand how clipping, value estimates, and KL penalties affect language-model policy updates.
How it connects
Connects policy gradients, importance sampling, value functions, generalized advantage estimation, KL divergence, REINFORCE, and GRPO.

Also explained in

Compare how 3 books explain Proximal Policy Optimization →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Reinforcement Learning from Human Feedback. The section links point to the parts of the book it draws on.