TAI BUI
Back to curriculum
LearnPython

Instruction-Following as Alignment Signal

The later critiques of RLHF all argue against this pipeline. Before you study how optimization pressure distorts a proxy, you have to see the proxy. InstructGPT (Ouyang et al., 2022) defined the reference architecture: supervised fine-tuning on instruction-response pairs, a reward model trained on pairwise preference rankings, and PPO against the reward model with a KL penalty to the SFT policy. A 1.3B InstructGPT was preferred over a 175B GPT-3. That result is a big part of why frontier labs in 2026 still ship an RLHF-shaped post-training pipeline.

TIME: ~45 minutesPREREQUISITES: Phase 10 · 06 (SFT), Phase 10 · 07 (RLHF), Phase 10 · 08 (DPO)

Learning Objectives

  • Name the three stages of the InstructGPT pipeline and the loss used in each.
  • Explain why a 1.3B instruction-tuned model beat the raw 175B GPT-3 on human preference evaluation.
  • State what the KL penalty in stage 3 is protecting against and why removing it lets the policy drift toward reward-model exploits.
  • Describe the alignment tax and the PPO-ptx mitigation Ouyang et al. used against it.

The Problem

Pre-trained language models complete text. They do not answer questions. Ask GPT-3 "write a Python function that reverses a list" and you often get back another prompt, because most of the training distribution is web text that continues with more web text. The model is doing its job. The job is wrong.

The fix the labs settled on is a proxy: human preference. Two completions go to a rater, the rater picks the better one, and a reward model learns the rater. Then an RL loop shifts the policy toward outputs the reward model scores high. That is the full InstructGPT thesis in three sentences. The rest of the paper is engineering.

Warm-up0/4
1. Why does a raw pre-trained language model often respond to 'write a Python function that reverses a list' with another prompt instead of code?Warm-up
A prompt asking for a Python function that reverses a list, answered not with code but with another prompt-style sentence asking for a different function.
Illustrative, matching the example in The Problem. Not a real model's output.
2. You fine-tune a pre-trained language model on prompts paired with ideal answers, using the standard next-token cross-entropy loss. What is this usually called?Warm-up
A prompt and a human-written ideal answer feeding a cross-entropy loss, with the name of this training setup left as a question mark.
Generic setup; the formula is the one named in the stem.
3. In reinforcement learning, what does the policy do?Warm-up
A person at a three-way fork on a walk, choosing between the left path, straight ahead, or the right path.
Everyday setup only, no reinforcement-learning terms.
4. What does the KL divergence between two probability distributions measure?Warm-up
Two bar charts over the same three outcomes, one weighted toward x1 and the other toward x3, with a question mark between them.
Generic distributions for comparison; values are illustrative.

The Concept

Stage 1: supervised fine-tuning (SFT)

Collect prompt-response pairs where the response is what a well-intentioned human would write. Ouyang et al. used 13k prompts from labelers and the OpenAI API. Fine-tune the base model on this data with standard cross-entropy loss.

What SFT gives you: the model now answers questions instead of continuing them. What it does not give you: any signal about which answer the rater prefers when multiple are plausible.

Stage 2: reward model (RM)

For each prompt, sample K completions from the SFT model. A labeler ranks them. Train a reward model that scores any prompt-response pair so that, for pairs where y_w was preferred over y_l:

L_RM = -log sigmoid(r(x, y_w) - r(x, y_l))

This is the Bradley-Terry pairwise preference loss. The RM is usually initialized from the SFT model with the LM head replaced by a scalar head.

Reward models are small: 6B was enough for the 175B InstructGPT. They are also fragile. Section 5 of the paper is mostly about reward-hacking behaviours that showed up at small scale.

Stage 3: PPO with a KL penalty

Define the objective:

J(pi) = E_{x~D, y~pi(.|x)} [ r(x, y) ] - beta * KL(pi(.|x) || pi_SFT(.|x))

Maximize with PPO. The KL term keeps pi from drifting far from the SFT policy. Without it, the optimizer finds adversarial examples: strings that score high under the RM because the RM never saw them, not because humans actually prefer them.

The KL coefficient beta is the single most important RLHF hyperparameter. Too low: reward hacking. Too high: no improvement over SFT.

The alignment tax

After RLHF, the model is preferred by humans but regresses on standard benchmarks (SQuAD, HellaSwag, DROP). Ouyang et al. call this the alignment tax and fix it with PPO-ptx: mix pre-training gradients into the RL objective so the model does not forget how to do downstream tasks it was never rewarded for.

