Chapter 6
Reinforcement Learning (Policy Gradients)
The main optimization family for pushing a model toward higher reward while trying not to let it drift too far from useful behavior.
The RLHF loop is policy optimization over text
A prompt enters the current policy, the model samples a completion, the completion gets scored, and that score drives a gradient update.
The key translation from classical RL is that the trajectory is a token sequence and the policy is an autoregressive language model.
Once you see that mapping, many RL concepts become much less mysterious.
REINFORCE, RLOO, PPO, and GRPO are different variance-control strategies
All of these algorithms are trying to answer the same question: how do we turn noisy sampled rewards into stable updates on a huge language model?
REINFORCE is the clean baseline, RLOO uses multiple completions to build a baseline, PPO adds clipped trust-region style control plus a value function, and GRPO normalizes rewards within a group.
The differences matter because RLHF is often bottlenecked by variance and instability more than by missing reward signal.
KL regularization is the governor
RL can improve reward quickly by moving the policy into strange regions. KL penalties keep the new policy near a reference model so the update stays behaviorally sane.
This is not a cosmetic term. It often determines whether the run improves or collapses.
A good mental model is that reward says where to go and KL says how recklessly you are allowed to get there.
As systems scale, orchestration becomes part of the algorithm
Large RLHF runs are not only about a loss function. They are also about queues, actor-learner splits, asynchronous rollout generation, and throughput constraints.
That engineering shape changes what algorithms are practical in real training systems.
For teaching purposes, the clean math is only half the story. The deployment system is the other half.
Review
5 quick checks
Questions with revealed answers.
1 What is the simplest way to describe RLHF policy optimization?
Sample completions from the current model, score them, and update the model to make high-scoring completions more likely.
2 Why do so many policy gradient variants exist in RLHF?
Because the core problem is turning noisy rewards on sampled text into updates that are stable enough for large language models.
3 What role does KL regularization play?
It restrains the policy from drifting too far from a reference model while reward optimization is happening.
4 How is PPO different from REINFORCE at a high level?
PPO adds extra control through clipping and typically a value function, making updates less brittle than plain REINFORCE.
5 Why is systems engineering part of the policy-gradient story?
Because rollout generation, actor-learner coordination, and asynchronous pipelines determine what is tractable at scale.