skip to content

Search

← The Language Machines

Part III — The Alignment Era (2021–2023)

RLHF

Bradley–Terry reward models and the PPO objective with a KL penalty — InstructGPT.

2017–2022 15 min read 5 papers

It is March 2022. Instruction tuning has taught language models to recognize a request as a request, but recognizing the shape of a good answer is not the same as producing one — labeled demonstrations show a model one acceptable response, not which of several plausible responses a person would actually prefer. A paper out of OpenAI folds a five-year-old reinforcement-learning technique from Atari and robotics into the fine-tuning pipeline, and the resulting model — 1.3 billion parameters, 100 times smaller than GPT-3 — is preferred by human raters over its giant, un-tuned ancestor.

Where We Were

Supervised fine-tuning on instructions, as chapter 12 covered, solved a real problem: a pretrained model predicts plausible continuations of text, not answers to requests, and demonstration data teaches it the difference. But demonstrations have a structural limit. For a task like “translate this sentence” there is close to one correct target, and imitating it works. For a task like “write a helpful, honest response to this question” there is a whole distribution of acceptable answers that differ in tone, length, caution, and framing, and a single labeler-written demonstration captures only one point in that space. Worse, a model trained purely to imitate demonstrations has no signal about how much better one plausible answer is than another, or about the many small ways an answer can be subtly unhelpful, evasive, or wrong without being flatly incorrect.

Reinforcement learning is the standard machine-learning tool for optimizing a scalar objective that isn’t a differentiable per-example label — but it requires a reward function, and nobody had a formula for “how aligned with human intent is this sentence.” The reward had to come from people, and people are slow, expensive, and inconsistent at giving numbers. What they are comparatively good at is comparisons: given two candidate outputs, saying which one is better is faster and more reliable than scoring either one in isolation on an absolute scale. The problem that had to be solved before any of this reached language models was a control problem — could an RL agent be trained at all from a trickle of pairwise human judgments instead of a hand-written reward function?

A control-theory trick reaches language models five years later Preference learning and PPO are both from 2017, both from control tasks; text is where they finally meet. Grey monospace text is the paper's headline result or date. Jun 2017 Preference RL Christiano et al, Atari and MuJoCo under 1% feedback coverage Jul 2017 PPO Schulman et al, general RL clipped surrogate objective Sep 2020 Summarization RLHF Stiennon et al, reaches text 1.3B beats 13B supervised Mar 2022 InstructGPT SFT, reward model, PPO 1.3B beats 175B GPT-3 Nov 2022 ChatGPT ships the recipe the pipeline goes public control-task origin reaches text and ships the three-stage pipeline at scale Five years separate the control-task proof of concept from a shipped chat product built on the same loop.
The two founding ideas sat in control tasks for three years before anyone tried them on text, and another two before the combined recipe reached a shipped product. PNG ↓

That question was answered outside language modeling entirely, in classic reinforcement-learning testbeds — Atari games and simulated robot locomotion — three years before it reached text.

The Breakthrough

Christiano 2017: preferences as the reward signal. “Deep Reinforcement Learning from Human Preferences” (Christiano et al., 2017), submitted in June 2017, showed that an RL agent could learn complex behaviors from a human comparing short video clips of its own trajectories, with no access to the environment’s true reward function at all. The loop had three parts: the current policy generates pairs of short trajectory segments, a human watches both and says which one better exhibits the desired behavior (a MuJoCo hopper doing a backflip, an Atari agent making progress at a level), and a separate reward-predictor network is trained to output higher scores for the preferred segment — effectively learning a numeric surrogate for “goodness” from ordinal judgments alone. The policy is then updated with a standard RL algorithm against this learned reward, and the loop repeats, with new trajectories queried for fresh comparisons as the policy improves. The result that mattered for everything downstream was data efficiency: the method solved tasks using feedback on less than 1% of the agent’s interactions with the environment, and produced novel behaviors — including the backflip, which no one had specified as a goal — from about an hour of human comparison time.

A reward function learned from which clip looks better, not a score Christiano et al train an RL policy with no access to the environment's true reward, only a human's pairwise pick. Grey monospace text is the paper's own figure for that step. Current policy acts in the environment Atari, MuJoCo hopper Two trajectory clips short segments, same task shown side by side Human picks better one one comparison, not a score about an hour of labelling Reward predictor trained on the comparison a learned reward surrogate RL update against the predicted reward under 1% of interactions the improved policy generates fresh clips to compare
Nobody ever writes down a reward function here; the only human input is which of two clips looks better, and that alone is enough to train the policy. PNG ↓

