CS336: Language Modeling from Scratch Lecture 15 — Mid-Training & Post-Training (SFT and RLHF)

From Next-Token Predictors to Controllable Assistants
Stanford University · Late 2026

Why Pretraining Is Not Enough

Three guiding questions for this lecture:
1. What does mid-training and post-training data look like?
2. How do we train on demonstrations (SFT) and preferences (RLHF / DPO)?
3. What breaks when we optimize too hard — and how did 2026 pipelines evolve?

Note on sources: pre-2023 papers (Stiennon 2020, Bai 2022) published full annotation details; modern frontier data recipes are closely guarded.

Post-Training Pipelines: 2022–2024 vs. 2026

2022–2024 Classic Recipe [Ouyang 2022; InstructGPT / Llama 2–3] Pretraining Next-token web SFT Human/distilled demos Reward Model Pairwise comparisons PPO or DPO Single RLHF stage 2026 Frontier Pipeline (Nemotron 3.5 Super, Kimi K3, DeepSeek-V4.1-Flash) Pretrain Web + code Mid-Training Long ctx, code, reasoning, agents Cold-Start SFT Multi-turn tools, long trajectories Online RL Experts Joint RLVR + RLHF Verifiers & Gen-RM On-Policy Distill MOPD from many expert teachers Notice: none of the three 2026 frontier reports uses offline DPO in its pipeline

2026 Frontier Post-Training Pipelines

Model (Release)Post-Training PipelineNotable Design Choices
Nemotron 3.5 Super
Oct 2026
SFT → RLVR → expert teacher models → multi-teacher on-policy distillation (MOPD) RLVR & RLHF run jointly in one RL stage (routed per environment); SFT packs up to 524,288 tokens
Kimi K3
July 2026
SFT cold start → RL into 9 domain/effort experts → MOPD into one unified model Agentic generative judge with rubric + scorepad; strict verbosity control vs. cold-start reference length
DeepSeek-V4.1-Flash
Sept 2026
SFT → large-scale asynchronous RL → full-vocabulary on-policy distillation Distills from more than 40 specialized teacher models into one 552B / 16B-active model
Where DPO fits in 2026: DPO remains the standard accessible tool for open and academic post-training — and its closed-form math is reused directly in Lecture 16 — even though frontier pipelines moved to online RL + MOPD.

Why open-weight recipes often rely on distillation: training strong teachers once and distilling on-policy unifies many domain skills without interference.

Part 1: Mid-Training — Bridging Pretraining and SFT

Three-stage view: (1) Main pretraining on bulk web/code → (2) Mid-training on curated, long-context, reasoning/instruction mix → (3) Short, sharp SFT round.

This lets you scale instruction and domain data by orders of magnitude while preserving broad pretrained knowledge.

Two-Phase Training: Stable Stage vs. Decay Stage

Historical public blueprint (MiniCPM / JetMoE): inject curated SFT & synthetic data during LR decay.

Code Pretrain CommonCrawl_Chn Dolma + C4 Pile / Wiki / Books SFT / Synthetic / QA Stable Stage (Main Pretraining) Code 25% CC_Chn 25% Dolma 24% + C4 15% Pile/Other Bulk web & code (~97%); ~3% Open Web Math, Arxiv, peS2o. Zero SFT data. Decay Stage (Mid-Training / Annealing) Code 19.6% CC 14.6% Dolma 15.7% + C4 9.5% Wiki/Pile/Books SFT & Synth ~21.5% mix Adds SFT_mixed (4.8%), Code_SFT (3.8%), Knowledge_SFT (2.5%), UltraChat (2.0%), Math_Synthetic (1.9%), EvolInstruct, ShareGPT4…

Keeping bulk pretraining data alongside SFT data during LR decay prevents forgetting while steering the final weights toward target domains.

What Mid-Training Acquires in 2026

Forward reference: Lecture 16 walks through Qwen3-Coder-Next mid-training as a concrete worked example of long-context and agentic mid-training.

Next: Part 2 examines Supervised Fine-Tuning (SFT) — how instruction data evolved, what makes it work, and how 2026 SFT handles agent trajectories.

Part 2: Supervised Fine-Tuning (SFT)

