Summary
Policy gradient methods directly parametrize a policy and optimize by ascending the gradient of expected return:
This is the policy gradient theorem (Sutton et al., 1999).
Policy gradient methods are the foundation of modern continuous-control RL (SAC, PPO), of large-scale RL (AlphaGo’s policy net, OpenAI Five), and of LLM alignment (RLHF uses PPO). They are essential whenever:
- The action space is continuous (no easy ).
- A stochastic policy is desirable (exploration, multi-modal optimal policies).
- You can write a clean, differentiable policy parametrization.
REINFORCE
The simplest policy gradient (Williams, 1992):
where is the return-to-go from step .
Sample a trajectory by running the policy. For each step, compute and weight by the actual return. Backprop. Take a gradient step.
Pros: extremely general. Works for any differentiable policy. Cons: high variance. Return is a noisy estimate of expected return; gradient estimator dominates by random rollout luck.
Variance reduction: baselines
Subtract any state-dependent baseline from . Does not change the expected gradient (so no bias) but can drastically reduce variance:
A common baseline is the value function , leading to actor-critic. It is not generally the minimum-variance baseline. For one conditional score-function term, let . When the denominator is nonzero, the scalar baseline minimizing the estimator’s total conditional variance is
This equals only under additional conditions on the score-norm weighting. Treat the baseline as constant when differentiating the policy term.
Predict before revealing: a one-step policy chooses action 1 with probability 0.8, receives reward equal to its action, and has logit score action - 0.8.
Must baseline have less variance than baseline 0.2?
Compare the mean and variance separately
No. With baseline 0.8, the two gradient estimates are 0.04 and 0.64, with probabilities 0.8 and 0.2. Their mean is 0.16 and variance is 0.0576. With baseline 0.2, both actions give gradient 0.16, so variance is zero. Both baselines are action-independent and unbiased; that does not make their variances equal.
A positive return still suppresses an action when it falls below baseline
Reference drawing
A positive return still suppresses an action when it falls below baseline
Derivation
Actor-critic
Two networks:
- Actor . The policy.
- Critic . Value function estimator.
Use the critic as the baseline. Define the advantage . Update:
Critic is trained by TD: .
This is the basic A2C / A3C algorithm.
Generalized Advantage Estimation (GAE)
Instead of one-step or full-return advantages, use a weighted sum:
trades bias for variance. gives one-step TD; gives the full-return form, with terminal or truncation handling stated separately. A value such as 0.95 is a tuning choice, not a universal PPO requirement.
Trust regions and PPO
Naive policy gradient updates can drastically change the policy in one step, leading to collapse. Trust Region Policy Optimization (TRPO; Schulman et al., 2015) constrains the KL divergence between old and new policies. PPO (Schulman et al., 2017) replaces the constraint with a clipped surrogate objective:
with and typical.
PPO is used in control and some RLHF pipelines. Its clipped objective removes the incentive for certain sampled-action changes beyond the clipping boundary; it is not a hard constraint on policy ratios or KL.
Predict before revealing: old action probability is 0.1, advantage is 1, and clipping parameter is 0.2. Can new probability 0.9 have the same clipped objective as new probability 0.12?
Inspect the objective, not an imaginary constraint
Yes. The ratios are 9 and 1.2, but both clipped surrogate values are 1.2. A flat objective beyond the boundary does not make those policy parameters infeasible. Monitor ratios and KL; optional early stopping is a separate implementation safeguard, not a guarantee supplied by clipping.
Off-policy actor-critic
For sample efficiency in continuous control, use a replay buffer with importance sampling correction or Q-function critics. DDPG, TD3, SAC are the standard off-policy actor-critic algorithms. SAC adds a maximum-entropy bonus that encourages exploration.
Common pitfalls
- High variance. Test an action-independent baseline. Advantage normalization changes finite-batch estimates and scale; evaluate it rather than assuming every baseline or normalization must help.
- Insufficient exploration. An entropy bonus can help when appropriate; deterministic policies are not automatically a failure. For a minimized loss, rewards entropy.
- Reusing stale samples. PPO uses rollout-policy probabilities in its importance ratios, but clipping does not bound staleness or make arbitrary off-policy reuse valid. Collect fresh rollouts and inspect drift.
- Mismatch between rollout and learning. Record the behavior-policy version and log probabilities. Ratios require matching support and do not by themselves guarantee a safe update.
- Treating policy gradient as universally low-variance. It isn’t. Q-learning often has lower variance for discrete-action problems.
Related
- Q-learning. Value-based alternative.
- RLHF and DPO. PPO applied to LLM alignment.
- PPO. Algorithm-level details.