Skip to content

InstructGPT: Training Language Models to Follow Instructions with Human Feedback

Skip →DPO
main track #7corefundamentalpaperrubric 12/122022 · ~60 min

Long Ouyang, Jeff Wu, Xu Jiang, …, Ryan Lowe

Read first: Proximal Policy Optimization (PPO) · Reward modeling: Bradley–Terry, label disagreement and a worked example

Status

TL;DR. Take GPT-3 and apply three steps. (1) SFT: fine-tune on about 13k prompts with labeller-written demonstrations. (2) RM: have labellers rank 4–9 model outputs for about 33k prompts and train a 6B reward model on all pairs. (3) PPO: on about 31k unlabeled API prompts, maximise the RM score minus a per-token KL penalty to the SFT model, optionally mixing in pretraining gradients (PPO-ptx). Labellers prefer the 1.3B result to the 175B GPT-3. This is the recipe ChatGPT-style post-training started from.

Why it matters now. Almost every later method is defined by which piece of this pipeline it removes or replaces. DPO drops the separate RM and the online loop. RLOO and GRPO drop the critic. Constitutional AI replaces human harmlessness labels with AI labels, and verifiable rewards replace the RM entirely. To read any of those papers you need this pipeline and its parts clearly in mind.

Stage 2: reward model. For a prompt with KK ranked responses, the loss over all (K2)\binom K2 pairs is

L(θ)=−1(K2) E(x,yw,yl)[log⁡σ(rθ(x,yw)−rθ(x,yl))],\mathcal L(\theta)=-\frac{1}{\binom K2}\,\mathbb E_{(x,y_w,y_l)}\big[\log\sigma\big(r_\theta(x,y_w)-r_\theta(x,y_l)\big)\big],

and all pairs from one prompt form one batch element. Shuffling them separately made the RM overfit in a single epoch. See the reward modelling hub for the Bradley–Terry model worked through.

Stage 3: RL. Each prompt and response is a one-step bandit episode. The policy is trained with PPO to maximise (paper Eq. 2)

E(x,y)∼πϕ[rθ(x,y)−βlog⁡πϕ(y∣x)πSFT(y∣x)]+γ Ex∼Dpretrain[log⁡πϕ(x)],\mathbb E_{(x,y)\sim\pi_\phi}\Big[r_\theta(x,y)-\beta\log\frac{\pi_\phi(y\mid x)}{\pi^{\text{SFT}}(y\mid x)}\Big]+\gamma\,\mathbb E_{x\sim D_{\text{pretrain}}}\big[\log\pi_\phi(x)\big],

with β=0.02\beta=0.02. “PPO” means γ=0\gamma=0; “PPO-ptx” (the model called InstructGPT) uses γ>0\gamma>0. The KL term is applied per token, so most tokens get a small reward of −βlog⁡(πϕ/πSFT)-\beta\log(\pi_\phi/\pi^{\text{SFT}}) and the last token also gets the RM score. For example, with log-ratios 0.2, 0.5 and −0.1 and RM score 1.5, the return is 1.5−0.02×0.6=1.4881.5-0.02\times0.6=1.488.

RoleTrained?InstructGPT initialisationWhat it contributes
Policy πϕ\pi_\phiyesSFT model (with 10% pretraining mix)numerator of the PPO ratio; generates the final model
Old / rollout policy πold\pi_{\text{old}}frozen snapshotcopy of πϕ\pi_\phi at the start of each iterationsamples the batch; denominator of the PPO ratio and clip at 0.2
Reference πSFT\pi^{\text{SFT}}frozen all runSFT modelper-token KL penalty; limits total drift
Reward model rθr_\thetafrozen6B, trained in stage 2one scalar per response
Critic VψV_\psiyesinitialised from the RM (6B)baseline for GAE advantages (no discount)

The old policy and the reference are easy to confuse. The ratio πϕ/πold\pi_\phi/\pi_{\text{old}} keeps one update small (PPO). The KL to πSFT\pi^{\text{SFT}} keeps the whole run where the RM was trained. Four of the five are large networks held in memory. That cost is why critic-free (RLOO) and RL-free (DPO) methods became popular.

