Reinforcement learning for language models
KL-regularized RLHF, the π* optimum, token-level PPO, GRPO, and verifiable rewards.
From fixed weights to RL
Multi-agent systems built agents around a model whose weights never changed: prompts, tools, memory and structure did the learning. This section changes the weights. The tool is the policy gradient of Policy gradients and actor-critic; the policy is the language model of The language model as a policy, read at the token level: state , action the next token, reward when the response is complete. The NLP course’s instruction-tuning note introduced reward models, RLHF and DPO; this topic derives the objective those methods optimize and how PPO and GRPO approach it.
The KL-regularized objective and π*
Maximizing expected reward alone puts all mass on the best-scored response. That lands on what the reward model knows least about, kills diversity, and forgets pretraining.
Key idea. Maximize reward minus times KL from a frozen reference (usually the SFT model):
Rewriting yields optimum , worth . Large keeps the reference; small approaches plain reward max. Solving for and substituting into Bradley–Terry cancels and gives DPO on the policy alone. sums over every response, so PPO and GRPO approach by sampling.
Worked example with , : at , — answer 3 wins over the higher-scored answer 4 because of reference probability.
PPO for language models
The sequence log-ratio is a sum of token log-ratios. PPO therefore charges a KL penalty at every token and the reward-model score at the last:
Summed with , the return matches the bracket of . A value head predicts remaining return; GAE turns TD errors into advantages for the clipped objective. Four large models sit in memory: policy, reference, reward model, critic. Credit assignment is hard: only the last token carries .
Worked example: log-ratios , , score , values then , → advantages .
GRPO — the group as baseline
GRPO (Shao et al., 2024) drops the critic. Sample responses per prompt, standardize rewards within the group, give every token of response the same advantage
KL moves into the loss via with . All-right or all-wrong groups give zero advantage. With : mean , std , correct answers get , wrong .
DeepSeekMath-Instruct 7B with GRPO: GSM8K , MATH . Maj@K rose; Pass@K did not — RL sharpened answers the model could already produce.
Verifiable rewards
A learned reward is the weakest link: optimization finds where it is wrong. For checkable answers, RLVR replaces it with a program: boxed maths equality, unit tests in a sandbox, format rules. DeepSeek-R1-Zero used rule-based accuracy and format rewards alone after neural reward models were hacked at scale.
False negatives add noise; false positives are optimized. A lenient verifier that checks only the last token of a three-token answer can report pass rate while exact accuracy is . Agentic versions of this failure — editing the tests instead of the code — return in Training agents with reinforcement learning.
Overoptimizing the proxy
Optimizing a proxy too hard makes the true objective worse (Goodhart). Gao, Schulman and Hilton (2023): gold score rises then falls while the proxy keeps rising. Best-of- moves nats from the sampling policy (best-of-16 ). Defences: limit or stop early on a held-out eval the proxy does not see; retrain the reward on current samples; use a verifier wherever answers are checkable.
Limits and next
Outcome rewards are sparse; hard prompts teach nothing until the policy succeeds by chance; is a guess; writing and advice still need learned rewards.
Everything here trains better single responses. Next: reasoning models and test-time compute — let the chain grow under verifiable rewards, and treat tokens at inference as a resource next to training compute.
Check your understanding
The same questions as in Pulse. Answers are shared between modes.
Answers are saved on the server and tied to this browser until you sign in.