Unit 5 of 13 · about 5 hours · explain, implement
Rejection fine-tuning, rollout and on-policy distillation and reasoning-length control
Filtered rollouts teach format and skill without RL. Distillation copies selected behavior, so its filters and length rules are the method.
You'll be able to
- Run a generate, filter by correctness and fine-tune loop on fixed rollouts and state how it differs from a policy gradient.
- Contrast offline sequence distillation with on-policy distillation by sampling distribution and KL direction.
- Control reasoning length with budgets and invalid-trace handling, and report length beside accuracy.
Covers
Read
In this order, only the parts listed
0 of 3 done
- STaR generate, filter and fine-tune loopSTaR: Bootstrapping Reasoning With Reasoning
Sections 2 and 3, arXiv:2203.14465v2: rationale generation filtered by correctness, fine-tuning outer loop, and rationalization by giving the correct answer for failed problems
- From offline to on-policy teacher-student distillationRLHF Book - Reasoning, Synthetic Data, Tools and Evaluation
The Path to On-Policy, Teacher-Student Distillation: sequence-level distillation with point-mass approximation, offline forward KL versus on-policy reverse KL, exposure bias with compounding as an analogy (the page calls the discrete-action DAgger bound an analogy, not a guarantee for token-level KL), multi-teacher mixture weights (page read 2026-10-14)
Read the KL direction and sampling-distribution argument. Skip the multi-teacher mixture math on a first pass.
- Distilling reasoning into Qwen3 0.6BBuild a Reasoning Model (From Scratch) - Chapters 3, 6 and 8
Chapter 8, Sections 8.2 to 8.7, printed pp.271-295: DeepSeek-R1 teacher traces with
<think>formatting, filtering 12000 to 6695 at 2048 tokens, train 6670 with val 25, answer-only cross-entropy 1.68; teacher 91.2 percent on MATH-500 (90.6 percent on the 12000-example distill set) versus base 15.2 percent on MATH-500Run the 10-example demo on CPU or your GPU first. Use
max_len1024 or 512 for the full run on a small GPU.
Focus on
- STaR filters rollouts by correctness and fine-tunes with cross-entropy. No importance ratio or advantage enters.
- Offline distillation matches the teacher on teacher prefixes with forward KL. On-policy distillation samples student prefixes with reverse KL.
- Answer-only loss trains teacher answer tokens, not prompt tokens. Length filtering at 2048 decides feasibility on small hardware.
- Invalid traces need an explicit policy: drop, finish with 0, or repair. Each choice changes the estimand.
Common mistakes · 3
- Calling rejection fine-tuning RL. It has no policy gradient, only filtered supervised updates.
- Sharing a tokenizer assumption silently. Per-token teacher feedback needs matching vocabularies.
- Reporting distilled accuracy without length. A longer student can win by budget, not by skill.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.How does STaR differ from a GRPO update on the same rollouts?Answer
STaR keeps correct traces and fine-tunes with cross-entropy. GRPO computes group advantages and takes a policy gradient step with ratios.
2.What changes between offline and on-policy distillation?Answer
The sampling distribution and KL direction. Offline uses teacher prefixes with forward KL. On-policy uses student prefixes with reverse KL.
3.Why filter at 2048 tokens and keep val at 25?Answer
Length decides memory feasibility: 5305 of 12000 exceed 2048. A tiny val set keeps the loop fast; MATH-500 is the real check.
4.A trace has no boxed answer. What are the three handling options?Answer
Drop it, keep it with reward 0, or repair the format. Each changes what the update estimates.
Practice
- Build a Reasoning Model: distillation training loop
Chapter 8, Listings 8.4 to 8.7 with
build_examples,filter_examples_by_max_lenandtrain_distillation; run the 10-example demo for 2 epochs atlr=5e-6withgrad_clip_norm=1.0, then the filtered full runAs one example, the full run takes about 3 hours and 5 minutes on a DGX Spark and uses roughly 15 GB at length 2048. Halve the length twice on your machine before blaming your GPU.
You're done when
Your STaR loop runs on fixed rollouts, your run of the book's distillation code reproduces the 6695 filtered count on the author's data, and every accuracy you report carries its length.
Only when you can do this without notes.
Leads to
Notes
Resources · 3 for this unit, 10 more in the section
- RLHF Book - Reasoning, Synthetic Data, Tools and EvaluationNathan Lambert · primary
Study Chapter 7 (reasoning and inference-time scaling), Chapter 12 (synthetic data and on-policy distillation), Chapter 13 (tool use), Chapter 14 (over-optimization) and Chapter 16 (evaluation). Build a claim map separating RLVR learning, inference-time search, on-policy distillation, tool trajectories, reward overoptimization and independent evaluation.
- Build a Reasoning Model (From Scratch) - Chapters 3, 6 and 8Sebastian Raschka (Manning) · support
Use Chapter 3 (a math verifier: boxed-answer extraction, normalization and equivalence checks), Chapter 6 (RLVR with GRPO on a MATH subset) and Chapter 8 (distillation from filtered rollouts) as the smallest verifier-to-distillation path on Qwen3 0.6B.
- STaR: Bootstrapping Reasoning With ReasoningZelikman et al. (NeurIPS 2022) · support
Read the generate, filter by correctness and fine-tune loop and the rationalization step. Use it as the rejection fine-tuning control that an RL method must beat at matched samples.
Also in this section
- RLHF Book Course - Lectures 5, 7, 11 and 12Nathan Lambert · required
Use Lecture 5 (the rise of reasoning models), Lecture 7 (synthetic data and modern post-training), Lecture 11 (tool use and the road to agents) and Lecture 12 (frontier model evaluation). Tie every mechanism to a distinct data and compute budget.
- DeepSeek-R1 Technical ReportDeepSeek AI · required
Read version 2 of the report (January 2026; the Nature 2025 paper is the peer-reviewed version): the R1-Zero and R1 training pipeline, reward design, observed behaviors and limitations. Reproduce only a reduced verifier-driven question and test whether longer sampling or selection explains the observed gain.
- Tulu 3: Pushing Frontiers in Open Language Model Post-TrainingLambert et al. (Ai2, 2024) · support
Read the RLVR section: verifiable rewards for math, instruction following and constraints, and how the RLVR stage sits after SFT and DPO. Compare its recipe with R1-Zero on what is rewarded and what is held out.
- RAGEN: Understanding Self-Evolution in LLM Agents via Multi-Turn Reinforcement LearningWang et al. (2025) · support
Read the multi-turn trajectory formulation and the training instabilities it reports for agent RL (collapse into repetitive reasoning). Use it to design the diagnostics for a small multi-turn environment.
- Stanford CS224R 2026 LLM RL Default Project - ExtensionStanford University · required
Use the specification sections on SFT, IPO, RLOO, evaluation and one extension such as off-policy sampling, test-time inference, exploration, self-play or tool reasoning. Build independent code on a distinct task and respect all course restrictions.
- Berkeley CS 185/285 Deep Reinforcement Learning (Spring 2026) - LLM RL Default Final ProjectUC Berkeley · support
Read the default project for open-ended instruction following: offline DPO, IPO and AOT, online GRPO, Dr. GRPO and GSPO, and judge-based win rates against a frozen base. Use it as a second extension menu; its compute assumes cloud GPUs and a paid judge model.
- Hands-on Modern RL - Reasoning, Agentic RL and SafetyWalking Labs · support
Use the build-an-agentic-training-system page (a from-scratch trainer exercise), one reasoning or search control and the reward-hacking evaluation chapter selectively. Skip the pages that need API keys or several GPUs and the frontier surveys. Pin commit 9231bab of walkinglabs/hands-on-modern-rl; its
code/chapterNNfolders do not follow the site chapter numbers. - veRLByteDance · support
Inspect the hybrid-controller architecture, worker roles, supported algorithms and examples at commit 8718ca3 after single-device losses pass. Trace one rollout from generation through reward and update, record policy lag and run only hardware-compatible examples.
- LLM Post-Training Laboratory - Final IntegrationRoadmap-Final · required
Finish the bounded rollout and verification queue, reasoning or tool extension, independent clean and adversarial evaluation, reward-hacking postmortem, policy-lag and throughput records, clean reproduction and one prespecified negative or positive result.
- Reinforcement Learning CheckpointRoadmap-Final · support
Take the checkpoint closed-note after the integrated project. Pass the estimator and state reconstruction, unseen failure diagnosis, matched-budget comparison, external evaluation and research-readiness clauses.