Lessons › Chapter 11: Transformers and LLMs
RLHF and preference tuning
A pretrained model can write many possible replies. Some are helpful, some ramble, some are wrong. For one prompt, generate two answers side by side.
Watch it move. This lesson is interactive on Gradient Lab: every step is an animated scene you can replay.
Start the interactive lessonStep by step
Helpful, not just fluent
Pip writes smooth answers that aren’t always helpful. The team starts collecting which answers people prefer.
Two answers to the same question
A pretrained model can write many possible replies. Some are helpful, some ramble, some are wrong. For one prompt, generate two answers side by side.
People pick the better one
A person reads both and picks the one they prefer. Collect many thousands of these comparisons across all kinds of prompts.
Learn what people prefer
A reward model is trained to predict those choices: give it an answer and it outputs a score for how much people would like it.
Tune the model toward preferred answers
Finally, the model is trained with reinforcement learning to produce answers that score well. This is rlhf. It’s a big part of what turns a raw text predictor into a helpful, safer assistant. Newer methods skip the separate reward model and learn from the comparisons directly.
In real life: the thumbs-up button
The thumbs-up and thumbs-down buttons under chatbot replies collect this kind of feedback. Together with carefully written guidelines and expert reviewers, signals like these help make assistants more helpful, honest and safe.
Quick check: In RLHF, what do people provide?
- Comparisons of which answer is better (correct)
- Pixel-by-pixel labels
- New vocabulary words
Human preference comparisons train the reward model that guides tuning.
Pseudocode
prompt → the model writes two answers, A and B people pick the better one reward_model learns to predict those choices the model is trained to write answers the reward model scores highly # newer methods (like DPO) learn from the choices directly
Key terms
- reward model
- A model trained to predict which answers people would prefer.
- rlhf
- Reinforcement learning from human feedback: tuning a model toward answers people prefer.