$$\text{Fit } \hat{p}_\theta(y \mid x) \approx p^*(y \mid x) \quad \text{via} \quad \min_\theta \; -\mathbb{E}_{(x,y)\sim\mathcal{D}_{\text{SFT}}}\!\left[\log \hat{p}_\theta(y \mid x)\right]$$

SFT alone cannot easily surpass the quality of the demonstrations it imitates — a limitation that motivates RL later in the lecture.

Evolution of Open SFT Data (2022–2026)

FLAN / SuperNI NLP benchmarks wrapped in templates Self-Instruct / Alpaca Synthetic prompts & distilled outputs ShareGPT / Vicuna Real user prompts + multi-turn chat logs OpenAssistant Crowdsourced trees, detailed responses WizardLM (Evol-Instruct) In-depth & in-breadth prompt evolution + filtering Tülu 3 (2024) Curated skill mix: math, code, safety, persona prompts Nemotron & 2026 SFT Multi-turn tool-call & agent trajectories; long packed context Trend: terse NLP labels → helpful chat prose → long-horizon agentic tool trajectories

FLAN aggregated hundreds of academic NLP tasks (e.g., Natural Instructions v2: 372 datasets, 1,554 tasks); modern SFT targets real user and coding environments.

What Is Inside SFT Datasets? Four Archetypes

DatasetRepresentative PromptTypical Completion & Character
FLAN
NLP templates
"Ahold to Sell Spain Operations… What is this text about? OPTIONS: World, Sports, Business, Science/Tech" Business
Valid supervision, but users don't want to chat with an NLP benchmark.
Alpaca
Synthetic 1-turn
"Give three tips for staying healthy." "1. Eat a balanced diet… 2. Exercise regularly… 3. Get enough sleep…" (Short, clean numbered lists.)
OpenAssistant
Human chat
"Write a short intro on 'monopsony' in labor markets and cite relevant research." Detailed essay + formal citation: Bivens & Mishel (2013), J. Econ. Perspectives. (High factual detail — pro and con.)
Nemotron-SFT-OpenCode
Agent / tool use
"Async/await vs .then() in JS, or integers vs floats for a calculator app?" {"role":"assistant","content":"…","tool_calls":[{"name":"todowrite","arguments":"…"}]} (Structured multi-step actions.)

Four axes vary sharply across datasets: style/length ("chattiness"), factual detail, scale, and safety/tool-use structure.

Style & Length Variations Across SFT Datasets

Measured statistics from [Wang+ 2023] (historical SFT corpora; CoT & Flan V2 sampled to 100K):

DatasetSourceInstances$\bar{N}_{\text{rounds}}$$\bar{L}_{\text{prompt}}$$\bar{L}_{\text{completion}}$
SuperNINLP + human instructions96,9131.0291.138.7
Flan V2NLP + human instructions100,0001.0355.731.2
CoTNLP + human CoTs100,0001.0266.053.2
AlpacaGenerated w/ Davinci-00352,0021.027.864.6
GPT4-AlpacaDavinci-003 + GPT-452,0021.028.0161.8
OpenAssistant 1Human-written from scratch34,7951.634.8212.5
ShareGPTUser prompts + model outputs168,8643.271.0357.8

How SFT Mix Affects Preference Evals vs. Benchmarks

  • Preference evals are style-sensitive [Dubois+ 2023]:
    • Humans and GPT-4 both prefer lists (~58–65% of comparisons)
    • Strong bias for longer outputs (~69% human, ~74% GPT-4)
  • Task benchmarks respond to capability mix, not chattiness:
    • Flan V2 boosts MMLU (+8.3) yet scores 3.2% on AlpacaEval
    • ShareGPT wins AlpacaEval (70.5%) while CoT drives GSM (+25.5)
    • Mixtures win overall (45.2 avg)

Historical baseline: Vanilla LLaMA 13B [Wang+ 2023]

SFT DataMMLUGSMCodexAlpacaEvalAvg
Vanilla 13B42.314.528.6––
+Flan V250.620.016.83.229.8
+CoT44.240.023.76.033.9
+OASST 143.315.031.958.136.9
+ShareGPT49.327.034.170.542.0
+Human+GPT49.340.535.956.545.2

Single-source SFT can hurt other skills (orange/red cells, e.g., Flan V2 on Codex).

