Skip to main content
This section explains PPO using the simplest possible environments:
  1. Single-state, two-action system
  2. Two-state trajectory system
The goal is conceptual clarity: understand why PPO exists and what clipping does.

1. From REINFORCE to PPO

REINFORCE update: J(θ)=E[R(τ)logπθ]\nabla J(\theta) = \mathbb{E}[R(\tau) \nabla \log \pi_\theta] Problem:
  • Updates can be too large
  • Policy may collapse or diverge
PPO introduces a trust region approximation using probability ratios.

2. PPO Objective

Define the probability ratio: rt(θ)=πθ(atst)πold(atst)r_t(\theta) = \frac{\pi_\theta(a_t|s_t)}{\pi_{old}(a_t|s_t)} PPO objective: L=min(rtAt,clip(rt,1ϵ,1+ϵ)At)L = \min( r_t A_t, \text{clip}(r_t, 1-\epsilon, 1+\epsilon) A_t ) Interpretation:
  • If policy changes too much → clip it
  • Prevents overly aggressive updates

3. Single-State Example

Policy: π(a1)=θ,π(a2)=1θ\pi(a_1)=\theta, \quad \pi(a_2)=1-\theta Reward:
  • a1a_1 → 1
  • a2a_2 → 0
We compare PPO dynamics with REINFORCE intuition.
Output from cell 2 Output from cell 2 Output from cell 2 Output from cell 2

Interpretation

  • Ratio shows how much policy changed
  • Clipping caps updates
  • Learning is smoother than raw policy gradient
Key idea:
PPO limits how far the new policy can move from the old one.

4. Two-State Example (Credit Assignment + PPO)

Now we introduce a trajectory:
  • action in state 1
  • action in state 2
  • reward depends only on state 2
Same reward is applied to both steps.
Output from cell 3 Output from cell 3 Output from cell 3 Output from cell 3

5. Final Interpretation

PPO modifies policy gradient in three ways:
  1. Uses probability ratios instead of raw log-prob gradients
  2. Introduces clipping to avoid large updates
  3. Maintains stability in high-dimensional policies (like LLMs)
Conceptually:
  • REINFORCE = push toward good trajectories
  • PPO = push, but not too far at once
This makes PPO suitable for LLM training where distributions are highly sensitive.