Pretraining teaches a model to imitate internet text; RLHF adds a reward from human judgments of the model's own answers, so it learns to give answers people prefer instead of merely likely text.
Imagine a child who has read every book in a huge library. The child can continue any sentence in any style: a recipe, a rant, a fairy tale, a rude note. But ask the child a question and they might answer, or they might write three more questions, because many pages look like that. Reading taught the child what text usually looks like, not what a helpful reply is. Now a parent listens to the child's own answers and says "this one was better than that one", again and again. The child slowly learns what people want: answer the question, be honest, do not be cruel. The parent taught no new facts. The parent taught which of the child's own habits to keep. That is RLHF on top of pretraining.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Pretraining and RLHF optimize different things. Pretraining fits a model to the distribution of human-written text. RLHF fits it to human judgments of its own answers. Most of what RLHF adds follows from that change of objective, and so do most of its limits.
A pretrained model is already fluent and knows a lot. GPT-3 at 175B parameters could write essays and code, yet labelers preferred a 1.3B model trained with human feedback. Something other than scale was missing, and the missing piece is a signal about which answers people want.
What the pretraining objective rewards
Pretraining minimizes next-token cross-entropy over a huge text corpus:
The best possible model under this loss reproduces the corpus distribution. That is a demanding goal: to predict text well, the model must learn grammar, facts, code, and reasoning patterns. But it is a goal about what text is likely, not about what text is good. A web corpus contains confident wrong answers, insults, spam, and forum threads where a question is followed by more questions. A perfect predictor reproduces all of these at their natural rates.
The InstructGPT paper states the gap directly. Predicting the next token on a webpage is a different objective from following the user's instructions helpfully and safely. So the paper calls the language modeling objective misaligned. The symptoms are familiar. A base model given a question may continue with a list of similar questions, invent facts in the style of a confident article, or produce toxic text when the prompt looks like a toxic page.
More pretraining does not remove these behaviors, because they are part of the distribution the model is trained to match. A larger model matches the distribution better, including the parts no user wants. What is missing is a signal that ranks outputs by their quality for the person asking.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- InstructGPT: labelers preferred the 1.3B model trained with SFT and RLHF over the 175B GPT-3, and the 175B version was preferred to GPT-3 85 ± 3% of the time.
- Llama 2-Chat: SFT followed by five rounds of RLHF (RLHF-V1 to V5), using rejection sampling and then PPO, with separate helpfulness and safety reward models.
What an interviewer would ask next. Try answering before peeking at the approach.
QIf the RL stage needs so little compute, why not skip pretraining and train with RLHF from scratch?
Think about what the reward needs to work: a policy that already writes sensible text worth comparing, and a competent reference model for the KL anchor.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Saying RLHF teaches the model new knowledge. It mainly changes behavior: which answers the pretrained model could already write get chosen, based on human judgments of its own outputs.
60 second bullets to scan on the way to the call.
Pretraining objective and what it rewards
Why a perfect next-token predictor still misbehaves
Primary sources. Browse if you want the original framing.
- Ouyang et al., Training language models to follow instructions with human feedback
- Christiano et al., Deep reinforcement learning from human preferences
- Stiennon et al., Learning to summarize from human feedback
- Touvron et al., Llama 2: Open Foundation and Fine-Tuned Chat Models
- Zhou et al., LIMA: Less Is More for Alignment
Same topic, related formats. Practice these next.