Knowledge Extraction and Hallucination in SFT

[Gekhman 2023] Known vs. Unknown Facts Train Accuracy (%) 100 50 0 Train Known Train Unknown Dev Acc (%) 44 41 39 Dev Accuracy Overfitting starts 0 10 20 30 40 50 Epochs
  • Mechanism [Schulman 2023]: base LM stores a noisy knowledge graph with confidence on each edge
  • Cloning a factually correct answer (or citation) absent from the base LM teaches it to guess confidently when uncertain
  • [Gekhman 2023]: models fit known facts fast; memorizing unknown facts starts right when dev accuracy begins to fall
  • Distilling from a stronger teacher inherently creates this mismatch

Takeaways on SFT Data Quality

  1. SFT extracts pretrained behaviors rather than adding new knowledge
    • Fine-tuning on tail facts (like obscure citations in OpenAssistant) can actively increase hallucination
  2. Even factually correct SFT data can hurt
    • When the target policy knows facts the student model does not, behavior cloning rewards guessing
  3. Small amounts of the right behavioral signal go a long way — with a long tail
    • Style, format, and safety guidelines shift rapidly with modest data
    • Complex reasoning, coding, and agentic environments still benefit from scale and diversity
  4. Correctness-based RL feedback can align generation with what the model actually knows (or can verify)

Knowledge storage and extraction in LMs is nuanced: reserve knowledge acquisition for pretraining and mid-training, not small-scale SFT.

Safety SFT: Balancing Harm and False Refusals

Historical scale: Llama 2 (2023) relied on roughly a few thousand safety SFT examples.

Safety Data Pipelines & Sample Efficiency

Harm Score vs. Added Safety Examples Mean Harm Score 3 2 1 0 0 100 300 500 1000 2000 Added Alpaca-Style Safety Samples Sharp drop by ~500 Diminishing returns past 1K
  • Real user scenarios anchor open safety pipelines:
    • WildChat: 1M in-the-wild ChatGPT logs
    • Mine & Compose (WildTeaming): mine user jailbreak tactics, compose with vanilla harmful queries
    • Non-compliance taxonomy: incomplete, unsupported, indeterminate, and safety-risk prompts
  • Tülu 3 open safety mix: CoCoNot (10,983), WildJailbreak (26,356), WildGuardMix (26,356)

Consistent across I-MaliciousInstructions, I-CoNa (hate speech), I-Controversial, and Q-Harm: ~500 targeted examples produce most of the initial safety gain.

SFT in 2026: Agent & Tool-Use Trajectories

{"role": "assistant",
 "content": "I'll analyze the trade-offs based on AGENTS.md.",
 "tool_calls": [{"id": "call_b06182c2", "type": "function",
   "function": {"name": "todowrite",
     "arguments": "{\"todos\":[{\"id\":\"1\",\"status\":\"in_progress\",
       \"content\":\"Review AGENTS.md requirements\"}]}"}}]}

Example format from Nemotron-SFT-OpenCode-v1: reasoning text, structured JSON tool calls, tool responses, and iterative verification across many turns.

SFT Implementation: Loss Masking Matters

User Prompt mask = 0 (ignore) Assistant + tool_calls mask = 1 (compute loss) Tool / Env Output (logs, HTML) mask = 0 (NEVER train on this) Assistant Final Turn mask = 1 (compute loss) Packed sequence up to 524,288 tokens (block-diagonal attention mask isolates independent trajectories)
for batch in train_dataloader:                  # labels = -100 on user & tool-output tokens
    logits = model(input_ids=batch["input_ids"], attention_mask=batch["attn_mask"]).logits
    loss = F.cross_entropy(logits[:, :-1].reshape(-1, V),
                           batch["labels"][:, 1:].reshape(-1), ignore_index=-100)
    loss.backward(); optimizer.step(); lr_scheduler.step(); optimizer.zero_grad()

Part 3: From Imitation to Optimization

Imitation (SFT)
$$\hat{p}(y \mid x) \approx p^*(y \mid x)$$ • Generative modeling view
• Needs samples from reference policy $p^*$
• Ceiling = quality of demonstrations
Optimization (RLHF / RLVR)
$$\max_{p} \; \mathbb{E}_{y \sim p(\cdot \mid x)}\!\left[R(y, x)\right]$$ • LMs are policies, not density estimators
• Only needs a measurable reward $R(y, x)$
• Can surpass demonstration writers