J_ptx(pi) = J(pi) + gamma * E_{x~D_pretrain} [ log pi(x) ]

PPO-ptx became standard. Anthropic, DeepMind, and Meta all use some variant.

The result

A 1.3B InstructGPT (SFT + RM + PPO-ptx) is preferred by labelers over the 175B base GPT-3 about 70% of the time. The gap widens on hidden-test prompts from production traffic. Two things to read off this number:

  1. Alignment is a different axis from capability. The 175B model had more capability; the 1.3B model had more alignment; labelers preferred the aligned one.
  2. The capability floor is set by the base model. You cannot RLHF a base model into knowing facts it never saw.

Why this is the reference point for Phase 18

The critiques in later lessons (reward hacking in Lesson 2, DPO in Lesson 3, sycophancy in Lesson 4, CAI in Lesson 5, sleeper agents in Lesson 7, alignment faking in Lesson 9) each argue against some part of this pipeline. Reward hacking attacks stage 2. DPO collapses stages 2 and 3. CAI replaces the human labeler. Sycophancy shows the labeler is a biased signal. Alignment faking shows the policy can route around stage 3 entirely. None of them make sense until the pipeline is in your head.

Check: The Concept0/23
1. What is stage 1 of the InstructGPT pipeline, supervised fine-tuning (SFT)?Define
A three-stage pipeline with stage 1 highlighted, labeled with 13k labeler and API demonstrations as input, next to stages 2 and 3 shown only as K ranked completions and PPO with a KL term. Stage 1's own training method is a question mark.
Stage counts from the Concept section. The method is the unknown.
2. What is the InstructGPT reward model usually initialized from?Define
An SFT model that answers prompts feeding into a reward model that scores a prompt-response pair, with the reward model's starting point marked as a question mark.
Setup only; the init source is the unknown.
3. Which loss does the InstructGPT reward model use over pairwise preference labels?Define
A preferred completion and a rejected completion, each with an unknown reward score, feeding an unnamed pairwise loss formula.
Setup only; both the scores and the loss form are unknowns here.
4. In RLHF, what is the KL penalty to the SFT policy primarily protecting against?Define
A policy being optimized away from an anchor SFT policy, with the KL penalty formula shown between them and a dashed box asking what the optimizer can find without that penalty.
Formula from Stage 3. What the penalty blocks is the unknown.
5. What does PPO-ptx change about the PPO objective?Define
The plain PPO objective with reward minus a KL penalty, and an arrow to a second formula box for PPO-ptx left blank.
Base formula from Stage 3. The PPO-ptx change is the unknown.
6. What problem does PPO-ptx mix pre-training gradients into the RL objective to mitigate?Define
A statement that PPO-ptx mixes pre-training gradients into the RL objective, with an arrow to a box asking what problem this treats.
Fact from the stem; the problem it treats is the unknown.
7. When a reward model is trained on labeler rankings, what is it actually approximating?Define
Three raters giving pairwise rankings on sampled completions, feeding a reward model, with what the reward model is a statistical proxy for left as a question mark.
Setup from Key Terms; the target of the proxy is the unknown.
8. Which pairing of InstructGPT stage and training loss is correct?Explain
The three-stage pipeline with real counts for each stage (13k demonstrations, 500 pairwise rankings, beta of 0.1) but every stage's loss or method left as a question mark.
Counts from Use It. Which loss belongs to which stage is the unknown.
9. After stage 1 the model answers questions instead of continuing them. What does SFT still not give it?Explain
One prompt with three equally plausible candidate answers the SFT model can produce, and a question mark over what is still missing.
Setup from Stage 1; the missing ingredient is the unknown.
10. Reward models are small relative to the policy and fragile. Why is that fragility dangerous in stage 3?Explain
A region of labeler-ranked completions the reward model was trained on, beside a much larger region of every other possible string it never scored, with a question mark between them.
Setup only, from Stage 2. Whether the optimizer reaches the untrained region is the unknown.
11. What happens in stage 3 when the KL coefficient beta is set too high?Explain
A beta scale from too low, labelled reward hacking, to too high, left as a question mark.
Low-beta outcome from Stage 3; the high-beta outcome is the unknown.
12. Why does mixing pre-training gradients into the RL objective reduce the alignment tax?Explain
Pre-training text that is never directly rewarded feeding into the RL objective, with the effect on forgetting downstream skills left as a question mark.
Setup from The alignment tax; the effect is the unknown.
13. A 1.3B InstructGPT was preferred over the 175B base GPT-3 about 70% of the time. What does this say about alignment and capability?Explain
Parameter counts of 175B for the base model and 1.3B for the aligned model, with the stated 70% labeler preference for the smaller model, and a question mark over what this means.
Numbers from the stem. The reading of them is the unknown.
14. InstructGPT's preference-rate advantage over GPT-3 does not stay flat across prompt sources. What happens on hidden production prompts?Explain
Two bars for labeler-preference rate, one at about 70% for labeler prompts and the other, for hidden production prompts, left blank with a question mark.
First value from the stem; the second is the unknown.
15. What does it mean that the capability floor is set by the base model?Explain
A large circle of facts seen during pre-training with a smaller region inside it labelled RLHF steers here, beside a separate area of facts never seen marked with a question mark.
Setup from The result; whether RLHF reaches the outside area is the unknown.
16. Which stages does DPO collapse into one step, in the lesson's map of later critiques?Explain
The three-stage pipeline with two other critiques labelled, reward hacking attacking stage 2 and CAI replacing the human labeler, next to a question mark over what DPO collapses.
Other critiques from Why this is the reference point. DPO's target stages are the unknown.
17. A reward model scores the preferred and rejected answers identically, so r(x, y_w) = r(x, y_l). What is the Bradley-Terry loss for that pair?Apply
The Bradley-Terry loss formula with a note that the two scores are tied, and the resulting loss value left blank.
Formula from Stage 2. The tied-score result is the unknown.
18. In stage 3 the expected reward is 1.2, beta is 0.1 and KL(pi || pi_SFT) is 3.0. What is J(pi)?Apply
The stage 3 objective formula with reward 1.2, beta 0.1 and KL 3.0 given, and the resulting J(pi) left blank.
Formula from Stage 3. The arithmetic result is the unknown.
19. J(pi) = 0.9, gamma = 0.5, and the expected pre-training log pi(x) is -2. What is J_ptx(pi)?Apply
The PPO-ptx objective formula with J(pi) 0.9, gamma 0.5 and a pre-training log-likelihood of negative 2 given, and the resulting J_ptx left blank.
Formula from The alignment tax. The arithmetic result is the unknown.
20. A team runs stage 3 with beta = 0. Training reward keeps climbing, but labelers rate the new outputs worse than the SFT model's. What is the most likely cause and first fix?Analyze
A rising training-reward curve next to a falling labeler-rating curve over training steps, both illustrative.
Illustrative trend from the stem. The lesson's own toy run does not show this divergence.
21. After RLHF, labelers prefer a model's answers, but its SQuAD and DROP scores fell. The RL objective had only the reward and the KL term. What was missing?Analyze
The reward-minus-KL objective with a note that labelers preferred the result but SQuAD and DROP scores fell, and the missing third term left as a question mark.
Objective from Stage 3; the benchmark drop is given in the stem. The fix is the unknown.
22. A colleague says the 1.3B InstructGPT beating 175B GPT-3 shows RLHF taught the small model more facts. What is wrong with that reading?Analyze
The same parameter counts and preference figure as before, with a colleague's claim that RLHF taught the small model more facts, and a question mark over what is wrong with it.
Numbers from the stem. The flaw in the claim is the unknown.
23. A paper claims its new stage 3 method is better because its policy reaches a higher reward-model score than PPO. Which evidence would best show the outputs are actually better?Design
A bar chart of reward-model scores with a new method scoring higher than PPO, and a question mark over the best evidence that its outputs are actually better.
Illustrative reward-model scores for the paper's claim; the real values are not given.

