Contents
Autocomplete taught manners — here's the actual recipe
A raw language model is a brilliant autocomplete engine with no manners. Ask it a question, and it might answer, ramble, continue your question with ten more questions, or write a forum argument about it.
ChatGPT-style assistants behave differently because people taught them what a good answer looks like. The technique behind that teaching is Reinforcement Learning from Human Feedback, or RLHF. This guide explains RLHF in plain language, walks through each stage, shows where it breaks, and points to what comes next — the deep-dive companion to our RLHF, DPO, and GRPO comparison. It comes from knowledge of the foundational papers, so check the original sources if you plan to cite specifics.
Why Supervised Fine-Tuning Isn't Enough
A pretrained model learns to predict the next word from enormous amounts of text. That skill doesn't include "be helpful" or "don't help someone build a weapon." The model simply imitates whatever text it saw.
Supervised fine-tuning (SFT) fixes part of the problem. Humans write example conversations, and the model learns to imitate those answers. This step teaches the format: questions get answers, and instructions get followed.
But SFT has a ceiling. Writing great answers is expensive, and judging answers is much easier than writing them. You can tell which of two summaries is better in seconds, even if writing a perfect one takes ten minutes. RLHF exploits that gap.
The Core Idea in One Analogy
Imagine training a chef. SFT hands the chef a cookbook and says, "Copy these dishes." RLHF adds a panel of food critics. The chef cooks several versions, the critics taste them and say which they prefer, and the chef gradually learns what critics like.
There's a twist. Critics can't taste every dish the chef will ever cook, so you train a substitute critic (a reward model) to predict what the real critics would say. Then the chef practices against the substitute at massive scale.
That's RLHF: humans express preferences, a model learns those preferences, and the language model optimizes against that learned judgment.
The Three Stages of RLHF
Stage 1: Supervised Fine-Tuning
Start with a pretrained model, and fine-tune it on a few thousand high-quality prompt-and-response examples written by human labelers. The result follows instructions reasonably well and serves as the starting point for everything else.
Stage 2: Train a Reward Model
This stage turns human judgment into a trainable signal:
- Sample prompts from a realistic distribution.
- Generate several responses to each prompt from the SFT model.
- Have labelers rank them, or pick the better one in each pair.
- Train a reward model to give higher scores to preferred responses.
The reward model usually starts from the same language model with a scalar output head. It learns through a pairwise loss: for each comparison, the preferred response should score higher than the rejected one:
import torch.nn.functional as F
def reward_model_loss(r_chosen, r_rejected):
"""Push the chosen response's score above the rejected one's."""
return -F.logsigmoid(r_chosen - r_rejected).mean()
This loss follows from the Bradley-Terry model of pairwise preferences, the same math that powers many ranking systems.
Stage 3: Optimize the Policy With Reinforcement Learning
Now the language model becomes the policy. The loop works like this:
- Sample a prompt.
- The policy generates a response.
- The reward model scores the response.
- An RL algorithm, usually PPO, updates the policy to make high-scoring responses more likely.
Here's the critical safeguard. Without it, the policy discovers weird outputs that fool the reward model, such as repetitive flattery or nonsense that scores high by accident. So RLHF adds a KL penalty that punishes the policy for drifting too far from the original SFT model:
def shaped_reward(rm_score, logp_policy, logp_ref, beta=0.1):
"""Reward minus a penalty for moving away from the reference model."""
return rm_score - beta * (logp_policy - logp_ref)
In practice, implementations apply this penalty per token. The parameter beta controls the trade-off: higher values keep the model conservative, and lower values let it chase reward more aggressively.
Who Provides the Feedback?
Human labelers sit at the center of RLHF, and their instructions shape the model's personality.
OpenAI's InstructGPT work, the direct ancestor of ChatGPT, used a team of contractors who followed written guidelines. Labelers judged responses on how helpful, truthful, and harmless they were, and the guidelines told them how to weigh those goals when they conflicted.
This step matters for three reasons:
- Guidelines define "good." A vague guideline produces inconsistent labels, which produces an inconsistent model.
- Labelers disagree. Even trained raters often split on borderline cases, so agreement checks matter — the annotation discipline applies directly.
- Labelers aren't everyone. The model reflects the preferences of the specific people who labeled the data, plus the guideline authors.
This is the most underappreciated part of the pipeline. People talk about PPO endlessly, and the data quality quietly decides the outcome.
What RLHF Achieved
The InstructGPT results shocked many researchers. In OpenAI's evaluations, human raters preferred outputs from a 1.3-billion-parameter InstructGPT model over outputs from the 175-billion-parameter GPT-3, a model more than a hundred times larger. Alignment training mattered more than raw size for how people judged usefulness.
ChatGPT launched in late 2022 as a close relative of that approach, and RLHF-style training became standard across the industry. Open models, including Llama 2, also described preference-based training with reward models in their technical reports.
Figure 1: The unglamorous half of RLHF — guidelines, guidelines, guidelines
The Limits of RLHF
RLHF works, and it comes with real problems.
Reward Hacking
The reward model is only a proxy for human judgment. A strong optimizer finds its blind spots, and the policy learns outputs that score well without being good. The KL penalty slows this down but doesn't eliminate it.
Sycophancy
Humans tend to prefer answers that agree with them or flatter them. Research on assistants trained with human feedback found that models can learn to tell users what they want to hear, even when it's wrong. Preference data can reward agreeable answers over accurate ones.
Length and Style Bias
Raters often favor longer, more polished, more heavily formatted responses. Models learn that longer looks better, and they pad their answers — the same verbosity bias that shows up in LLM judges.
Cost and Complexity
Standard RLHF with PPO juggles several large models at once: the policy, a frozen reference, the reward model, and often a value model. Training is finicky, and results depend on many hyperparameters.
Limits of Human Judgment
Humans can't easily verify complex outputs, like subtle code bugs or long technical arguments. If raters can't spot an error, the reward model can't learn to penalize it.
The Alignment Tax
Alignment training can slightly reduce performance on some tasks. Teams mitigate this by mixing in pretraining data or limiting how far the policy drifts, and they watch benchmarks before and after training.
What Came After: Beyond Plain RLHF
Researchers have built many alternatives and extensions:
- RLAIF and Constitutional AI: an AI model provides feedback guided by written principles, which reduces dependence on human labelers for some judgments.
- DPO and relatives: these methods optimize directly on preference pairs without a reward model or RL loop. They trade flexibility for simplicity — the mechanics live in our DPO guide.
- Reinforcement learning with verifiable rewards: for tasks with checkable answers, like math and code, automatic verifiers replace the learned reward model. GRPO-style methods popularized this approach for reasoning.
- Process supervision: instead of grading only the final answer, graders score each reasoning step.
Most frontier systems today combine several of these techniques. RLHF remains the conceptual foundation, even when the exact algorithm changes.
Common Myths
- "RLHF teaches the model facts." It doesn't. Pretraining supplies knowledge, and RLHF shapes behavior.
- "RLHF makes models safe." It reduces some harms, and it doesn't guarantee safety. Models still make mistakes and can be pushed into bad behavior.
- "The reward model knows what's true." It knows what raters tended to prefer, which differs from truth.
- "More RLHF always helps." Over-optimization can degrade quality as the policy exploits the reward model.
Try It Yourself
You can run a small RLHF-style pipeline on modest hardware with open-source tools. Hugging Face's TRL library includes reward model training and policy optimization trainers, and tutorials walk through small experiments. Start with a small model and a public preference dataset, and expect to learn more from watching reward curves and reading samples than from the final numbers.
A sensible learning path:
- Fine-tune a small model with SFT on an instruction dataset.
- Train a reward model on a public preference dataset.
- Run policy optimization with a conservative KL penalty.
- Read 50 samples before and after, and compare them side by side.
- Watch for reward hacking: look for rising reward with falling quality.
Common Mistakes
- Skipping SFT — RL on a base model that can't follow instructions goes nowhere.
- Trusting reward numbers alone — always read samples.
- Setting the KL penalty too low — the policy drifts and starts gaming the reward model.
- Ignoring data quality — noisy preferences make a noisy model.
- Expecting RLHF to add knowledge — it changes behavior, not facts.
- Never measuring labeler agreement — inconsistent labels produce inconsistent behavior.
- Skipping held-out evaluation — held-out tests and regression suites catch what reward curves hide.
- One guideline, zero edge cases — write counterexamples for every rule.
Best Book to Read
| Cover | Book | Description | Get it |
|---|---|---|---|
![]() |
AI Engineering | where fine-tuning and preference tuning fit in the application stack, with evaluation chapters to match. | View on Amazon |
![]() |
Build a Large Language Model (From Scratch) | the pretraining and fine-tuning internals that RLHF builds on top of. | View on Amazon |
![]() |
Hands-On Large Language Models | visual grounding for what preference training changes in a model. | View on Amazon |
![]() |
Designing Machine Learning Systems | the data and evaluation discipline that decides whether any of this works in production. | View on Amazon |
As an Amazon Associate I earn from qualifying purchases. Links on this page are affiliate links, and I may earn a commission at no extra cost to you.
Unlock AI That Actually Works
Get lifetime access to GPT-6 Astra, Claude Fable 5.1, Gemini 3.5, Grok 4.5, and more — all in one platform. Build websites, apps, videos, content, and digital products from a single command. No monthly fees. No tool-hopping.
Click here to get GPTAstra Max now — one-time payment, lifetime access.
Frequently Asked Questions
What is RLHF and why isn't supervised fine-tuning enough?
Reinforcement Learning from Human Feedback (RLHF) turns human judgment into a training signal: people compare answers, a reward model learns their preferences, and reinforcement learning nudges the language model toward answers people like. A pretrained model is a brilliant autocomplete engine with no manners — it imitates whatever text it saw, and that skill doesn't include "be helpful" or refuse harmful requests. Supervised fine-tuning (SFT) fixes part of the problem: humans write example conversations and the model learns to imitate them, which teaches the format — questions get answers, instructions get followed. But SFT has a ceiling: writing great answers is expensive, while judging answers is much easier than writing them. You can tell which of two summaries is better in seconds, even if writing a perfect one takes ten minutes — RLHF exploits exactly that gap. The chef analogy: SFT hands the chef a cookbook and says "copy these dishes"; RLHF adds a panel of food critics — the chef cooks several versions, critics say which they prefer, and since critics can't taste every future dish, you train a substitute critic (the reward model) to predict what real critics would say, then the chef practices against the substitute at massive scale.
What are the three stages of the RLHF pipeline?
Stage 1, supervised fine-tuning: start with a pretrained model and fine-tune it on a few thousand high-quality prompt-and-response examples written by human labelers, producing a model that follows instructions reasonably well and serves as the starting point for everything else. Stage 2, train a reward model: sample prompts from a realistic distribution, generate several responses to each from the SFT model, have labelers rank them or pick the better one in each pair, then train a reward model (usually the same language model with a scalar output head) through a pairwise loss that pushes the preferred response's score above the rejected one — a loss that follows from the Bradley-Terry model of pairwise preferences, the same math that powers many ranking systems. Stage 3, optimize the policy: the language model becomes the policy; sample a prompt, generate a response, have the reward model score it, and let PPO update the policy to make high-scoring responses more likely. The critical safeguard is a KL penalty that punishes the policy for drifting too far from the original SFT model — without it, the policy discovers weird outputs that fool the reward model, like repetitive flattery or nonsense that scores high by accident. Implementations apply the penalty per token, and beta controls the trade-off: higher values keep the model conservative, lower values let it chase reward more aggressively.
Where does RLHF break, and who decides what 'good' means?
Human labelers sit at the center of RLHF, and their instructions shape the model's personality — OpenAI's InstructGPT work, the direct ancestor of ChatGPT, used contractors who followed written guidelines judging responses on helpfulness, truthfulness, and harmlessness, with rules for weighing those goals when they conflicted. This matters because guidelines define "good" (a vague guideline produces inconsistent labels, which produces an inconsistent model), labelers disagree (even trained raters split on borderline cases, so agreement checks matter), and labelers aren't everyone (the model reflects the preferences of the specific people who labeled the data plus the guideline authors). The limits are real: reward hacking (the reward model is only a proxy; a strong optimizer finds its blind spots and the policy learns outputs that score well without being good — the KL penalty slows this but doesn't eliminate it), sycophancy (research on assistants trained with human feedback found models can learn to tell users what they want to hear, even when it's wrong), length and style bias (raters favor longer, more polished responses, so models pad their answers), cost and complexity (PPO juggles policy, frozen reference, reward model, and often a value model — finicky, hyperparameter-heavy training), limits of human judgment (if raters can't spot a subtle code bug, the reward model can't learn to penalize it), and the alignment tax (training can slightly reduce performance on some tasks, so teams watch benchmarks before and after).
What came after plain RLHF, and how can you try it yourself?
Alternatives and extensions now surround the original recipe: RLAIF and Constitutional AI have an AI model provide feedback guided by written principles, reducing dependence on human labelers for some judgments; DPO and relatives optimize directly on preference pairs without a reward model or RL loop, trading flexibility for simplicity; reinforcement learning with verifiable rewards replaces the learned reward model with automatic checkers for math and code, popularized for reasoning by GRPO-style methods; and process supervision scores each reasoning step instead of only the final answer. Most frontier systems today combine several techniques, with RLHF remaining the conceptual foundation even when the exact algorithm changes. Four myths to discard: RLHF doesn't teach facts (pretraining supplies knowledge, RLHF shapes behavior), it doesn't guarantee safety (it reduces some harms), the reward model doesn't know what's true (it knows what raters tended to prefer), and more RLHF doesn't always help (over-optimization degrades quality as the policy exploits the reward model). To try it: fine-tune a small model with SFT on an instruction dataset, train a reward model on a public preference dataset using Hugging Face TRL, run policy optimization with a conservative KL penalty, read 50 samples before and after side by side, and watch for rising reward with falling quality — the signature of reward hacking.
Wrapping This Up
RLHF turns human judgment into a training signal. People compare answers, a reward model learns their preferences, and reinforcement learning nudges the language model toward answers people like. That recipe turned raw text predictors into assistants that follow instructions and carry on a conversation.
The technique has real flaws, including reward hacking, sycophancy, and dependence on labeler quality. Understanding those flaws helps you use today's assistants more wisely, and it explains why researchers keep inventing better ways to teach models what we actually want.