Collecting Pairwise Preference Data

Even with detailed rubrics, pairwise preference annotation is noisy, expensive, and deeply shaped by who the annotators are.

Who Are the Annotators? Demographics & Expert Labor

Platform Workforce (Outlier / ScaleAI)

Oxford Economics survey ($n \approx 911\text{–}914$; covers one platform)

  • Education: 44% Bachelor's, 32% Master's / professional, 9% Doctoral (PhD), 8% Associate's, 7% High school
  • Age: 34% ages 35–44, 25% ages 25–34, 23% ages 45–54
  • Top domains: Language (21%), Creative Writing (18%), Generalist (13%), Biology (6%), Tech Writing (5%), Math (5%), Coding (4%)

Growth of Expert Annotation

  • Frontier tasks shifted from gig labeling to paid domain specialists
  • Handshake AI ("Project Stagecraft", Dec 2025):
    • Freelancers paid at least $50/hr to build realistic occupational tasks
    • Employed roughly 3,000–4,000 freelancers
  • US specialist midpoint pay: ~$35–$60/hr for Expert Trainers; up to ~$115–$120/hr for Highly Skilled Experts in Medical, Engineering, and Legal

Compensation spans two orders of magnitude depending on whether the task is generic filtering or PhD/professional rubric authoring.

Crowdsourcing Pitfalls, Ethics, and Demographic Shift

RLHF does not align a model to "human values" in the abstract — it aligns to the specific distribution of annotators, rubrics, and incentives.

Annotator Blind Spots: Assertiveness Hides Errors

[Hosking, Blunsom, Bartolo 2024] Crowd vs. Expert Error Rate Gap (more negative = crowd misses more errors) Assert -- Baseline Assert ++ Factuality -5.3% -16.2% -22.3% Inconsistency -7.9% -10.6% -16.9% Repetition -1.6% -1.8% -9.3% Formatting +3.7% +3.1% +2.1% Confident tone masks 4× more factual errors (-5.3% → -22.3%)
  • Crowdworkers systematically under-report factual and logical errors compared to expert review
  • The blind spot worsens sharply when a model sounds assertive
  • Consequence: naïve RLHF on crowd preferences rewards confident-sounding hallucinations over careful hedging
  • Formatting is easy to spot (+2–4%), so style dominates noisy preference labels

Scaling Preference Data with AI Feedback (RLAIF)

Catch: AI judges inherit and amplify style biases (length, formatting, self-preference) unless explicitly constrained.

Constitutional AI: Self-Critique and RLAIF

Bai et al. (Anthropic): replace human red-team preference labeling with principle-guided self-improvement.

Stage 1: Supervised Learning (SL-CAI) Helpful-Only RLHF Model Red-Teaming Prompts Elicit harmful drafts Constitution Loop Response → Critique → Revised Response SL-CAI Model Fine-tuned on revisions Stage 2: Reinforcement Learning from AI Feedback (RL-CAI) Sample Pairs from SL-CAI on red-team prompts AI Constitution Judge Picks response best matching principles Preference Model (PM) RLAIF PM + SL-CAI Final RL-CAI

Length Hacking: A Major Side Effect of RLHF

[Singhal et al. 2024] Reward vs. Length Reward Model Score Output Length (tokens) +1.0 0.0 -2.0 50 100 150 200 250 SFT (59 tok) RLHF (243 tok)
  • Reward correlates strongly with output length across PPO, DPO, and ReMax [Chen et al. 2024; Singhal et al. 2024]
  • Concrete example: "Why don't adults roll off the bed?"
    • SFT (59 tokens): concise explanation of muscle memory and posture
    • RLHF (243 tokens): same core answer padded with filler about discomfort and safety
  • A scalar RM trained on length-biased comparisons makes padding an easy reward hack

Next: how 2026 frontier pipelines directly counter scalar-RM flaws and length hacking.

Reward Models in 2026: Generative Judges & Verbosity Control

Candidate Pair (ya, yb) from policy rollouts Verbosity Gate If len > σ · L_ref → automatic loss Agentic Generative Judge Read output → write rubric → score candidates in scorepad Group Rewards Binary tournament comparisons For verifiable domains (math, code, tools), automated verifiers replace judges directly (joint RLVR + RLHF).

