Seyed Masoud Hosseini · Overview · Study log · Weekly summaries · Ideas · Search · Transcript · RSS feed
Deep Reinforcement Learning · Lecture 86 of 99 · 54:28
Guest Lecture: Eric Mitchell on RLHF, Algorithms and Applications
Study guide
What this lecture covers
This guest lecture by Eric Mitchell (Stanford) explains reinforcement learning from human feedback (RLHF), the technique credited with turning GPT-3-level models into ChatGPT-level assistants. It walks through the full RLHF pipeline used for large language models, then introduces direct preference optimization (DPO), an algorithm Mitchell co-developed that removes the RL training loop entirely while optimizing the same underlying objective. It closes with a case study applying DPO to reduce factual errors in generated text.
After watching, you can describe the four-stage RLHF pipeline (pretraining, supervised fine-tuning, reward modeling, RL fine-tuning), explain why preference comparisons scale better than direct reward labeling, derive the core idea behind DPO, and describe how DPO-style training was used to improve factuality without additional human labels.
Key ideas
- Language models as policies: a language model maps token sequences to a distribution over the next token; for RLHF this is usually treated as a contextual bandit, where a whole prompt is the state and a whole response is a single action.
- Why comparisons beat direct reward labels: asking humans to score a response numerically produces noisy, inconsistent ratings, while asking which of two responses is better produces much higher agreement and is faster to collect.
- Bradley-Terry preference model: preference probability is modeled as a function of the difference between two hidden reward scores, giving a maximum-likelihood objective for fitting a reward model from binary preference data.
- The four-step RLHF pipeline: unsupervised pretraining (produces a GPT-3-like model), supervised fine-tuning on human demonstrations, reward model fitting on preference pairs sampled from the fine-tuned model, and finally RL fine-tuning (typically PPO) against that reward model with a KL penalty back to the supervised model.
- Over-optimization risk: without a KL constraint keeping the policy close to the supervised model, RL fine-tuning can exploit inaccuracies in the reward model, since the reward model is only reliable near the data it was trained on.
- Direct Preference Optimization (DPO): using a specific closed-form relationship between optimal policies and reward functions, the Bradley-Terry preference loss can be rewritten directly in terms of policy parameters, letting the policy be trained by a simple classification-style loss with no reward model, no rollouts, and no separate value function.
- DPO's gradient behavior: the DPO loss pushes up the probability of preferred responses and down the probability of dispreferred ones, weighted more heavily on pairs the implicit reward currently gets wrong, and naturally stops updating on pairs it already ranks correctly.
- RLAIF and AI-generated preferences: preference labels do not have to come from humans; models themselves (or automated fact-checking against references like Wikipedia) can generate preference data, as used both for Claude's harmlessness training and for the factuality application described later.
Walkthrough
Why RLHF, and how language models are framed as RL policies (1:06)
Mitchell frames RLHF as the "one weird trick" that separates the muted reception of GPT-3 from the viral reception of ChatGPT. He defines a language model as an autoregressive policy over tokens and explains the contextual bandit framing used throughout: a prompt is the state, a full response is one action, referencing the "Contrastive Preference Learning" paper for readers interested in per-token versus per-sequence formulations.
The RLHF pipeline: pretraining through reward modeling (5:08)
The lecture walks through unsupervised pretraining (producing a GPT-3-style base model) and supervised fine-tuning on human demonstrations, then asks why this isn't sufficient: demonstrations are laborious to scale and imitation cannot exceed human performance. It argues that a reward signal is needed, and that asking humans to directly assign numeric rewards is unreliable, whereas asking which of two sampled responses is preferred is both faster and more consistent. This preference data is fit to a reward model using the Bradley-Terry choice model via maximum likelihood.
RL fine-tuning, its pitfalls, and why RLHF still works (12:13)
With a reward model in hand, the policy is fine-tuned with an RL algorithm (PPO) to maximize reward. Mitchell highlights the distribution shift risk: since the reward model is only accurate near responses the supervised model assigned high probability to, optimizing without a KL penalty toward that reference model lets the policy exploit reward model errors. He shows InstructGPT results where a 1.3B-parameter RLHF model was preferred by humans over a 175B-parameter purely supervised model, underscoring how much the RL stage contributes. He also briefly covers two RLHF variants: learning diversity metrics from human similarity judgments, and using an RLHF-trained "helpful" model to auto-generate harmlessness labels (RL from AI feedback, as used for Claude).
Direct Preference Optimization (23:23)
Mitchell identifies problems with the PPO pipeline: implementation complexity (juggling a reward model, value function, policy, and reference model), heavy resource requirements, and an unidentifiable reward function (rewards for a given prompt can be shifted by an arbitrary constant without changing the optimal policy). DPO resolves this using a closed-form expression relating any reward function to its optimal KL-constrained policy. Substituting this relationship into the Bradley-Terry loss produces a loss defined directly over policy parameters, no reward model or RL rollouts required. He walks through the resulting gradient, showing it pushes up preferred-response probability and down dispreferred-response probability, weighted by how wrong the implicit reward currently is, which naturally implements the KL constraint by ceasing to update once a pair is already correctly ranked.
Comparing DPO and PPO, and where DPO struggles (41:33)
Using a synthetic sentiment-maximization task with a known ground-truth reward, Mitchell shows DPO achieving a stronger reward-versus-KL-divergence tradeoff than PPO, even when PPO uses the true reward function directly. He also shows that DPO's beta coefficient predictably controls the resulting KL divergence, unlike PPO where the same hyperparameter can produce very different outcomes across runs. A subtler failure mode is described: when the chosen and rejected responses share an identical first token (such as a fixed "TL;DR" marker), DPO's gradient for that token cancels out and nothing is learned about it, showing why the supervised fine-tuning stage remains necessary before preference optimization.
Application: reducing hallucinations with DPO (48:35)
The lecture closes with a case study on factuality. Standard RLHF does not reliably reward truthfulness, since human raters are shown to favor agreement with their existing beliefs over accuracy. Instead, preference data is generated automatically by scoring completions for factual correctness against a reference source, without human labelers, and used to train with DPO. On biography generation and medical question answering, this factuality-tuned model reduces incorrect facts per response and increases correct facts per response, outperforming standard RLHF on the same metric.
Before you watch
- Review the policy gradient and PPO material from earlier in the course, since RLHF fine-tuning is described as running an off-the-shelf RL algorithm on top of a learned reward model.
- Recall the maximum entropy IRL and preference-modeling material from the inverse RL lectures, since the Bradley-Terry preference model reappears here in the same form.
Check your understanding
- Why do preference comparisons scale better as a source of training signal than asking humans for direct numerical reward scores?
- What problem does the KL penalty to the reference model solve during RLHF fine-tuning, and what goes wrong without it?
- How does DPO turn the Bradley-Terry preference loss into a loss over policy parameters, without training a separate reward model?
- Why did DPO fail to learn anything about the shared first token in the TL;DR summarization example, and what does this imply about needing a supervised fine-tuning stage first?
Vocabulary
- RLHF (noun)
- Reinforcement learning from human feedback, a method for training models using human preference labels.
RLHF turned GPT-3 into a much more helpful assistant. - contextual bandit (noun)
- A simplified RL setting where each action is chosen once per context, with no multi-step sequence.
A prompt-response pair is treated as a contextual bandit. - preference (noun)
- A choice showing which of two options someone likes better.
Human preference labels compare two model responses. - Bradley-Terry model (noun)
- A statistical model that predicts preference probability from the difference between two scores.
The Bradley-Terry model turns reward differences into preference probabilities. - reward model (noun)
- A trained model that predicts how good a given response is.
The reward model is fit on human preference data. - supervised fine-tuning (noun)
- Training a model further on labeled examples of desired behavior.
Supervised fine-tuning comes before reward modeling. - KL penalty (noun)
- A cost added to keep a trained policy close to a reference policy.
A KL penalty prevents the policy from drifting too far from the base model. - over-optimization (noun)
- Improving too much against an imperfect measure, causing unwanted side effects.
Without a KL penalty, over-optimization exploits the reward model. - direct preference optimization (noun)
- A method that trains a policy directly from preference data without a separate reward model.
DPO removes the RL loop needed by standard RLHF. - closed-form (adjective)
- Expressed as an exact formula rather than requiring iterative computation.
DPO uses a closed-form relationship between rewards and policies. - rollout (noun)
- A generated sequence of actions or text produced by running a policy.
Standard RLHF requires expensive rollouts from the policy. - hallucination (noun)
- A confident but factually wrong statement produced by a language model.
DPO was applied to reduce hallucinations in generated text. - factuality (noun)
- The quality of being accurate and true to real facts.
The case study focuses on improving factuality. - distribution shift (noun)
- A change between the data a model was trained on and the data it now sees.
Distribution shift lets the policy exploit reward model errors. - pipeline (noun)
- A series of stages a system goes through in order.
The RLHF pipeline has four stages from pretraining to RL fine-tuning. - autoregressive (adjective)
- Generating a sequence one item at a time, each based on the previous items.
A language model is an autoregressive policy over tokens. - laborious (adjective)
- Requiring a lot of time and effort.
Collecting human demonstrations at scale is laborious. - arbitrary (adjective)
- Chosen without a specific reason, so it could just as well be different.
The reward for a prompt can be shifted by an arbitrary constant. - unidentifiable (adjective)
- Not possible to pin down to a single unique value from the available information.
The reward function in standard RLHF is unidentifiable up to a constant shift. - synthetic (adjective)
- Artificially created rather than occurring naturally.
DPO is tested on a synthetic sentiment task with a known reward. - hyperparameter (noun)
- A setting chosen before training that controls how a model learns.
DPO's beta hyperparameter predictably controls the resulting KL divergence. - ground-truth (adjective)
- Known to be exactly correct, used as a reference for comparison.
The synthetic task uses a known ground-truth reward function. - cease (verb)
- To stop happening or being done.
The DPO gradient ceases to update once a pair is ranked correctly. - dispreferred (adjective)
- Liked less than an alternative; the rejected option in a comparison.
DPO pushes down the probability of the dispreferred response. - off-the-shelf (idiom)
- Ready to use as it is, without special modification.
RLHF fine-tuning runs an off-the-shelf RL algorithm on the reward model. - harmlessness (noun)
- The quality of not causing harm or danger.
An RLHF-trained model auto-generates harmlessness labels. - summarization (noun)
- The task of producing a short version of a longer text.
The TL;DR summarization example shows a DPO failure case. - viral (adjective)
- Spreading extremely quickly and widely, especially online.
ChatGPT had a viral reception compared to GPT-3.
From the YouTube description
Guest lecture in CS 285 by Eric Mitchell (Stanford)
← Lecture 20: Inverse Reinforcement Learning, Part 4 · Guest Lecture: Andrea Zanette on Statistical Foundations of RL →