Use It

main.py simulates the three stages on toy preference data. The base "policy" is a softmax over three actions {A, B, C}. Stage 1 SFT fits the action frequencies of 200 labeler demonstrations in closed form. Stage 2 fits a Bradley-Terry reward model from 500 pairwise rankings. Stage 3 runs a stripped-down policy-gradient update (REINFORCE with a KL-shaped reward, standing in for PPO) with a KL penalty to the SFT policy. You can watch the reward climb, the KL divergence grow, and the policy drift. Then run it with the KL term off and compare.

With the fixed seed, beta = 0.1 and beta = 0.0 end up close together, both putting roughly 97% of the probability on B. The reward model is accurate on three actions, so there is little for the optimizer to exploit. The KL term earns its keep when the reward model is wrong.

What to look at:

  • Reward trajectory with beta = 0.1 vs beta = 0.0.
  • KL(pi || pi_SFT) over training steps.
  • Final action distribution compared to labeler preference.
Check: Use It0/4
1. Suppose 200 labeler demonstrations over {A, B, C} contain 100 A, 60 B and 40 C, and stage 1 of main.py fits action frequencies in closed form. What is the SFT policy?Apply
A bar chart of 200 demonstrations split 100, 60 and 40 across actions A, B and C, with the resulting SFT policy left as a question mark.
Counts from the stem; the fitted policy is the unknown.
2. The toy reward model in main.py gets a +0.5 bias on action A, but the ranking still has B on top after the bias. Where does the stage 3 policy end up?Apply
A note that the reward model has a +0.5 bug on action A but B is still the highest-ranked action, with the resulting stage 3 policy left as a question mark.
Ranking fact given in the stem; the policy outcome is the unknown.
3. In main.py, beta = 0.1 and beta = 0.0 both end with about 97% of probability on B. What explains the match?Analyze
Two bars, both near 0.97, for action B's probability with beta 0.10 and beta 0.00, with why they match left as a question mark.
Final probabilities computed by calling main.py's stage3_ppo with both beta values.
4. You must ship an RLHF run next week and suspect the reward model overrates some outputs, but you cannot retrain it in time. Which stage 3 setup fits?Design
A note that an RLHF run must ship next week, the reward model is suspected to overrate some outputs, and there is no time to retrain it, with the beta setting for stage 3 left as a question mark.
Scenario from the stem. The setting is the unknown.