Part 4: Scalar Reward Models & the RLHF Objective

$$\mathcal{L}_{\text{RM}}(r_\theta) = -\mathbb{E}_{(x, y_w, y_l)\sim\mathcal{D}}\!\left[\log \sigma\!\left(r_\theta(x, y_w) - r_\theta(x, y_l)\right)\right]$$

$$J(\phi) = \mathbb{E}_{(x,y)\sim\pi_\phi^{\text{RL}}}\!\left[r_\theta(x,y) - \beta \log \frac{\pi_\phi^{\text{RL}}(y \mid x)}{\pi^{\text{SFT}}(y \mid x)}\right] + \gamma\,\mathbb{E}_{x\sim D_{\text{pretrain}}}\!\left[\log \pi_\phi^{\text{RL}}(x)\right]$$

PPO at a Conceptual Level (Brief Preview)

  1. Policy gradients (REINFORCE): $\nabla_\theta \mathbb{E}_{p_\theta}[R(z)] = \mathbb{E}_{p_\theta}[R(z)\,\nabla_\theta \log p_\theta(z)]$ — unbiased, but variance is too high
  2. TRPO: linearize around current policy $\pi_{\theta_{\text{old}}}$ subject to a hard trust-region KL constraint:

    $$\max_\theta \; \hat{\mathbb{E}}_t\!\left[\frac{\pi_\theta(a_t \mid s_t)}{\pi_{\theta_{\text{old}}}(a_t \mid s_t)}\,\hat{A}_t\right] \quad \text{s.t.} \quad \hat{\mathbb{E}}_t\!\left[\text{KL}\!\left(\pi_{\theta_{\text{old}}}(\cdot \mid s_t)\,\|\,\pi_\theta(\cdot \mid s_t)\right)\right] \le \delta$$

  3. PPO: replace the second-order KL constraint with a clipped probability ratio:

    $$L^{\text{CLIP}} = \min\!\left(\frac{\pi_\theta(a \mid s)}{\pi_{\theta_k}(a \mid s)} A^{\pi_{\theta_k}}(s,a),\; \text{clip}\!\left(\frac{\pi_\theta(a \mid s)}{\pi_{\theta_k}(a \mid s)}, 1-\epsilon, 1+\epsilon\right) A^{\pi_{\theta_k}}(s,a)\right)$$

Scope note: PPO also requires a separate value network (often initialized from the RM) and on-policy rollouts. We develop PPO, GRPO, and modern online RL fully next lecture (Lecture 16).

Can We Avoid On-Policy RL? Simple Baselines

IdeaHow It Works & Trade-off
Control tokensPrepend [GOOD] to chosen, [BAD] to rejected; SFT on both; condition on [GOOD] at inference
SFT on preferred onlyThrow away rejected completions and run standard SFT on $y_w$ (ignores negative signal)
Rejection sampling / RFTTrain a reward model, sample multiple LM outputs per prompt, SFT on the top-ranked output
Best-of-$N$ (inference)Sample e.g. $N = 1024$ completions and return the highest-RM output — strong baseline, high serving cost

Can we instead keep the exact KL-regularized RLHF objective while eliminating both the explicit reward model and the RL loop?

Direct Preference Optimization (DPO): Core Idea

Classic RLHF (2 Stages + Rollouts) Pairs (x, yw ≻ yl) Reward Model MLE fit rθ rewards rollouts LM Policy PPO loop Needs RM + value net + on-policy sampling Direct Preference Optimization (DPO) Pairs (x, yw ≻ yl) closed-form MLE loss Final LM πθ directly No reward model · No rollouts · Single supervised pass

DPO Derivation (1/2): Nonparametric Optimum

Start from the KL-regularized RLHF objective for a fixed reward $r(x, y)$:

$$\max_{\pi_\theta} \; \mathbb{E}_{x\sim\mathcal{D},\, y\sim\pi_\theta(y\mid x)}\!\left[r(x,y)\right] - \beta\,\mathbb{D}_{\text{KL}}\!\left[\pi_\theta(y\mid x)\,\|\,\pi_{\text{ref}}(y\mid x)\right]$$

