Learn › Training & Alignment
·FREE·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.

Key points

  • Making language models bigger does not inherently make them better at following a user's intent (§1).
  • The method has three stages: SFT on demonstrations, a reward model from rankings, then PPO to update the policy.
  • The reward model's loss depends only on the gap between winner and loser scores, not on absolute score values.
  • The PPO KL penalty exists to mitigate over-optimisation of the reward model.
  • Outputs from the 1.3B InstructGPT were preferred to those of the 175B GPT-3; size for size, 175B InstructGPT was preferred 85±3% of the time.

Training language models to follow instructions with human feedback

Primary source — what this article is built on

undefined2022-03-04→undefined2026-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.

Stage 3: update the policy with reinforcement learning

With a reward model in hand, the SFT model is fine-tuned with PPO using that scalar as reward (§3.1, Step 3). The environment is a bandit — one prompt appears, one response is returned, the reward model scores it, the episode ends (§3.5). The value function is initialised from the RM.

The objective being maximised is:

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_{\mathrm{pretrain}}}\big[\log\pi^{\mathrm{RL}}_\phi(x)\big]
(2)

Put in words: a carrot, a stick, and a revision session. The large E\mathbb{E} only means "average this over many samples", ϕ\phi is the bundle of weights being trained, and β\beta and γ\gamma are dials for how hard the stick and the revision session pull. Chase the reward model's score (the carrot), pay a price for every step taken away from the SFT model you started from (the stick), and in the last term read some pretraining text again so the model does not forget what it could already do.

Three terms, where πϕRL\pi^{\mathrm{RL}}_\phi is the policy being learned and πSFT\pi^{\mathrm{SFT}} is the SFT model it started from.

  1. rθ(x,y)r_\theta(x,y) — push up the reward model's score. This is the engine.
  2. −βlog⁡(πϕRL/πSFT)-\beta\log(\pi^{\mathrm{RL}}_\phi/\pi^{\mathrm{SFT}}) — a per-token KL penalty, charging the policy for drifting from the SFT model. Its stated purpose is to mitigate over-optimisation of the reward model (§3.5): the RM is only a stand-in for humans, and pursued to its limit it leads somewhere humans do not care about.
  3. γlog⁡πϕRL(x)\gamma\log\pi^{\mathrm{RL}}_\phi(x) — the log likelihood of pretraining data. With γ=0\gamma=0 you get plain "PPO"; positive gives "PPO-ptx", which is what the paper means by InstructGPT.

Why the third term exists leads straight into the next section.

What the paper showed

The headline is that a small model beat a large one under human evaluation. Outputs from the 1.3B InstructGPT were preferred to outputs from the 175B GPT-3 — over 100x fewer parameters, the same architecture, differing only in having been fine-tuned on human data (Abstract, §4.1). Size for size, 175B InstructGPT is preferred to 175B GPT-3 85±3% of the time, and to a few-shot-prompted 175B GPT-3 71±4% of the time (§4.1).

Limits and open questions

Sections 5.2 and 5.3 are unusually candid.

A note as of this writing in 2026 (mine, not the paper's): since this work, methods like DPO — which collapse the reward model and the RL stage into a single classification-style loss — have become widespread. Every number and claim above is from this paper alone; nothing from later work is mixed in.

How this shows up on the job

Of the three stages, the only one most teams actually run is the first. Building a reward model and an RL loop in-house belongs to organisations with a dedicated team and a standing labeling operation.

The knob names. In TRL, start at SFTTrainer with num_train_epochs, learning_rate, packing. Moving to preference learning: DPOTrainer's beta — the same role as β\beta here, deciding how far you may drift from where you started — and a frozen ref_model. Going all the way to RLHF: PPOTrainer's init_kl_coef and target. Whichever route you take, "how much KL from the reference model do I allow" is the knob that matters most.

Three traps. One: early stopping on validation loss. As §3.5 shows, instruction-following quality does not track it. Two: shuffling comparisons that came from the same prompt. Strongly correlated pairs become separate gradient steps and the RM overfits within one epoch (§3.5, footnote 3). Three: not measuring the alignment tax. Watch only instruction-following and your extractive QA and translation degrade quietly.

The design-review question is "why insert a reward model at all — why not use human judgement directly?" Two threads. First, RL needs a reward every episode; asking a human each time fails on both speed and cost, so the reward model is a fast approximation of human preference. Second, precisely because it is an approximation it can break, which is what the KL term in equation (2) is fencing in. A reward model is a proxy metric, and proxy metrics pursued hard enough drift off the real objective — say that and you have understood the design.

Making the supervised stage itself cheaper is the subject of the LoRA paper explained. And if "bad validation loss, good human ratings" is still uncomfortable, overfitting and evaluation is the piece to read first.

Summary

Original paper: Ouyang et al., "Training language models to follow instructions with human feedback" (arXiv:2203.02155, 2022)

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.

Published by TechAthletes · Editorial policy · How we cite · Corrections

Comments

Sign in to comment