RLHF: Definition, How It Works and Examples
Quick answer
What RLHF means, how human rankings tune a model, a worked ranking example, and what the method cannot guarantee.
RLHF, short for reinforcement learning from human feedback, is a way of training an AI model using human judgements instead of a hand-written scoring rule. People rank or rate the model's outputs, and the model is tuned toward the answers people prefer. It is widely used to make chatbots more helpful and better behaved.
Key takeaways
- RLHF learns from human feedback instead of relying on an engineered reward function.
- In the InstructGPT work, human demonstrations came first, then rankings of model outputs.
- A reward model scores text; it takes a sequence of text and outputs a single number.
- Human feedback is costly and subjective, so RLHF does not guarantee correct answers.
On this page:
- What RLHF means
- How RLHF works, with a ranking example
- Where RLHF is used
- Common mistakes and confusions
- Related terms
- Frequently asked questions
| Term | What it does | Where the signal comes from |
|---|---|---|
| Supervised fine-tuning | Trains on example answers | Human-written demonstrations |
| RLHF | Tunes the model toward preferred outputs | Human rankings of outputs |
| Reinforcement learning | Learns by maximising a reward | A reward function, often engineered |
| Reward model | Scores a piece of text | Learned from human feedback |
What does RLHF mean?
A survey on arXiv (Kaufmann et al., December 2023) describes the approach as learning from human feedback instead of relying on an engineered reward function.
IBM (10 November 2023) describes RLHF as a machine learning technique in which a reward model is trained with direct human feedback. A reward model must take a sequence of text and output a scalar reward value.
How does RLHF work?
The InstructGPT paper from OpenAI researchers (Ouyang et al., on arXiv) first fine-tunes GPT-3 with labeller demonstrations. It then collects a dataset of rankings of model outputs and uses reinforcement learning from human feedback. The full paper sets out three steps:
- Supervised fine-tuning on human-written demonstrations.
- Training a reward model (a scorer) on labellers' comparisons of model outputs.
- Reinforcement learning that updates the model so its answers earn higher scores from that reward model.
An illustrative ranking with made-up data: the prompt is "Explain loans in simple words", and the model writes four answers. A labeller ranks them 2, then 4, then 1, then 3. The scorer learns to give answer 2 the highest score. The chatbot is then tuned so its answers score higher on that learned measure.
The paper reports that outputs from the 1.3B-parameter InstructGPT model were preferred to outputs from the 175B GPT-3, despite having 100x fewer parameters. This is a human preference result from that paper, not a general guarantee.
Where is RLHF used?
It is used to shape assistants so replies are helpful and in the right tone. A hypothetical Indian example: reviewers rank replies from a Hindi-English support bot for politeness and accuracy. The ranking data would show which tone customers prefer. This is a scenario, not a real project.
IBM says the main advantage is capturing nuance and subjectivity where success is hard to define by a rule. For related terms, see reinforcement learning and AI prompt examples.
What are the common mistakes?
- Treating RLHF as plain reinforcement learning. The reward comes from human judgement.
- Assuming it makes models truthful. IBM notes human input is highly subjective, and annotators can disagree.
- Ignoring cost. IBM says human preference data is expensive.
Which terms are related?
Fine-tuning, reward models and evaluation are close neighbours. Read what a neural network is, what a transformer model is and LLM benchmarks explained.
Next step
Take one prompt, write four answers yourself, and rank them. Then note where a friend ranks them differently, which shows why feedback is subjective.
Frequently asked questions
What does RLHF stand for and what does it do?
RLHF stands for reinforcement learning from human feedback. It tunes a model using human judgements of its outputs instead of a hand-written reward function.
Why do chatbots need human feedback at all?
Qualities like helpfulness and tone are hard to define as a rule. IBM says RLHF captures nuance and subjectivity where success is hard to state.
Is RLHF the same as reinforcement learning?
No. It uses reinforcement learning, but the reward signal comes from human feedback rather than an engineered reward function.
What is a reward model?
A reward model takes a sequence of text and outputs a single reward value. In RLHF it is trained with direct human feedback.
What are the disadvantages of RLHF?
IBM says human preference data is expensive and human input is highly subjective, with annotators disagreeing on quality. It also does not guarantee correct answers.