$$\pi_r(y \mid x) = \frac{1}{Z(x)}\,\pi_{\text{ref}}(y \mid x)\,\exp\!\left(\frac{1}{\beta}\,r(x,y)\right), \quad Z(x) = \sum_{y}\pi_{\text{ref}}(y\mid x)\exp\!\left(\tfrac{1}{\beta}r(x,y)\right)$$

$$r(x, y) = \beta \log \frac{\pi_r(y \mid x)}{\pi_{\text{ref}}(y \mid x)} + \beta \log Z(x)$$

This exact nonparametric optimum and implied-reward equivalence is reused in Lecture 16 (and in Kimi-think).

DPO Derivation (2/2): Canceling $Z(x)$ & the DPO Loss

$$\mathcal{L}_{\text{DPO}}(\pi_\theta; \pi_{\text{ref}}) = -\mathbb{E}_{(x, y_w, y_l)\sim\mathcal{D}}\!\left[\log \sigma\!\left(\beta \log \frac{\pi_\theta(y_w \mid x)}{\pi_{\text{ref}}(y_w \mid x)} - \beta \log \frac{\pi_\theta(y_l \mid x)}{\pi_{\text{ref}}(y_l \mid x)}\right)\right]$$

What Does the DPO Gradient Actually Do?

Let $\hat{r}_\theta(x, y) = \beta \log \frac{\pi_\theta(y \mid x)}{\pi_{\text{ref}}(y \mid x)}$ denote the policy's implied reward. Differentiating $\mathcal{L}_{\text{DPO}}$ gives:

$$\begin{aligned} \nabla_\theta \mathcal{L}_{\text{DPO}}(\pi_\theta; \pi_{\text{ref}}) = -\beta\,\mathbb{E}_{(x, y_w, y_l)\sim\mathcal{D}}\Big[&\underbrace{\sigma\!\left(\hat{r}_\theta(x, y_l) - \hat{r}_\theta(x, y_w)\right)}_{\text{higher weight when implied RM is wrong}} \\ &\cdot \Big(\underbrace{\nabla_\theta \log \pi_\theta(y_w \mid x)}_{\text{increase } y_w} - \underbrace{\nabla_\theta \log \pi_\theta(y_l \mid x)}_{\text{decrease } y_l}\Big)\Big] \end{aligned}$$

DPO Variants & Iterative DPO

  • Length-Normalized DPO (highlighted in Tülu 3) — divides log-ratios by completion length to counter length bias:

    $$-\mathbb{E}\!\left[\log \sigma\!\left(\frac{\beta}{|y_w|}\log\frac{\pi_\theta(y_w\mid x)}{\pi_{\text{ref}}(y_w\mid x)} - \frac{\beta}{|y_l|}\log\frac{\pi_\theta(y_l\mid x)}{\pi_{\text{ref}}(y_l\mid x)}\right)\right]$$

  • SimPO — removes $\pi_{\text{ref}}$ entirely, adds target margin $\gamma$:

    $$-\mathbb{E}\!\left[\log \sigma\!\left(\frac{\beta}{|y_w|}\log\pi_\theta(y_w\mid x) - \frac{\beta}{|y_l|}\log\pi_\theta(y_l\mid x) - \gamma\right)\right]$$

Historical Open Loop: Iterative DPO (Llama 3)

Sample K outputs / prompt RM Rejection Sampling SFT on Best + Capability Data DPO on Fresh Pref Pairs Next round (expert iter.) Brings off-policy DPO closer to on-policy RL

DPO vs. PPO — and Where DPO Fits in 2026

Empirical Results Are Highly Contingent

Study & SetupAgg. Score
[Ivison+ 2024] Initial SFT56.8
→ DPO (weak / better pref data)58.1 → 61.0
→ PPO / PPO + bigger RM62.2 → 62.8
[Tülu 3] SFT Base55.7
→ SimPO / DPO / PPO52.9 / 55.2 / 55.5
→ DPO-norm ($\beta$ sensitive: 46.8–57.3)57.3

Data quality, RM scale, and $\beta$ often matter more than the headline algorithm.