PPO: the optimizer everyone standardized on. One month later, “Proximal Policy Optimization Algorithms” (Schulman et al., 2017), submitted in July 2017, was not framed around human feedback at all — it was a general-purpose policy-gradient algorithm, positioned as a simpler, easier-to-tune alternative to trust region policy optimization (TRPO) that kept TRPO’s stability with plain first-order optimization. Its central device, a clipped surrogate objective, discourages any single update from moving the policy too far from where it collected data, which keeps training stable across many small gradient steps on the same batch. PPO said nothing about where the reward came from; that turned out to be exactly why it became the default RL algorithm to pair with a learned, preference-trained reward model. Reward from a neural network trained on human comparisons is noisier and less stationary than a hand-coded game score, and PPO’s conservative, clip-bounded updates tolerate that noise better than more aggressive policy-gradient methods.

Learning to Summarize: the recipe meets language. For three years the preference-learning loop stayed in control tasks. “Learning to Summarize from Human Feedback” (Stiennon et al., 2020), submitted in September 2020, ported it to open-ended text generation, using a curated version of Reddit’s TL;DR dataset as the task. The pipeline: start from a model already fine-tuned on demonstrations (supervised summaries), have it produce pairs of summaries for the same post, collect human judgments of which summary is better, train a reward model on 64,832 such comparisons, and fine-tune the summarizer against that reward model with PPO, adding a penalty for straying too far — in KL divergence — from the starting policy. Results at 1.3B and 6.7B parameters showed the value of the approach starkly: their 1.3B human-feedback-trained model was preferred over the dataset’s own human-written reference summaries 61% of the time, while a 13B model trained with supervised learning alone — ten times the parameters, no human-feedback stage — was preferred only 43% of the time. Feedback-trained summaries also transferred to CNN/DailyMail news articles without any domain-specific fine-tuning, approaching reference-summary quality on a task the model had never been tuned for. The paper established, for the first time in language generation, that a smaller model optimized against human preferences could beat a larger model optimized against a fixed dataset.

InstructGPT: the three-stage pipeline at scale. “Training Language Models to Follow Instructions with Human Feedback” (Ouyang et al., 2022), submitted in March 2022, generalized the summarization recipe from one task to arbitrary instructions, and turned it into the pipeline the field now calls RLHF. About 40 contractors, hired through Upwork and ScaleAI, produced two kinds of data on real API prompts: roughly 13,000 demonstrations of good responses (for a supervised fine-tuning stage) and roughly 33,000 prompts on which labelers ranked 4 to 9 model outputs from best to worst (for a reward model trained on all (K2)\binom{K}{2} pairwise comparisons implied by each ranking). The reward model was fixed at 6 billion parameters even for the 175B policy — the paper reports that training a 175B reward model was unstable and not worth the compute. A further 31,000 prompts, drawn only from the API with no human labels, were used for the RL stage itself: the SFT model was fine-tuned with PPO against the reward model, with a per-token KL penalty against the SFT policy to keep the RL model from drifting into reward-model blind spots, and — in a variant the paper calls PPO-ptx — an added pretraining-data loss term to fix an “alignment tax,” the tendency of RLHF fine-tuning to regress performance on standard NLP benchmarks relative to the base model.

Three stages, three datasets, one policy at the end Ouyang et al chain supervised demonstrations, a reward model and PPO-ptx into the pipeline the field now calls RLHF. Grey monospace text is the labeler dataset size for that stage. Pretrained GPT-3 175B, next-token only the starting checkpoint SFT on demonstrations labeler-written answers 13,000 demonstrations Reward model trained on ranked outputs 33,000 ranked prompts PPO-ptx against reward model plus pretraining loss term Pretraining data mixed into PPO-ptx InstructGPT 1.3B beats 175B GPT-3 ~85% preferred at matched scale starting weights and pretraining data the SFT stage and the finished model the reward model the RL optimisation stage
Three separate datasets feed three separate stages before a single policy comes out the other end; PPO-ptx is where all three converge. PNG ↓

