How Does Stanford CS336 Lecture 15 Align Language Models with SFT and RLHF?

30.2K views
•
June 20, 2025
by
Stanford Online
YouTube video player
How Does Stanford CS336 Lecture 15 Align Language Models with SFT and RLHF?

TL;DR

Language models are aligned by post-training them on desired behaviors through supervised fine-tuning and reinforcement learning from human feedback. Stanford CS336 Lecture 15 follows InstructGPT’s three-step structure: imitate expert demonstrations, collect pairwise preferences, and optimize behavior using methods such as PPO or DPO. It also examines reward models, annotator bias, length bias, and safety guardrails. Read on to understand how these pieces turn a pre-trained model into an instruction-following system.

Transcript

OK, so we'll get started. Welcome to lecture 15. We've got two pieces left to the class. And that's going to be various aspects of post-training. Up until now, we've focused very much on the big pre-training systems data components. And then now, we're going to take the big pre-trained model, and we're going to make it useful and safe in various wa... Read More

Key Insights

  • RLHF is used to align large language models with human preferences by optimizing a policy to maximize rewards based on human feedback.
  • Pairwise feedback is collected to train a reward model, which then guides the model's behavior during reinforcement learning.
  • The InstructGPT model employs a KL divergence term to prevent the model from deviating too far from the original supervised fine-tuned model.
  • Data collection for RLHF includes challenges such as ensuring annotator quality and avoiding biases from annotator backgrounds.
  • AI-generated feedback is increasingly used due to its cost-effectiveness and ability to produce consistent evaluations.
  • PPO, a reinforcement learning algorithm, is commonly used in RLHF to optimize policies by correcting for stale samples.
  • DPO offers a simplified approach to RLHF by converting the problem into a maximum likelihood estimation, avoiding the complexity of PPO.
  • Length biases in feedback can influence model behavior, leading to preferences for longer outputs regardless of quality.

Install to Summarize YouTube Videos and Get Transcripts

Explore YouTube Video Summarizer or Get YouTube Transcript Extractor

Questions & Answers

Q: How does RLHF align language models with human preferences?

RLHF uses human feedback to optimize a language model toward preferred behavior. Pairwise judgments identify whether output A or output B is better, a reward model learns from those comparisons, and reinforcement learning then encourages outputs that receive higher rewards.

Q: What does Stanford CS336 Lecture 15 cover?

Lecture 15 shifts from pre-training to post-training, focusing on supervised fine-tuning, RLHF, safety, and alignment. Its central question is how to turn a capable but poorly controlled pre-trained system like GPT3 into an instruction-following system like ChatGPT.

Q: What is the three-step InstructGPT alignment process?

The process begins with supervised fine-tuning on expert demonstrations. It then collects pairwise feedback, trains a reward model from those preferences, and uses reinforcement learning to refine the language model’s behavior.

Q: What role does supervised fine-tuning play before RLHF?

Supervised fine-tuning trains a pre-trained model to imitate expert demonstrations of desired behavior. The lecture presents it as the first part of the InstructGPT-style pipeline, before reinforcement learning and pairwise feedback are introduced.

Q: What is the reward model’s role in RLHF?

The reward model learns to assign scalar values to model outputs from pairwise comparisons. Those values guide optimization toward responses judged more helpful, truthful, and harmless.

Q: How does DPO simplify language-model alignment?

DPO converts the preference-optimization problem into a maximum-likelihood estimation problem. This avoids the complexity of using a reinforcement learning algorithm such as PPO while still learning from pairwise feedback.

Q: What problems can affect the quality of RLHF feedback?

Feedback quality can be weakened by inconsistent annotators, limited time for checking factual or mathematical correctness, and biases tied to annotator backgrounds. Evaluators may also favor formatting or other surface features over factual accuracy, producing distorted training signals.

Q: How do length bias and KL divergence affect RLHF?

Length bias can cause evaluators to prefer longer outputs regardless of their quality, encouraging unnecessary verbosity. In InstructGPT, a KL divergence term acts as a regularizer that keeps the reinforcement-learning policy from moving too far from the supervised fine-tuned model.

Summary & Key Takeaways

  • Reinforcement learning from human feedback (RLHF) is a technique used to align language models with human preferences by optimizing for helpfulness, truthfulness, and harmlessness. This process involves collecting pairwise feedback, training a reward model, and using reinforcement learning algorithms like PPO or DPO to refine the model's behavior.

  • Challenges in RLHF include ensuring the quality and consistency of human feedback, addressing biases introduced by annotators, and managing the trade-offs between model safety and performance. AI-generated feedback is becoming popular due to its cost-effectiveness and ability to produce consistent evaluations.

  • The DPO algorithm simplifies the RLHF process by converting it into a maximum likelihood estimation problem, avoiding the complexity of PPO. This approach allows for more straightforward optimization of model behavior based on human feedback, making it a promising alternative for aligning language models with human values.


Read in Other Languages (beta)

Share This Summary 📚

Explore More Summaries from Stanford Online 📚