Policy Gradient Theorem
Definition
The Policy Gradient Theorem gives an unbiased, sampleable estimator for the gradient of the RL objective with respect to policy parameters — even though the distribution being averaged over depends on those very parameters. It rests on the score-function (log-derivative) trick and, crucially, makes the unknown environment dynamics drop out, so learning is model-free. It is the foundation of REINFORCE, actor-critic, and PPO.
Key math
Score-function trick — turn a gradient of an expectation into an expectation of a gradient:
Applied with , , and the trajectory factorization, every environment term (, transitions ) is -independent and vanishes:
giving the general form with a weight on each action’s score:
All choices of share the same expected gradient but differ in variance: total return (highest) → reward-to-go → baselined reward-to-go → → advantage (lowest). A state-dependent baseline is unbiased because the expected score is zero: .
Why it matters
Because the gradient flows only through , the reward can be non-differentiable, black-box, even human — exactly the RLHF/RLVR setting where reward is a learned reward model or a pass/fail verifier. For an LLM the autoregressive log-prob sum is the trajectory log-prob, so the policy gradient reuses the ordinary token log-probs. The huge vocabulary action space is why value-based methods fail and policy-gradient methods dominate LLM post-training.
Taught in
- 02-policy-gradients — full derivation: score-function trick, dynamics dropping out, the menu, baselines, and the LLM connection.
See also
- reinforce — the Monte Carlo policy-gradient algorithm
- advantage-function — the ideal weight
- actor-critic — learned baseline for the gradient
- ppo — trust-region wrapper around this estimator
- rlhf — where the reward is a learned model
- rl-for-llms