The headline comparison was the one that made the paper impossible to ignore: in human evaluations, outputs from the 1.3B-parameter InstructGPT model were preferred over outputs from the 175B GPT-3, despite having 100 times fewer parameters, and at matched 175B scale InstructGPT’s outputs beat GPT-3’s roughly 85±3% of the time. The gains were not limited to a vague notion of “preference”: InstructGPT generated truthful, informative answers on TruthfulQA about twice as often as GPT-3, produced roughly 25% fewer toxic outputs when prompted to be respectful, and hallucinated on closed-domain summarization tasks 21% of the time versus 41% for GPT-3. Size stopped being the only lever that mattered; what the model had been optimized against mattered as much as how large it was.

The Mathematics

The pipeline has three components with three different learning objectives layered on top of one another: a reward model learned from comparisons, a policy-gradient optimizer that uses that reward, and a penalty that keeps the optimized policy tethered to where it started.

The reward model is trained on pairs, not absolute scores. Given a prompt xx and two candidate responses, where ywy_w is the one a human preferred and yly_l is the one they didn’t, the model learns a scalar function rθ(x,y)r_\theta(x,y) such that higher-scoring responses are the ones people pick more often:

LRM(θ)=−1(K2)  E(x, yw, yl)∼D[log⁡σ(rθ(x,yw)−rθ(x,yl))]\mathcal{L}_{\text{RM}}(\theta) = -\frac{1}{\binom{K}{2}}\; \mathbb{E}_{(x,\,y_w,\,y_l)\sim D}\Big[\log \sigma\big(r_\theta(x,y_w) - r_\theta(x,y_l)\big)\Big]
SymbolMeaning
θ\thetaReward model parameters
xxThe prompt shared by both candidate responses
yw, yly_w,\ y_lThe response humans preferred, and the one they didn’t
rθ(x,y)r_\theta(x,y)The reward model’s scalar score for response yy to prompt xx
σ\sigmaThe logistic sigmoid function
KKNumber of responses ranked per prompt; (K2)\binom{K}{2} pairwise comparisons come from one ranking

Once a reward model exists, the policy is optimized against it with PPO. The core device is a clipped surrogate objective that bounds how far one gradient step is allowed to move the policy relative to where it was when the training data was collected:

LCLIP(θ)=Et[min⁡(rt(θ) A^t,  clip(rt(θ), 1−ϵ, 1+ϵ) A^t)]L^{\text{CLIP}}(\theta) = \mathbb{E}_t\Big[\min\big(r_t(\theta)\,\hat{A}_t,\ \ \mathrm{clip}\big(r_t(\theta),\,1-\epsilon,\,1+\epsilon\big)\,\hat{A}_t\big)\Big]
SymbolMeaning
θ\thetaPolicy parameters being optimized
rt(θ)r_t(\theta)Ratio of new to old policy probability for the action taken at step tt
A^t\hat{A}_tEstimated advantage of the action taken at step tt
ϵ\epsilonClip range hyperparameter, 0.2 in the original PPO experiments
clip(⋅)\mathrm{clip}(\cdot)Truncates its argument to the interval [1−ϵ, 1+ϵ][1-\epsilon,\,1+\epsilon]

InstructGPT combines this optimizer with a reward that is not just the reward model’s score but that score minus a penalty for drifting from the supervised policy, plus — in the PPO-ptx variant — a term that keeps pretraining-style language modeling alive during RL fine-tuning:

objective(ϕ)=E(x,y)∼DπϕRL[rθ(x,y)−βlog⁡πϕRL(y∣x)πSFT(y∣x)]  +  γ Ex∼Dpretrain[log⁡πϕRL(x)]\mathrm{objective}(\phi) = \mathbb{E}_{(x,y)\sim D_{\pi^{\mathrm{RL}}_\phi}}\Big[r_\theta(x,y) - \beta \log\frac{\pi^{\mathrm{RL}}_\phi(y\mid x)}{\pi^{\mathrm{SFT}}(y\mid x)}\Big] \;+\; \gamma\, \mathbb{E}_{x\sim D_{\text{pretrain}}}\big[\log \pi^{\mathrm{RL}}_\phi(x)\big]
SymbolMeaning
ϕ\phiRL policy parameters
πϕRL, πSFT\pi^{\mathrm{RL}}_\phi,\ \pi^{\mathrm{SFT}}The policy being trained, and the fixed supervised-fine-tuned policy it started from
rθ(x,y)r_\theta(x,y)Reward model score for response yy
β\betaKL-penalty coefficient
γ\gammaPretraining-loss mixing coefficient, zero for plain PPO, nonzero for PPO-ptx
DpretrainD_{\text{pretrain}}The original language-model pretraining distribution

What It Enabled

