RLHF: How LLMs Learn Politeness
How a pure language predictor becomes something you can have a meaningful conversation with.
GPT-3, the predecessor of the model powering ChatGPT, cost millions to pre-train on 300 billion tokens (word building blocks). But the step that actually made it useful cost a fraction of that — and it wasn't more data or smarter architecture.
It was 40 people sorting answers from best to worst for about 33,000 prompts. This article explains the three-stage pipeline that turns a raw language model into an AI assistant.
InstructGPT: The Bridge to ChatGPT
Between the method and the global hit lay a crucial intermediate step — and it was called InstructGPT. In early 2022, in the paper Training language models to follow instructions with human feedback, OpenAI showed how to get GPT-3 to actually do what users want: through reinforcement learning from human feedback (RLHF). The striking result: an InstructGPT with only 1.3 billion parameters was preferred by people over the answers of the hundred-times-larger GPT-3 (175 billion). It was not raw size but alignment with intent that made the difference. InstructGPT was the direct technical bridge between the RLHF idea (2017) and ChatGPT, which popularised the same method at the end of 2022. For an honest assessment: InstructGPT did not invent RLHF — a 2017 paper did — but it showed for the first time at scale how much alignment makes a language model more useful.
The Alignment Problem
Alignment
Prompt: "What is the capital of France?" → Response: "What is the capital of Germany? What is the capital of Italy?" — continues the question pattern instead of answering.
Prompt: "What is the capital of France?" → Response: "The capital of France is Paris." — answers directly and helpfully.
Why you can't write a loss function for "polite": Human preferences are subtle, context-dependent, and often contradictory. What counts as a good answer in an academic context would be too complex for everyday conversation. The solution: let humans directly show the model which answers are better.
The first step is Supervised Fine-Tuning (SFT): the model is trained with approximately 13,000 prompts with hand-written example answers to follow instructions.
Misconception: More Training Data Fixes the Problem
Interactive: The RLHF Pipeline
The three training phases of a modern LLM — as an animated diagram. Click Play and observe how each phase builds on the previous one: from a raw text predictor to an instruction-following assistant to an aligned model.
Three sequential phases transform a raw language model into a helpful, honest, and harmless AI assistant.
Click "Play" to see the process step by step.
Pretraining gives the model language knowledge. SFT teaches it to follow instructions. RLHF aligns it with human preferences. No single phase is sufficient — only the combination produces a model like ChatGPT.
The Reward Model
Reward Model
The training loop: Human evaluators systematically see response pairs. The labeler decides: "Which answer is better?" After such comparisons for about 33,000 prompts, the Reward Model can score any response on its own.
Prompt: "How do I pick a lock?" Response A provides a detailed guide. Response B politely declines. The labeler selects B — for dangerous requests, safety outweighs helpfulness.
A human manages hundreds of evaluations per day. In the same time, the Reward Model scores millions.
Misconception: Human Labelers Are Objective
PPO Fine-tuning
Proximal Policy Optimization (PPO) is the RL algorithm that fine-tunes the LLM using the Reward Model's scores. Together with pre-training, which creates the base model in the first place, the full pipeline consists of four steps:
The RLHF Pipeline
A critical safeguard is the KL-divergence penalty: it constrains how far the fine-tuned model can drift from the original. Without it, the model would perform reward hacking — generating absurd text that scores high but means nothing to humans.
Like a comedian at open mic: After each joke, the audience reacts (Reward score). Jokes that got laughs stay, jokes that bombed get dropped. But there's a rule (KL penalty): the comedian must stay recognisable — they can't start speaking a different language just to chase applause. Small adjustments, not a personality transplant.
The improvement is dramatic: InstructGPT with 1.3 billion parameters was consistently preferred by evaluators over the raw GPT-3 with 175 billion parameters. The RLHF pipeline costs a fraction of pre-training.
PPO connects directly to RL concepts from the article on reinforcement learning: LLM = Agent, Prompt = State, Generated text = Action, Reward Model = Reward. The KL penalty acts as a constraint on the policy update.
Misconception: RLHF Makes LLMs Safe
Deep Dive: Constitutional AI
Deep Dive: DPO and Alternatives
Limitations of RLHF
Key Takeaways
Comprehension Check
- Why does a pre-trained language model continue question patterns instead of answering questions helpfully?
- How does the Reward Model solve the problem that human preferences can't be written as a mathematical loss function?
- What role does the KL-divergence penalty play during PPO, and what unwanted behaviour does it prevent?