InstructGPT pipeline and the five models in PPO Top row: three stages. Stage 1, supervised fine-tuning on about 13 thousand prompts with labeller demonstrations. Stage 2, a 6B reward model trained on about 33 thousand prompts where labellers rank 4 to 9 responses, using all pairs per prompt. Stage 3, PPO on about 31 thousand unlabeled prompts with reward equal to the reward-model score minus beta times KL. Bottom: inside stage 3, the trained policy initialised from SFT sits in the centre. Around it are the frozen old policy that samples the batch and gives the PPO ratio, the frozen SFT reference that gives the per-token KL penalty with beta 0.02, the frozen reward model that gives one scalar per response, and the trained critic initialised from the reward model that gives the GAE baseline. 1. SFT 13k prompts with labeller demonstrations 2. Reward model (6B) 33k prompts, rank K = 4–9 all pairs in one batch item 3. PPO (bandit episodes) 31k prompts, no labels reward r_θ − β·KL (+ ptx) Inside stage 3: five models old policy π_old (frozen copy) samples y; PPO ratio, clip 0.2 reference π_SFT (frozen) per-token KL, β = 0.02 reward model r_θ (frozen) one scalar per response critic V (trained) init from RM; GAE baseline policy π_φ (trained) init: SFT model The old policy limits one update (ratio clip); the SFT reference limits total drift (KL). Four of the five are large networks in memory, which is what RLOO (no critic) and DPO (no RM, no RL) cut.
Original sketch. The three stages, with the datasets and human input each needs, and the five models PPO keeps in play. The red dashed arrow is the KL penalty to the frozen SFT reference.
  • Preference (Fig. 1). 175B InstructGPT is preferred to 175B GPT-3 85 ± 3% of the time, and to few-shot-prompted GPT-3 71 ± 4% of the time. The 1.3B PPO-ptx model is preferred to 175B GPT-3.
  • Held-out labellers prefer InstructGPT at about the same rate. RM accuracy drops only from 72.4 ± 0.4% to 69.6 ± 0.9% on their preferences.
  • Truthfulness. About twice as many truthful and informative TruthfulQA answers. Closed-domain hallucination falls from 41% to 21%.
  • Toxicity and bias. About 25% fewer toxic outputs than GPT-3 when prompted to be respectful; no significant improvement on Winogender or CrowS-Pairs bias.
  • FLAN and T0. GPT-3 fine-tuned on these public instruction datasets is worse than the SFT baseline; InstructGPT is preferred to them 78 ± 4% and 79 ± 4% of the time. The authors’ explanation: about 57% of API prompts are open-ended generation or brainstorming, and only about 18% are classification or QA.
  • Simple mistakes remain. It sometimes accepts false premises, hedges too much (the authors suspect labellers rewarded epistemic humility) and degrades on instructions with several explicit constraints.
  • Whose preferences? “Aligned” here means aligned to the labellers, the researchers who wrote their instructions, and the API customers who sent the prompts. The authors say none of these is claimed to be the right source of preferences.
  • It follows harmful instructions. The model is allowed to produce harmful or dishonest output when the user asks for it, because helpfulness was prioritised during training.
  • Reward model overoptimisation is controlled only by β and early stopping. See RM overoptimisation scaling.

Questions to think through

