Why align? Next-token pretraining makes a model fluent, not necessarily helpful or
harmless1. RL vocabulary for LLMs1: the agent is the LLM itself, an action is
generating text (words, a chosen answer, a reply), the reward is usually a number scoring
how helpful, truthful or harmless the response is, and the policy is the agent's strategy,
updated to earn more reward. Reading the prompt is observing the state, and the weight
update is learning, not an action.
SFT: fine-tune GPT-3 on labeler-written demonstrations (supervised).
Reward model (RM): labelers rank K=4 to 9 outputs per prompt, giving
(2K) pairwise comparisons; a model with a scalar head learns to predict which
output is preferred.
RL: optimize the SFT policy against the RM score with PPO. Each episode is one prompt and
one response (a bandit), and a per-token KL penalty to the SFT model counters
over-optimization of the RM. PPO-ptx also mixes in pretraining gradients to limit
regressions on public NLP benchmarks.
The RM loss depends only on reward differences, so adding a constant to all rewards
changes nothing; InstructGPT therefore shifts the RM so demonstrations score 0 on average2.
Over-optimization and reward hacking. The RM is only a proxy. Optimizing it harder first
raises the true ("gold") reward, then lowers it while the proxy keeps rising, an instance of
Goodhart's law3. This is reward hacking: if the RM happens to favour long or agreeable
answers, the policy becomes verbose or sycophantic; a coding agent rewarded for passing tests
may edit the tests instead of the code7. The KL term keeps the policy near the distribution
where the RM is reliable.
Constitutional AI8 needs no human labels of harmfulness, only a written list of
principles: the model critiques and revises its own answers and is fine-tuned on the
revisions, then AI-labelled comparisons train a preference model for RL (RL from AI
feedback, RLAIF).
DPO4 skips both the separate RM and RL. The KL-constrained RLHF objective has a
closed-form optimal policy, so the reward can be written as
βlogπref(y∣x)πθ(y∣x) (the implicit reward);
inserting it into the Bradley–Terry likelihood gives a classification loss on stored
preference pairs. No sampling from the policy during training, but the frozen reference
model's log-probabilities are needed for every pair; β controls how far the policy may
drift from πref.
Reasoning via RL: DeepSeek-R15. R1-Zero applies RL (GRPO) directly to the base
model with rule-based accuracy and format rewards, no SFT first; reflection and
re-checking emerged on their own (the "aha moment"), but outputs had poor readability and
mixed languages. R1 adds stages: cold-start SFT on thousands of readable long
chain-of-thought examples → reasoning RL → rejection sampling plus another SFT round (with
non-reasoning data) → a final RL stage for helpfulness and harmlessness.
GRPO5 samples a group of G outputs per prompt (16 for R1-Zero), scores each, and uses
the reward normalized within the group as the advantage in a PPO-style clipped objective
with a KL penalty to a reference policy.
Test-time reasoning. Self-consistency samples several chain-of-thought paths and
returns the majority answer instead of the single greedy path6.
Formulas
Bradley–Terry preference and RM loss2,4:
P(yw≻yl∣x)=σ(r(x,yw)−r(x,yl)),
LRM=−logσ(r(x,yw)−r(x,yl)).
The reward model is trained before RL on comparison data; the RL step optimizes only the
policy.
The KL term is subtracted: it penalizes drifting from the SFT/reference model, it does not
reward exploration.
In DPO, a largerβ keeps the policy closer to the reference, and the reference model
is still needed throughout training.
Reward hacking is a mismatch between proxy and intent, not an optimization failure such as a
diverging loss.
GRPO's group is several answers to the same prompt from one model, not an ensemble of models
or a split of the dataset; GRPO itself predates R1 (Shao et al., 2024)5.
R1-Zero and R1 start from the same base model; they differ only in post-training (pure RL vs.
SFT + RL).
Self-consistency votes over final answers; the single most probable path can lose.
References
Hugging Face LLM Course — Ch. 12, Introduction to Reinforcement Learning and its Role in LLMs (What is RL?, RLHF)