JA EN
LearnTraining & Alignment
·★ MEMBER·PAPER·9 min read

Instruction Tuning and RLHF from Scratch — How a Model Learns to Follow Orders

A pretrained model ignores your instructions not because it lacks the ability but because it was optimised for something else. Working only from the InstructGPT paper (Ouyang et al., 2022): the three stages — SFT, reward model, RL — down to the equations, the claim that a 1.3B model beat a 175B one in human evaluation, and the limits the authors themselves put in writing.

Training language models to follow instructions with human feedback

Primary source — what this article is built on

undefined2022-03-04undefined2026-08-064y 5mo later

Training language models to follow instructions with human feedbackLong Ouyang, Jeff Wu, Xu Jiang et al. · 2022-03-04 · v1arXiv:2203.02155Paper page·PDF
undefined

Making language models bigger does not inherently make them better at following a user's intent. For example, large language models can generate outputs that are untruthful, toxic, or simply not helpful to the user. In other words, these models are not aligned with their users. In this paper, we show an avenue for aligning language models with user intent on a wide range of tasks by fine-tuning with human feedback. Starting with a set of labeler-written prompts and prompts submitted through the OpenAI API, we collect a dataset of labeler demonstrations of the desired model behavior, which we use to fine-tune GPT-3 using supervised learning. We then collect a dataset of rankings of model outputs, which we use to further fine-tune this supervised model using reinforcement learning from human feedback. We call the resulting models InstructGPT. In human evaluations on our prompt distribution, outputs from the 1.3B parameter InstructGPT model are preferred to outputs from the 175B GPT-3, despite having 100x fewer parameters. Moreover, InstructGPT models show improvements in truthfulness and reductions in toxic output generation while having minimal performance regressions on public NLP datasets. Even though InstructGPT still makes simple mistakes, our results show that fine-tuning with human feedback is a promising direction for aligning language models with human intent.


Scaling up does not buy obedience

The InstructGPT paper opens with a flat denial: making language models bigger does not inherently make them better at following a user's intent (Abstract). Large models emit things that are untruthful, toxic, or simply unhelpful. The paper's diagnosis is not a capability gap but a mismatch of objectives.

What pretraining maximises is "predict the next token on a webpage from the internet". What we want is "follow the user's instructions helpfully and safely". The paper's word for the gap is misaligned (§1).

Aligned to what, then? The paper names three properties: helpful (it helps you solve your task), honest (it does not fabricate or mislead), harmless (it causes no physical, psychological or social harm) (§1, §3.6). Honesty, though, cannot be measured — you cannot read a model's beliefs from outside — so the paper measures truthfulness, whether the model's statements about the world are true, and says so plainly (§3.6).

Stage 1: collect demonstrations, fine-tune supervised (SFT)

The move is simple. Have labelers write demonstrations of the answer they want for a prompt, and fine-tune GPT-3 on them with supervised learning (§3.1, Step 1).

The scale is smaller than you would guess: about 13,000 training prompts for SFT (11,295 labeler-written plus 1,430 from API customers) (§3.2, Appendix A.3, Table 6). The mix of use cases is telling too — classification and QA are only about 18% of the distribution, while open-ended generation and brainstorming make up roughly 57% (Table 1, §4.1). That is simply not the shape public NLP datasets are good at.

One training detail contradicts the textbook. SFT runs for 16 epochs even though validation loss overfits after a single epoch — and yet more epochs kept improving both the reward-model score and human preference ratings (§3.5).

FIG 1The usual rule is "stop when validation loss turns up". InstructGPT's SFT kept improving on human preference well after validation loss had gone bad (§3.5). What counts as overfitting depends on which metric you actually care about

Stage 2: turn human rankings into a reward model

Demonstrations alone are not enough. Writing a good answer every time is expensive — and choosing which of two answers is better is far easier than writing one.

So labelers rank a set of model outputs for the same prompt. The paper shows them between K=4K=4 and K=9K=9 responses and turns each ranking into (K2)\binom{K}{2} pairwise comparisons (§3.5). The RM training set is 33,000 prompts (Table 6).

The reward model itself is the SFT model with its final unembedding layer removed, taking a prompt and a response and returning one scalar (§3.5). The loss is:

loss(θ)=1(K2)E(x,yw,yl)D[logσ(rθ(x,yw)rθ(x,yl))]\mathrm{loss}(\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]
(1)

Read left to right, it says: take a pair of responses a human judged, subtract the loser's score from the winner's, squash that difference into a probability, and penalise the model whenever that probability comes out low. Put in words, then, the loss does not care about the absolute size of a score at all. Only the gap between the two matters — add the same number to both and the loss does not move, so "80 against 60" and "20 against 0" are the same state as far as this equation is concerned.

Symbol by symbol: xx is the prompt, ywy_w the response the human preferred, yly_l the one they did not, rθr_\theta the scalar the reward model outputs, and σ\sigma the sigmoid. All equation (1) says is score the winner above the loser. The sigmoid converts a score difference into "the probability a human picks that one" — a difference of zero gives 0.5, and larger differences approach 1.

FIG 2The σ of equation (1). Horizontal axis, the reward gap between two responses; vertical axis, the probability a human prefers the winner. Zero gap is a coin flip; the further apart, the closer to certainty — and the reward model is trained so this probability matches real human choices

Two implementation notes are spelled out. First, shuffling the (K2)\binom{K}{2} comparisons into one pile and training on them one at a time overfits within a single epoch, because comparisons from the same prompt are strongly correlated. The fix is to treat all comparisons from a prompt as a single batch element, which is also cheaper — one forward pass per completion instead of one per pair (§3.5, footnote 3).

Second, only 6B reward models are used. Training a 175B RM could be unstable and was less suitable as the value function for RL (§3.5). Since the loss is invariant to shifts in reward, the RM is finally normalised so labeler demonstrations average a score of zero.

What's behind this

§

Members-only from here

371 walkthroughs, 26 textbook chapters, 48 student units and 6 close readings — all included for $4.99/mo, with three new explainers every day. Cancel any time; access runs to the end of the period.

Already a member? Sign in to keep reading

References

  1. Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida et al.. (2022-03-04) Training language models to follow instructions with human feedback. arXiv:2203.02155Paper page·PDF

This article is written from the source paper above. Where they differ, the original is authoritative.

Comments

Sign in to comment