Ship It

This lesson produces outputs/skill-instructgpt-explainer.md. Given an RLHF pipeline description or a paper abstract, it identifies which of the three stages is being modified, what loss is being used at each stage, and whether a KL penalty or equivalent regularizer is present.

Author's Note

I'd run main.py before trusting the story above. The beta = 0.1 and beta = 0.0 runs land in nearly the same place, and I think that is the useful surprise. Reward hacking needs a reward model with something to exploit, and a three-action bandit fits too cleanly to give the optimizer anything.

That makes the buggy-reward-model run the better place to poke. It puts a +0.5 bias on action A (exercise 2 uses the same action), but the ranking still has B on top after the bias, so the policy ends on B anyway. I'd raise the bias until the ranking flips, then sweep beta and see where the KL term starts to matter.

Stage 3 here is a per-sample policy gradient with a log-ratio penalty. There is no clipping and no value function, so I'd read the KL curves for their shape and not as a faithful copy of the InstructGPT recipe.

Exercises

  1. Run main.py. Set beta = 0.0 and report the action distribution after the default 300 policy-gradient steps. Explain the mode-seeking behaviour in one paragraph.

  2. Modify the reward model to have a +0.5 bias for action A (a simulated reward bug, matching the buggy run in main.py). Run the stage 3 loop with beta = 0.1. Does the KL penalty prevent the policy from exploiting the bias? At what beta does exploitation become visible?

  3. Read Ouyang et al. (arXiv:2203.02155) Figure 1. Reproduce the labeler-preference curve by running PPO for 1, 5, 20, 100 steps and measuring preference against the SFT model.

  4. The paper's Section 4.3 reports a 1.3B InstructGPT beats 175B GPT-3 about 70% of the time. Why would the ratio be higher on hidden production prompts than on the labeler's own prompts?

  5. Replace the PPO loss with DPO (Phase 10 · 08) on the same preference data. Compare final policy drift (KL to SFT) and final reward. Which method drifts further at matched reward?

Key Terms

TermWhat people sayWhat it actually means
SFT"instruction tuning"Stage 1: cross-entropy fine-tune on prompt-response pairs
Reward model"the RM"Scalar regressor over (prompt, response) trained with Bradley-Terry on pairwise labels
Bradley-Terry"pairwise preference loss"-log sigmoid(r_w - r_l); reduces pairwise ranking to binary classification
KL penalty"the regularizer"beta * KL(pi || pi_SFT); keeps the RL policy near the SFT anchor
PPO-ptx"PPO with pretraining mix"Adds a fraction of pre-training log-likelihood to the PPO objective to offset the alignment tax
Alignment tax"the RLHF regression"Post-RLHF drop on standard benchmarks that RLHF did not target
Labeler preference"the ground truth"Sample of human rankings; the RM is a statistical proxy for this, not for "human values"

Further Reading

Code

Ships With