Policy Gradient

Policy gradient methods optimize a parameterized policy directly by estimating how changing changes expected return.

For a stochastic policy , the policy gradient theorem gives:

where is a return estimate from timestep .

The trajectory objective is:

where and is the total return. The log-derivative trick gives:

and for a policy-controlled trajectory:

A baseline can reduce variance:

Actor-critic methods use a learned value function as the baseline:

where is an advantage estimate.

Generalized advantage estimation uses temporal-difference residuals:

and:

This trades bias and variance through .

KL-Regularized Objective

Many post-training setups constrain the learned policy near a reference policy:

For language models, is a token and the trajectory is the generated response. The KL term prevents the policy from exploiting reward-model artifacts too aggressively.

This can also be read as a constrained optimization problem:

The penalty coefficient is a practical way to approximate or control this constraint.

PPO-Style Clipped Surrogate

For samples from an old policy, define:

The clipped objective is:

This limits large policy updates when the new policy diverges from the sampled distribution.

Key Ideas

  • Policy gradients can optimize non-differentiable rewards because the reward does not need to be backpropagated through the environment.
  • Variance control is central; baselines, advantage estimation, and clipping are practical stabilizers.
  • The policy can drift away from a useful reference unless constrained.
  • In LLM post-training, actions are generated tokens or trajectories, and rewards often come from a reward model or verifier.

Where It Fits

SettingStateActionReward
classical RLenvironment observationenvironment actiontask return
LLM post-trainingprompt and partial responsenext token or responsereward model/verifier score
tool-using agenttask state and historytool call or messagesuccess, cost, safety, verification
molecule generationpartial molecule/trajectoryedit, token, atom, bondproperty or constraint score

Policy gradient is attractive when the reward is non-differentiable, but sample efficiency and reward misspecification become central risks.

Practical Checks

  • What trajectory distribution produced the samples: current policy, old policy, or logged data?
  • Is there a KL constraint, clipping rule, or reference policy?
  • Are rewards normalized or shaped in a way that changes the intended behavior?
  • Does higher reward correspond to better external task success?
  • Is the reward model evaluated separately from the optimized policy?
  • Are KL, clipping, and entropy terms reported with coefficients?
  • Is the metric computed on policy samples or a filtered subset?
  • Does the agent exploit the evaluator, tool environment, or formatting rule?