RLHF changed what “improving a language model” meant. Before it, progress mostly meant more data, more parameters, or better instruction-tuning mixtures — all upstream of what the model would actually say. After it, a model’s behavior could be shaped directly against a signal built from the exact axis a product team cared about, whatever that axis was: helpfulness, harmlessness, brevity, refusal behavior, or house style.

Supervised demonstrations only (pre-2020)RLHF pipeline (2020–2022)
Training signalImitate one written example per promptOptimize against a learned model of relative preference
Captures “better, not just correct”No — one demonstration per promptYes — comparisons directly encode degree
Smaller model can beat a larger oneRarelyYes — 1.3B beat 175B GPT-3 in preference
Handles no-single-right-answer tasksPoorly (dialogue, open-ended writing)Directly, by design
Side effects to manageOverfitting to demonstration styleReward hacking, alignment tax, “blind spot” exploitation
Compute/memory footprintOne modelPolicy, reference policy, reward model, and value function concurrently

The lineage from Christiano’s control-task preference learning to a shipped chat product took five years and four papers:

Model / paperDateScaleHeadline result
Preference RL (Christiano et al., 2017)Jun 2017Atari, MuJoCoNovel behaviors from under 1% feedback coverage, ~1 hour of human time
PPO (Schulman et al., 2017)Jul 2017General RLClipped objective becomes the default optimizer for learned-reward RL
Summarization RLHF (Stiennon et al., 2020)Sep 20201.3B–6.7B1.3B model preferred over human references 61% vs. 43% for a 13B supervised model
InstructGPT (Ouyang et al., 2022)Mar 20221.3B–175B1.3B RLHF model preferred over 175B GPT-3; ~85% win rate at matched scale

InstructGPT’s pipeline shipped, largely intact, as ChatGPT in November 2022 (chapter 14) — the moment RLHF stopped being a research result and became the default expectation for what a “finished” language model behaves like. But the pipeline this chapter describes is also the expensive version: a reward model trained once, then a policy optimized against it through a live RL loop that keeps four models — the policy, a frozen reference copy, the reward model, and a value function — resident at the same time, with all the instability that on-policy RL brings (reward hacking, sensitivity to the KL coefficient, extra hyperparameters). Those costs are exactly what motivated the next wave of preference-optimization methods — Constitutional AI’s RLAIF, DPO, and GRPO — which keep the comparison-based training signal but remove the online RL loop; that redesign is chapter 15. The reward-model-plus-RL structure also generalized past human preference entirely: reasoning models trained with reinforcement learning against verifiable rewards — a unit test passing, a math answer matching — rather than a learned preference model, are chapter 20, and the resulting shift of compute from training-time to inference-time is priced out in engine-room’s test-time-compute economics.

InstructGPT is the hinge between two later redesigns One branch keeps the comparison signal but drops the online RL loop; the other keeps the RL loop but drops human preference entirely. Grey monospace text names the chapter each successor gets. ChatGPT ships the pipeline intact November 2022 InstructGPT reward model plus PPO March 2022 Constitutional AI, RLAIF drops the online RL loop December 2022 DPO and GRPO direct preference optimisation chapter 15 RL against verifiable rewards drops learned human preference unit tests, matching answers the shipped product InstructGPT and its RL-based successor preference-optimisation successors
InstructGPT is the pivot: everything after it either keeps the comparison signal and removes the RL loop, or keeps the RL loop and removes human preference. PNG ↓

Key Papers

PaperAuthorsYearLinkWhy it matters
Deep Reinforcement Learning from Human PreferencesChristiano et al.2017arXiv:1706.03741Proved an RL policy could be trained from pairwise human comparisons alone, on control tasks
Proximal Policy Optimization AlgorithmsSchulman et al.2017arXiv:1707.06347Clipped surrogate objective became the default optimizer for learned-reward RL, including RLHF
Learning to Summarize from Human FeedbackStiennon et al.2020arXiv:2009.01325First RLHF result in language generation; 1.3B model beat a 13B supervised model in preference
Training Language Models to Follow Instructions with Human FeedbackOuyang et al.2022arXiv:2203.02155InstructGPT: named the three-stage RLHF pipeline; 1.3B beat 175B GPT-3 in human preference
Rank Analysis of Incomplete Block Designs: I. The Method of Paired ComparisonsBradley and Terry1952DOIThe pairwise-comparison model whose loss function underlies every RLHF reward model

PM Lens

Papers referenced