These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.

  1. Derive / compute

    A labeller ranks K = 4 responses A over B over C over D, and the reward model scores them 2.0, 1.0, 0.5 and −0.5. Using the paper's ranking loss, compute how many pairs it uses, each pair's loss, and the prompt's total loss. Then explain why the paper puts all pairs from one prompt into one batch element instead of shuffling them into the dataset.

    What a strong answer covers
    • K choose 2 = 6 pairs, each with loss −log σ(r_better − r_worse).
    • Gaps 1.0, 1.5, 2.5, 0.5, 1.5 and 1.0 give losses of about 0.313, 0.201, 0.079, 0.474, 0.201 and 0.313.
    • The sum is about 1.582, and dividing by 6 gives about 0.264. The B over C pair, with the smallest gap, contributes most.
    • Shuffled pairs from one prompt are strongly correlated, and each response would be seen K − 1 times per epoch, so the RM overfit within one pass.
    • As one batch element, each response needs one RM forward pass instead of one per pair, and validation accuracy and log loss improved.
  2. Derive / compute

    In PPO the KL term is applied per token. A three-token response gets RM score 1.5, and its per-token log-ratios log(π/π_SFT) are 0.2, 0.5 and −0.1, with β = 0.02. Write the reward at each token, the episode return, and what changes with β = 0. How does this connect to the sequence-level objective in the paper's Eq. 2?

    What a strong answer covers
    • Per-token rewards: −0.004, −0.010 and +0.002 + 1.5 = 1.502. The RM score arrives only at the last token.
    • The undiscounted return is 1.5 − 0.02 × 0.6 = 1.488.
    • The per-token log-ratios add up to the sequence log-ratio log(π(y|x)/π_SFT(y|x)), so the sum matches r − β·log-ratio in Eq. 2. Its expectation under π is the KL.
    • With β = 0 the return is the RM score alone, and nothing stops the policy drifting to text where the RM is wrong.
    • Tokens where the policy is more confident than SFT (positive log-ratio) are penalised. Tokens where it is less confident are slightly rewarded.
  3. Mechanism

    PPO-based RLHF keeps five roles in play: the policy being trained, the old or rollout policy, the reference (SFT) policy, the critic or value function, and the reward model. For each, say whether it is trained or frozen, what it is initialised from in InstructGPT, and the exact quantity it contributes to the update.

    What a strong answer covers
    • Policy π_φ: trained; starts as the SFT model (with 10% pretraining mix). It provides the numerator of the PPO ratio.
    • Old or rollout policy: a frozen snapshot of π_φ that sampled the batch. It provides the denominator of the PPO ratio and the clipping anchor, and is refreshed every iteration.
    • Reference π_SFT: frozen for the whole run. It provides the per-token KL penalty β·log(π_φ/π_SFT), so it anchors the whole run, not just one step.
    • Reward model r_θ: frozen 6B model. It provides one scalar at the end of the response.
    • Critic V: trained 6B model initialised from the RM. It provides the baseline for GAE advantages (no discount).
    • It is a common mistake to merge the old policy and the reference: the ratio to the old policy limits one step; the KL to SFT limits total drift.
  4. What if…

    RLHF made GPT-3 worse on SQuAD, DROP, HellaSwag and WMT French–English, an "alignment tax". Compare the two remedies the paper considers, raising the KL coefficient β and mixing in pretraining gradients (PPO-ptx). Say what each changes in the objective and which worked.

    What a strong answer covers
    • Raising β pulls the policy back towards SFT everywhere. In the paper this cut validation reward significantly and never fully recovered DROP and SQuAD.
    • PPO-ptx adds γ·E[log π(x)] on pretraining text, so the model keeps assigning probability to the original data distribution while optimising reward.
    • The paper finds that pretraining mixing beats simply raising the KL coefficient: a suitable γ reverses the SQuADv2 and DROP regressions with minimal loss of validation reward.
    • PPO-ptx removes most regressions without hurting labeller preference, although large PPO-ptx models were slightly worse on prompts submitted to GPT-3.
  5. Critique

    The paper itself asks "who are we aligning to?". Use its numbers on labellers and RM accuracy, and its admission that labellers rewarded hedging, to critique the claim that InstructGPT is aligned to human intent. What experiment would test whether the RM generalises to a different population?

    What a strong answer covers
    • About 40 contractors wrote the demonstrations and comparisons. Training labellers agreed with each other 72.6 ± 1.5% of the time, so about a quarter of labels reflect disagreement.
    • RMs predicted held-out labellers 69.6 ± 0.9% vs 72.4 ± 0.4% for training labellers, which is encouraging but covers only one vendor pool.
    • Labellers prioritised helpfulness during training but truthfulness and harmlessness during final evaluation, so the training signal and the evaluation target differ.
    • The authors suspect the hedging behaviour came from rewarding epistemic humility, a labeller preference that the RM learned and the policy amplified.
    • Test: collect comparisons from a demographically or professionally different group on the same prompts. Measure RM accuracy and policy win rate per group, especially on prompts where the groups disagree.
  6. Design

    You are building a retrieval-augmented answer generator for a library search service and want to use the InstructGPT recipe. Define the three datasets, how the RM is initialised and what it sees, which model is the KL reference, and two evaluations that would catch the failure modes this paper reports.

    What a strong answer covers
    • SFT: librarian-written answers to real queries with retrieved passages in the prompt. RM: K-way rankings of model answers to other queries. RL: unlabeled queries only, as in the paper's 13k / 33k / 31k split.
    • Initialise the RM from the SFT model with a scalar head. Its input must include the retrieved passages so it can judge grounding.
    • Use the SFT model as the frozen KL reference, and consider PPO-ptx-style mixing on general text to limit the alignment tax.
    • Measure closed-domain hallucination (the paper reports 21% vs 41% for GPT-3) by checking answers against the passages, and test false-premise queries.
    • Hold out users and labellers, and track RM score against human win rate during RL to detect overoptimisation.

Done with this page?

Status