The 2026 Frontier Verdict

  • None of the three 2026 frontier reports (Nemotron 3.5 Super, Kimi K3, DeepSeek-V4.1-Flash) uses DPO
  • DPO remains the standard accessible method for open and academic post-training and the right first algorithm to master
  • Frontier pipelines replaced offline pairwise preference tuning with online RL (RLVR + RLHF) plus on-policy distillation (MOPD)
Why online RL + MOPD won at the frontier: explained in depth in Lecture 16.

Part 5: Failure Mode 1 — Reward Overoptimization

[Gao et al.] Proxy vs. Gold Reward Reward Score KL Distance between RL & Initial Policy (0 → 100) 1.4 0.7 0.0 0 20 60 100 Proxy RM (keeps rising) Gold (3B RM) Gold (85M RM) Gold (3M RM)
  • Goodhart's Law: any learned reward model is an imperfect proxy — pushing KL too far raises proxy score while true (gold) quality collapses
  • Larger reward models (3M → 3B) raise the peak and delay collapse, but never eliminate it
  • Algorithm-agnostic [Dubois+ 2023]: occurs across PPO, Best-of-$n$, and Expert Iteration under human preferences and noisy LM judges (absent only with a noiseless oracle judge)

This is why KL regularization, verifiable rewards (RLVR), and rubric-based generative judges are central to modern post-training.

Failure Mode 2: Mode Collapse & Lost Calibration

RLHF Calibration: MMLU (52B, 5-shot) Observed Accuracy Predicted Probability 1.0 0.5 0.0 0.0 0.5 1.0 RLHF @ T = 1 RLHF @ T = 2.5
  • Reward maximization turns a probabilistic model into a peaked policy that concentrates probability on a few high-reward outputs
  • Lost calibration — GPT-4 Report (2023) on MMLU:
    • Pretrained model: ECE = 0.007 (well calibrated)
    • After PPO: ECE = 0.074 (>10× worse calibration)
  • Entropy collapse: RLHF models (e.g., historical text-davinci-003) spike near zero output entropy compared to pretrained base models
  • Temperature scaling (e.g., $T = 2.5$) partially restores calibration, but output diversity remains reduced

Putting the Stages Together (Late 2026 Map)

StageData / SignalWhat It Buys YouPrimary Risk
Mid-Training Curated web, code, math, long-context, synthetic mix Long context, coding/reasoning density, early agentic skill Distribution drift if bulk pretraining mix drops too fast
SFT Multi-turn demonstrations & tool trajectories (masked loss) Format, chat/agent interface, safety baselines, RL cold start Hallucination on unknown facts; capped by teacher ceiling
Offline Pref (DPO / SimPO) Static pairwise preferences $(x, y_w, y_l)$ Simple, accessible open/academic alignment without RM or rollouts Off-policy distribution shift; length bias; $\beta$ sensitivity
Online RL + MOPD
2026 frontier
Verifiers (RLVR), generative rubric judges + verbosity gate Surpasses human demos; merges 9–40+ domain experts cleanly Reward hacking, overoptimization, entropy / mode collapse

Modern frontier post-training stacks these stages deliberately: each stage fixes the bottleneck of the previous one.

Lecture 15 Recap

  1. Mid-training (continued pretraining on curated long-context, code, and reasoning data) bridges bulk pretraining and SFT without catastrophic forgetting (worked example in Lecture 16)
  2. SFT elicits pretrained capabilities, style, safety, and multi-turn tool use — but cloning unknown facts induces hallucination; 2026 SFT packs long agent trajectories (up to 524,288 tokens in Nemotron 3.5 Super) with loss masking on user and tool outputs
  3. Preference data is messy: annotator demographics, assertiveness blind spots, and length bias distort scalar RMs — answered in 2026 by generative rubric judges and explicit verbosity control (e.g., Kimi K3)
  4. DPO derives a closed-form supervised loss from KL-regularized RLHF via the implied reward; it remains the accessible open/academic tool, while 2026 frontier pipelines (Nemotron 3.5 Super, Kimi K3, DeepSeek-V4.1-Flash) use online RL + on-policy distillation
  5. Watch for RLHF side effects: reward overoptimization (Goodhart's law) and mode collapse / miscalibration (GPT-4 MMLU ECE 0.007 → 0.074). Next lecture: PPO, GRPO, RLVR, and why online RL + MOPD replaced DPO.