How far should reward feedback move the policy?

Collect experience, estimate advantages, then update the policy

1 · Interact using a snapshot

  • Copy the current policy to \(\pi_{\rm old}\).
  • Sample a batch. Save each \((s_t,a_t)\), its old action probability and its estimated advantage.

2 · Optimize using that batch

  • Keep \(\pi_{\rm old}\) fixed while changing \(\theta\).
  • The candidate policy now assigns different probabilities to the recorded actions.

Repeat. Refresh the snapshot and collect another batch. This alternates online interaction with batch optimization.

A probability ratio measures how much a sampled action changed

Goal: increase expected return \(J(\theta)\). Score candidate actions at states visited by the old policy.

Average the old policy’s advantages using the candidate’s action probabilities:

\[\sum_a\pi_\theta(a\mid s)\hat A(s,a) =\sum_a\pi_{\rm old}(a\mid s)\underbrace{\frac{\pi_\theta(a\mid s)}{\pi_{\rm old}(a\mid s)}}_{\rho(s,a)}\,\hat A(s,a).\]

  • East at the corner: its probability rises from \(0.5\) to \(0.6\), so each recorded east move gets weight \(0.6/0.5=1.2\).

\[\mathbb E_{a\sim\pi_\theta(\cdot\mid s)}[\hat A(s,a)] =\mathbb E_{a\sim\pi_{\rm old}(\cdot\mid s)}[\rho(s,a)\,\hat A(s,a)].\]

A parameter step can change the policy by very different amounts

At one state with two actions, let \(\pi_\theta(\mathrm{east}\mid s)=\sigma(k\theta)\), where \(k\) sets the sensitivity. Both panels use \(k=10\) and the same axis scales.

On one sigmoid curve a parameter step of 0.2 moves east probability from 27% to 73%. A step of 1.0 near saturation moves it from 99.3% to nearly 100%.

TRPO gives the policy a budget for changing its action distribution

\[\max_\theta L(\theta)=\widehat{\mathbb E}_t[\rho_t(\theta)\hat A_t] \qquad\text{subject to}\quad \bar D(\theta)=\widehat{\mathbb E}_t[D_{\rm KL}(\pi_{\rm old}\,\|\,\pi_\theta)]\le\delta.\]

One state, three actions

  • Each point gives two probabilities. The third is \(1-p_1-p_2\).
  • Green policies satisfy the KL budget \(\delta=0.08\). The boundary has KL exactly \(\delta\).
  • If action 1 has the highest advantage and the others tie, move right as far as the budget permits.

Three-action probability simplex with the old policy, a shaded forward-KL region and the feasible update maximizing action one probability.

PPO stops rewarding an excessive change in the favored direction

PPO uses a simpler heuristic for cautious updates. Ordinary gradient ascent optimizes a clipped surrogate in place of the KL-constrained solve. For each sample, maximize the smaller of two contributions: \[\min\!\left(\rho_t\hat A_t,\; \operatorname{clip}(\rho_t,1-\epsilon,1+\epsilon)\hat A_t\right).\]

  • Positive advantage: extra credit stops above \(1+\epsilon\).
  • Negative advantage: extra credit stops below \(1-\epsilon\).
  • Average these contributions over the sampled batch.

Clipping the objective does not clamp the policy probabilities

  • The optimizer changes shared parameters, so other samples can still move this action’s probability.
  • Clipping supplies neither a hard ratio bound nor guaranteed improvement in true return.
  • Check the size of policy changes and evaluate fresh trajectories.

A cautious update cannot repair a reward that measures the wrong goal.

GRPO uses group-relative feedback instead of a learned critic

Group Relative Policy Optimization (GRPO) · DeepSeekMath, outcome supervision.

For one prompt, sample responses with the rollout policy. Score each completed response and compare it with its group: \[\hat A_i=\frac{r_i-\bar r}{\sigma_r},\qquad \sigma_r>0.\]

  • Above-average outcomes receive positive relative feedback.
  • Below-average outcomes receive negative relative feedback.
  • This group comparison replaces a separately learned value baseline in this formulation.

A mixed-success group produces a relative learning signal

One question, many sampled answers. Correct earns \(1\) and wrong earns \(0\).

What tells the policy which answers to favor?

  • Scores \([1,1,0,0]\) give mean \(0.5\) and standard deviation \(0.5\).
  • Correct: \((1-0.5)/0.5=+1\). Wrong: \((0-0.5)/0.5=-1\).
  • All correct or all wrong: every score ties. The rewards give no direction for improvement.

How often do we get a mix?

For \(n\) independent answers, each correct with probability \(p\), \[P(\text{mixed group})=1-(1-p)^n-p^n.\]

At 10% accuracy on this question:

  • 10 answers: expect 1 correct; 65% chance of a mix.
  • 20 answers: expect 2 correct; 88% chance of a mix.

Larger groups help only if the starting policy can already produce a correct answer.

GRPO puts group-relative feedback into a clipped policy objective

For response \(i\), state \(s_{i,t}\) is the prompt and prefix; action \(a_{i,t}\) is the next token. Its \(T_i\) tokens share the response’s score \(\hat A_i\).

\[\rho_{i,t}(\theta)=\frac{\pi_\theta(a_{i,t}\mid s_{i,t})}{\pi_{\rm old}(a_{i,t}\mid s_{i,t})}.\]

Maximize, for a sampled group of \(G\) responses: \[\widehat J_{\rm GRPO}(\theta)=\frac1G\sum_{i=1}^{G}\frac1{T_i}\sum_{t=1}^{T_i} \left[\min\!\left(\rho_{i,t}\hat A_i,\;\operatorname{clip}(\rho_{i,t},1-\epsilon,1+\epsilon)\hat A_i\right)-\beta d_{i,t}\right].\]

  • Clipped term: favor tokens in relatively better responses, using the PPO rule.
  • \(d_{i,t}\): sampled KL penalty against a reference policy; \(\beta\) sets its strength.

The rollout policy and reference policy serve different purposes

Policy Question it answers
Trainable \(\pi_\theta\) What will we sample after this update?
Rollout \(\pi_{\mathrm{old}}\) How likely was this token when we collected it?
Reference \(\pi_{\mathrm{ref}}\) Which behavior anchors the regularization?

The original GRPO objective adds a penalty for divergence from the reference policy. That is separate from clipping ratios against the rollout policy.

The three methods make different choices about feedback and update size

Method Feedback for a sampled action What governs the update?
TRPO Estimated advantage, often from a critic Optimize a surrogate within an average KL budget
PPO-Clip Estimated advantage, often from a critic Clip favorable changes to the sampled surrogate
GRPO Score relative to other responses to this prompt Clip token ratios and penalize divergence from a reference

Practical tradeoff. GRPO avoids fitting a separate critic and needs several scored responses per prompt. Tied scores carry no within-group preference.

Better reward is evidence to test against the real task

Use fresh trajectories to test whether the update improves expected return. In Gridworld:

  • Compare discounted returns from the same starting squares.
  • Check whether gains persist on rarely visited squares.
  • Count environment interactions used to learn each policy.

The same question applies to a language model. Does a higher training reward translate into better answers on fresh questions?

RL can improve a language model after pretraining

Post-training adapts a pretrained model to tasks such as answering math questions.

  1. Sample several answers to a training question and score them.
  2. Update the model to favor better answers. DeepSeekMath used GRPO for this step.
  3. Evaluate on held-out questions to see whether the answers improve.

What if answering a question requires opening a file or running a calculation? Now the model must choose an action and use what comes back.