What is RLHF (reinforcement learning from human feedback)?
Reinforcement learning from human feedback (RLHF) is a way to fine-tune a model using human judgments of its outputs instead of hand-written correct answers. People compare pairs of responses, a reward model learns to predict which one they prefer, and the language model is then trained with reinforcement learning to produce responses that the reward model scores highly.
RLHF is the step that turned large pretrained language models into usable assistants. OpenAI's InstructGPT (2022) used it to make GPT-3 follow instructions, and the same recipe was used for ChatGPT. It is applied wherever the goal is easy to judge but hard to write down as a loss: helpfulness, tone, refusing harmful requests, and summary quality. Direct preference optimization (DPO) is a simpler variant that many open models now use.
Key ideas
- RLHF fine-tunes a model toward outputs people prefer, using comparisons instead of written answers.
- The standard pipeline is supervised fine-tuning, then a reward model, then reinforcement learning with PPO.
- A reward model trained on pairs learns only reward differences, through the loss −log σ(r_chosen − r_rejected).
- A KL penalty against the reference model keeps the policy from drifting into text that games the reward model.
- Reward hacking is when the learned reward goes up but human judgments of the output do not.
- DPO trains directly on preference pairs and needs no separate reward model or RL loop.
Common questions
What is the difference between RLHF and supervised fine-tuning?
Supervised fine-tuning trains on demonstrations: the model copies a written answer token by token. RLHF trains on judgments of the model's own outputs, so it can improve behavior that people can recognize but find hard to write out. Most pipelines run SFT first and RLHF after it.
Why is it called reinforcement learning?
The model is treated as a policy. It generates a full response, receives a single scalar reward, and is updated to make high-reward responses more likely. There is no correct target token at each position, only a score for the whole answer, which is the setting reinforcement learning is built for.
Where did RLHF come from?
Christiano et al. (2017) trained agents in Atari games and simulated robotics from human comparisons of short video clips. With about 900 comparisons, a simulated robot learned to do a backflip. The method was later applied to text summarization and then to instruction following in InstructGPT.
Is RLHF still used, or has DPO replaced it?
Both are used. DPO is cheaper and simpler to run, so many open-weight models use it or one of its variants. PPO-based RLHF is still used when a separate reward model is wanted, for example to score fresh samples during training. Many pipelines also replace some human labels with AI-generated feedback (RLAIF).
Related explainers
- Decoder-Only Transformers — The architecture behind GPT and modern LLMs
- Language Modeling — Predict the next token — the objective that powers GPT, BERT, and modern NLP
- KL Divergence — Measuring how different two distributions are
- Softmax, Logits & Temperature — Turning raw scores into probabilities
- Loss Functions — How networks measure their mistakes
- LoRA & Parameter-Efficient Fine-Tuning — Adapt large models by training tiny low-rank matrices instead of all the weights
References
- Ouyang et al. (2022), "Training language models to follow instructions with human feedback" (InstructGPT)
- Christiano et al. (2017), "Deep reinforcement learning from human preferences"
- Rafailov et al. (2023), "Direct Preference Optimization: Your Language Model is Secretly a Reward Model"
- Schulman et al. (2017), "Proximal Policy Optimization Algorithms"
Last updated