MLCrack

    REINFORCEMENT LEARNING · INTERVIEW QUESTION

    Explain PPO (Proximal Policy Optimization). Why is it preferred over vanilla policy gradient?

    🔴 advanced · Policy Gradient Methods

    Hint: Think about the clipped surrogate objective and trust regions.

    Answer

    Vanilla policy gradient (REINFORCE) has high variance and can take destructively large steps.

    PPO's clipped surrogate objective:

    L=min⁡(rt(θ)A^t,  clip(rt(θ),1−ϵ,1+ϵ)A^t)L = \min\left( r_t(\theta) \hat{A}_t, \; \text{clip}(r_t(\theta), 1-\epsilon, 1+\epsilon) \hat{A}_t \right)

    where rt=πθ(a∣s)πold(a∣s)r_t = \frac{\pi_\theta(a|s)}{\pi_{\text{old}}(a|s)} is the probability ratio and A^\hat{A} is the advantage estimate.

    Clipping removes the incentive for some excessively large updates in the surrogate objective. It does not constrain every ratio or guarantee stability; monitor realized KL and optionally stop epochs early.

    python
    from stable_baselines3 import PPO model = PPO('MlpPolicy', env, verbose=1, learning_rate=3e-4, clip_range=0.2, # epsilon n_epochs=10, batch_size=64) model.learn(total_timesteps=100_000)

    Benefits: simple implementation, good sample efficiency, works across many domains. PPO is used in RLHF for LLM alignment, robotics, and game AI.