Maps to: UC Berkeley EE 290/194 Scalable AI, Spring 2026 Lecture 13, The Data Powering Post-Training: SFT Data Engineering and RL Environments (slides
lecture_13.pdf), and Spring 2026 Lecture 14, NeMo Data Designer Deep Dive (guest lecture by Dhruv Nathawani and Yev Meyer, NVIDIA; slideslecture_14.pdf). The Fall 2026 offering’s Lecture 15 covers the same material; its slides were not public when these notes were written. Recommended reading: DeepSeek-AI, DeepSeek-R1 §2.3 (arXiv:2501.12948); Kimi Team, Kimi K2 §3.1 (agentic data synthesis, arXiv:2507.20534); Qwen Team, Qwen3 Technical Report (arXiv:2505.09388); Chu et al., SFT Memorizes, RL Generalizes (arXiv:2501.17161); Feng et al., Beyond Model Collapse: Scaling Up with Synthesized Data Requires Verification (arXiv:2406.07515); Shumailov et al., AI models collapse when trained on recursively generated data (Nature 2024); Gerstgrasser et al., Is Model Collapse Inevitable? (arXiv:2404.01413); Ge et al., Scaling Synthetic Data Creation with 1,000,000,000 Personas (arXiv:2406.20094); Zhou et al., IFEval (arXiv:2311.07911); Lambert et al., Tülu 3 (arXiv:2411.15124); Ng, Harada and Russell, Policy Invariance under Reward Transformations (ICML 1999); Zaharia et al., The Shift from Models to Compound AI Systems (BAIR blog, 2024); the NeMo Data Designer repository (github.com/NVIDIA-NeMo/DataDesigner). Code:code/lecture17/contains:
task_world.py: five skills with exact checkers, a simulated teacher with known mistakes, and a simulated judge;designer.py: a miniature Data Designer (columns, a DAG, a manifest);student.py: a small Transformer trained by SFT on what the pipelines produce;sql_world.py: text-to-SQL data checked by a real SQL engine;envs.py: a tool-using environment graded by its final state;- six demos.
Reading time: ~2.5 hours for the prose; ~10 minutes to run all demos (three of them train models; each has a
--quickmode).
0. How to read this lecture
0.1 Learning goals
After this lecture you should be able to:
- Describe post-training data precisely. Static records (SFT, preferences) vs executable feedback (environments with verifiers); the fields of a record; the axes of a data taxonomy; protocol SFT vs vertical SFT.
- Design an SFT data pipeline: specification → generation → filtering and verification → normalisation → mixing → release, with the role of humans, judges and verifiers at each step.
- Build a synthetic dataset as code in the NeMo Data Designer style: sampler, template, LLM, validator and judge columns in a dependency graph, with previews, cost accounting and lineage.
- Predict what a data decision does to a model: why random teacher errors wash out and systematic ones are learned, why rejection sampling leaves holes, why mixtures and prompt diversity matter, and how contamination inflates scores.
- Explain why SFT is not enough and what RL environments add: on-policy exploration, recovery from one’s own mistakes, credit assignment.
- Design environments and verifiers: state-based checks, realistic failure modes, budgets, why precision matters more than recall, how reward shaping can change the optimal policy, and how rollouts flow back into SFT data.
0.2 Prerequisites and scope
- Prerequisites: Lecture 16 (chat templates, loss masks, SFT, preferences, RLVR and GRPO, evaluation); Lecture 11 (synthetic pre-training data, verifiers vs judges, model collapse); Lecture 10 §5 (deduplication).
- Scope: what post-training data looks like, how it is generated, checked and mixed, and how RL environments and verifiers are built.
- Not in scope: RL algorithms (Lecture 18) and RL systems at scale (Lecture 19). Nemotron 3 Nano’s actual post-training data and recipe are Lecture 20.
0.3 Section → code map
| Section | Idea | Code in code/lecture17/ |
|---|---|---|
| §1 | records, axes, the share of tokens that train | 01_records_and_pipeline.py (Part A) |
| §4.2–4.3 | a dataset declared as columns; cost; lineage | designer.py, 01_records_and_pipeline.py (Parts B–F) |
| §4.4 | text-to-SQL (Case A) checked by a real database | sql_world.py, 02_text_to_sql.py |
| §5.1–5.3 | rejection sampling, errors, holes, the student | task_world.py, student.py, 03_rejection_sampling.py |
| §5.4 | mixtures | 04_mixtures.py |
| §5.5–5.7 | diversity, collapse, contamination | 05_diversity_and_contamination.py |
| §6–§8 | covariate shift, environments, verifiers, shaping | envs.py, 06_environments_and_verifiers.py |
0.4 Notation
- = prompt (structured context); = response; = loss-mask bit of token .
- = verifier (returns 1 for pass, 0 for fail, or a score).
- = mixture weight of slice ; = sampling temperature.
- = rollouts per prompt in a GRPO group; = candidates per prompt in rejection sampling.
0.5 How the experiments in this lecture work
The slides describe pipelines that run frontier teacher models over millions of prompts. We cannot do that, and if we did we could not measure the truth. So the code builds a small world where the truth is known:
- Five skills stand for families of real SFT data: 2-digit addition (math), reversing a word, uppercasing a word, extracting
{"name": ..., "age": ...}as JSON (structured output), and “repeat a word k times, comma separated” (instruction following with a count constraint). Each has an exact checker. - The teacher is simulated. It answers correctly most of the time and otherwise makes one of three kinds of mistakes, at rates stated in
task_world.py:- a random slip, different every time;
- a systematic bug, the same wrong answer on the same kind of input every time. For example, it never reverses words that start with a vowel correctly, and it writes “repeat 5 times” only 4 times;
- a style quirk: about 5% of its answers start with “Sure! ”, which breaks “answer only”.
- The judge is simulated too, with stated biases: it likes politeness, misses half the content errors, and shares the teacher’s blind spot if it comes from the same family.
- The student is real. A 0.2M-parameter character-level Transformer is trained by SFT on each dataset and graded on fresh prompts.
So “the student copies 96% of the teacher’s bugs” is a measurement on a real model, though of a small model on simple skills. What carries over to large models is the direction of each effect, not its size.
1. Two kinds of post-training data
1.1 Static data and executable feedback
Lecture 16 showed what post-training does. This lecture asks a practical question for each capability: what data and feedback would actually make the model better at it? There are two answers:
| static data (SFT, preferences) | executable environments (RL) | |
|---|---|---|
| a record is | , or | a task plus an environment whose state changes with the model’s actions |
| the label is | fixed when the record is written | computed after the model acts (tests, parsers, simulators, judges) |
| it teaches | protocol, format, tone, tool syntax, refusal style | exploration, recovery (“try → observe → fix”), when to stop |
Post-training is a data-and-feedback stack. Protocol SFT sets the defaults, vertical SFT teaches domain skills, and environments with verifiers let the model go beyond what its SFT data showed it.
1.2 A record has fields, and a taxonomy has more than one axis
An SFT record is a structured context (messages, tools, metadata) and a target continuation . A minimal record, as 01_records_and_pipeline.py stores it:
{"messages": [{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Sam is 35 years old. Give JSON."},
{"role": "assistant", "content": "{\"name\":\"Sam\",\"age\":35}"}],
"metadata": {"vertical": "structured output", "skill": "json", "verifier": "schema + exact", "lang": "en"}}
A tool-use record adds a tool catalogue with JSON schemas, and assistant turns with tool calls followed by tool results. The fields matter for two reasons:
- the same text is different data depending on its role and template (Lecture 16 §1);
- the metadata is what lets a team weight the mixture by slice and find which slice regressed.
The capability (“vertical”) is only one axis. The slides propose a minimal set of axes for every record:
| axis | values |
|---|---|
| interaction | single turn / multi-turn / trajectory |
| control | text only / tools / sandboxed execution |
| verification | none / weak judge / strong deterministic |
| difficulty | easy / medium / hard / adversarial |
| language | English + long-tail languages |
The same vertical, say coding, appears as “write a function” (single turn), “ask a clarifying question, then refine” (multi-turn), and “search the repo → edit → run tests → repair” (trajectory). These are different data.
1.3 SFT is behaviour cloning with a mask
The mask removes user turns, system prompts and tool outputs from the loss. Demo 01 Part A renders each record through Lecture 16’s chat template and counts the trained tokens:
| record | tokens | with gradient |
|---|---|---|
| add / reverse / upper (single turn) | 30–36 | 3 (8–10%) |
| json | 55 | 17 (31%) |
| repeat | 43 | 7 (16%) |
| refund conversation (multi-turn, tools; Lecture 16) | 443 | 167 (38%) |
SFT is behavioural cloning: the model maximises the likelihood of curated continuations. That fixes defaults: tone, format, tool-call syntax, refusal style. But the model cannot learn a strategy that is absent from its data. That limit is the reason for §6 onward.
The slides separate two kinds of SFT:
- protocol SFT teaches roles, refusal policy, tool-call syntax and output formatting;
- vertical SFT teaches the skills of each capability slice.
1.4 Quality has several dimensions, and what you do not measure gets optimised as a proxy
Five dimensions of SFT data quality:
- correctness: factual, logical, functional (can it be verified?);
- constraint adherence: format, style, policy, tool schemas;
- coverage: intents, domains, languages, edge cases;
- calibration: appropriate uncertainty, hedging and abstention;
- robustness: stable under rewording; not tied to one template.
The slide’s rule of thumb is worth memorising: if you do not measure a dimension, training will quietly optimise a proxy instead, usually verbosity, confidence or a pleasing style. Verifiers help because they keep at least correctness honest.
1.5 The mixture is a hidden hyperparameter, and biases propagate
SFT minimises cross-entropy on a weighted union of slices:
Changing changes what the model does by default: how often it calls tools, how often it refuses, which languages it handles well. Because SFT clones its data, the data’s biases become the model’s:
- a narrow labeller pool makes that group’s norms the model’s defaults;
- over-represented regions crowd out others, and the model is confidently wrong outside them;
- cautious labels make the model refuse benign requests;
- if most examples hedge, the model hedges everywhere;
- fixed tool orderings in traces make the model fail when the tools change.
Section 5.4 measures what mixture weights do to a real student.
2. The behaviour verticals
Lecture 16 evaluated eight capability slices. The same eight slices organise the data:
| vertical | context | target output | how it can be verified |
|---|---|---|---|
| knowledge / factuality | query; optional documents or search tool | answer, direct or grounded | citation and entailment checks + judge |
| STEM & reasoning | problem + constraints | final answer (+ steps) | symbolic / numeric checks, unit tests |
| coding | repository context, errors, tests | patch + explanation | compile, tests, lint |
| instruction following | multi-constraint prompt | strict format (JSON, XML, …) | schema and regex validators |
| long context | long documents, several documents | summary + citations | span matching, retrieval checks |
| general agent | stateful task, tools | plan + tool calls + recovery | task success in a sandbox |
| search agent | browsing tool, source constraints | sourced synthesis | grounding checks, citation parsers |
| multilingual | locale, cultural norms | correct answer in the language and style | back-translation, human audit |
What each one adds, in brief:
- Knowledge has three modes. Answer from memory with honest hedging; decide whether to search (time-sensitive, niche or numeric questions); after searching, ground the answer in the results. The hard part is the decision, and then committing to the evidence rather than averaging it with the model’s prior.
- Failure modes: blending parametric guesses into grounded answers; searching for everything (lazy) or never (overconfident); “citation laundering”, i.e. citations that are present but irrelevant.
- Reasoning data is made by sampling and verifying.
- DeepSeek-R1 ran RL on the base model (R1-Zero) and kept the highest-reward reasoning traces as a “cold-start” SFT set. After fine-tuning, it rejection-sampled the improved model to build a second SFT set.
- Qwen3 curated ~4K problems with verified answers, sampled several solutions per problem, and kept only those that passed the verifier.
- The chain of thought in such a record is the model’s own text, not hand-written. The verifier checks only the final answer.
- Coding data comes from real repositories.
- MiniMax’s pipeline mines merged GitHub pull requests with tests and builds a runnable Docker environment per PR. It extracts fail-to-pass tests (must flip after the patch) and pass-to-pass tests (must stay green), lets a model attempt the fix, and keeps only patches that satisfy both. The result is 140K+ tasks from 10K+ runnable PRs in 10+ languages.
- The same PR is reused as a bug-fix task, a test-writing task and a code-review task. The same Docker environments later serve as RL environments.
- Instruction following is checked by code, not by judges. For constraints like “exactly 3 bullets, no sentence over 10 words, end with ‘health’”, a regex or schema validator is cheaper and more accurate than an LLM judge.
- Generators create random, non-contradictory constraint sets and “challenge” prompts that break naive heuristics.
- Failure modes: over-specification (the model always answers in JSON, even when not asked) and template over-fitting.
- Long context needs distractors and span checks. Synthetic document bundles plant an irrelevant document and constraints in the middle (“lost in the middle”). A span-match verifier checks that cited sections contain the claim. Without it, the model learns to sound comprehensive while inventing.
- Agent data is simulated at scale.
- Kimi K2 gathered 3,000+ real MCP tool specifications from GitHub and generated 20,000+ synthetic tool variants. It created thousands of synthetic agents (system prompts × tool subsets) and simulated multi-turn use with synthetic users. A judge then filtered the trajectories by rubric. For math and code it ran real execution environments.
- The valuable turns are the error-recovery ones (“no flights Saturday; Friday is available, book that?”). They require trajectory data, not single-turn QA.
- Search agents: grounding checks first, then a judge. MiniMax’s WebExplorer samples hard multi-hop questions and lets an agent browse and write a cited answer.
- It verifies citation format, evidence coverage (at least one citation per claim) and span matches, and only then lets a judge score the writing. Rejected trajectories are recycled as negative examples.
- These trajectories can reach 200K tokens.
- Multilingual ability is easy to lose. Tool, code and reasoning SFT is overwhelmingly English. Without a stable multilingual slice in every stage, SFT overwrites what the base model knew. The checks are back-translation, script and encoding checks, cross-lingual consistency, and native-speaker review.
3. The curation pipeline
3.1 From specification to release
spec (vertical + rubric) → author / generate → filter & verify → normalise → mix & pack → release
↑ │
└──────────────────────── evaluation slices and regressions ────────────────────────┘
The slide’s key point: filtering and verification are the bottleneck. How good the verifier is decides how much of the synthetic data actually helps.
Humans are scarce and go where machines cannot check:
- generalist labellers (instruction following, style, safety);
- domain experts (medicine, law, math, security);
- “operator” annotators who drive tool interfaces for agent traces;
- reviewers who settle disagreements.
Their work is of four kinds: authoring ideal responses, editing synthetic drafts, grading, and adversarial probing to create hard negatives. Above all, they write the rubrics that the synthetic pipeline then scales.
A good rubric scores independent axes separately: correctness, helpfulness, format, safety, calibration. Vague rubrics produce style-optimised data. When the rubric is unclear, annotators fall back on their own preferences (usually verbosity and confidence), and judges trained on those labels amplify the same bias.
3.2 Generating synthetic data
Synthetic generation dominates modern SFT. It produces millions of examples, targets rare edge cases, and can be redone quickly when a rubric changes. Four methods:
| method | pitfall |
|---|---|
| self-instruct prompt expansion | distribution collapse: prompts start to look alike |
| teacher → student distillation | students inherit the teacher’s stylistic quirks |
| environment-generated traces (run an agent in a sandbox, keep verified runs) | only as good as the environment’s checks |
| programmatic templates (parameterised constraints, math problems, schemas) | narrow wording unless varied deliberately |
Hidden leakage cuts across all four: synthetic data can contain evaluation items or their paraphrases. Section 5 measures quirks, collapse and leakage.
3.3 Judges, rejection sampling and cascades
LLM judges are useful for style, clarity, tone and coherence, for pairwise comparisons on subjective axes, and for triage (which items should a human see?). They are not a substitute for deterministic checks:
- they favour their own model family;
- they reward persuasive phrasing over accuracy;
- they are sensitive to prompt wording.
The recommended cascade is: hard filters (schema, tests, grounding) → judge (style, coverage) → human audit of disagreements.
Rejection sampling (拒绝采样) is the SFT workhorse. Sample candidates per prompt, run the verifier , keep those that pass:
It turns a noisy generator into a high-precision dataset. A verifier cascade orders the checks by cost:
- syntax (JSON parse, tool-call schema);
- static analysis (regex constraints, lint, type checks);
- execution (tests, sandbox, retrieval);
- a judge, for what remains ambiguous.
Cheap checks reject obvious failures early, so the expensive ones run only on candidates that might be right.
3.4 Decontamination, diversity, safety, normalisation, versioning
- Decontamination.
- Benchmarks leak in three ways: directly, through synthetic paraphrases, and through public solutions in crawls.
- Defences: hashing and fuzzy matching against eval sets; keeping generators away from eval corpora; lineage metadata for every generated item.
- Diversity controls.
- Teachers produce high-probability text, so unconstrained prompt generators drift toward repetitive templates and safe topics.
- What works: latent variables in the generator (domain, difficulty, language, tool availability); n-gram or embedding dedup within shards; coverage quotas per slice; “trap” prompts with rare constraints.
- Safety and privacy are data requirements. SFT needs explicit refusal behaviour and safe-completion examples next to capability data. It also needs PII removal, suppression of rare memorisable strings, and provenance for audits.
- Normalisation. Canonical role names and tool-call structure; one chat-template version per release; token-level masks; render tests on serialised prompts. A template bug is a behavioural bug, not a formatting issue.
- Versioning. Post-training data is added, removed and reweighted continually, based on evaluation regressions. Without immutable shards with content hashes, a lineage graph and invalidation lists, no one can tell which data change caused which behaviour change.
- A release artifact contains:
- the template version and serializer;
- the tool-schema catalogue versions;
- shard manifests with hashes and sizes;
- the metadata schema;
- train/validation/test splits with contamination controls;
- audit logs (filter pass rates, judge score distributions, human review statistics).
4. A synthetic data system: NeMo Data Designer
4.1 Why “prompt and pray” fails
The guest lecture placed Data Designer between data curation (NeMo Curator filters and deduplicates raw web text, Lecture 10) and training. Curator produces clean text; Data Designer augments it or generates new data from scratch: SFT pairs, QA with reasoning traces, preference data, RL tasks.
The motivating fact is old: InstructGPT’s 1.3B model, trained on a small set of human-written demonstrations and preferences, was preferred by labellers over the 175B GPT-3. For instruction following, small targeted data can beat orders of magnitude more untargeted data, when it is well structured and quality-controlled.
Asking one LLM for 10,000 examples in one prompt (“prompt and pray”) fails in predictable ways:
- model collapse;
- schema drift;
- quality variance;
- low throughput;
- poor reproducibility;
- duplication;
- poor scalability;
- hallucination.
The answer is a compound AI system (Zaharia et al.): many calls to models, tools, validators and services, each doing what it is best at, including non-LLM components.
4.2 Columns and the DAG
In Data Designer the column is the building block:
| column type | what it does | cost |
|---|---|---|
| sampler | draws categories and numbers from stated distributions (uniform, Poisson for counts, Gaussian for measurements, conditional on another column) | free, exact |
| person / persona sampler | draws a whole synthetic person (Nemotron-Personas: 6M US personas grounded in census-style demographics; collections for Japan, India, Singapore, Brazil) | free |
| seed column | brings in existing (possibly proprietary) data for part of the schema | free |
| expression | fills a Jinja template from other columns | free |
| LLM text / code / structured | sends a rendered prompt to a model | model calls |
| validator | lints or executes code, calls a local function or a remote endpoint | cheap to moderate |
| LLM judge | scores another column against a rubric | model calls |
Columns refer to each other with {{ name }}. The engine resolves the references into a DAG (有向无环图) and fills the table column by column in parallel batches. The workflow is configure → preview (5–10 rows, read them!) → iterate → create at scale.
designer.py implements the idea in ~350 lines. Demo 01’s pipeline has 12 columns:
- five samplers: skill, content, phrasing, persona, whether to use a preamble;
- two expressions: the preamble and the prompt;
- the teacher (an LLM column);
- a format validator and an exact checker;
- a judge;
- a “keep” rule.
The engine sorts them by their references; the self-test declares them backwards and still gets a valid order. A preview row looks like this:
| prompt | teacher response | format ok | correct | judge | keep |
|---|---|---|---|---|---|
| As a teacher from Oregon, Extract name and age as JSON: Finn (56). | {"name":"Finn","age":56} | True | True | 5 | True |
| Turn eldy around, last letter first. | eydl | True | False | 2 | False |
4.3 What the pipeline costs and what lineage buys (Demo 01)
On 3,000 rows:
| filter | rows kept | precision (kept rows that are correct) |
|---|---|---|
| none (raw teacher) | 3,000 | 73.0% |
| format validator | 2,729 | 80.3% |
| judge ≥ 4 only | 2,330 | 85.6% |
| judge ≥ 4 only, judge from the teacher’s family | 2,489 | 80.1% |
| format + exact check | 2,191 | 100% |
| format + exact check + judge ≥ 4 | 1,994 | 100% |
Four lessons follow:
-
Where the cost goes. Only two of twelve columns call a model, and the judge takes 91% of the model tokens: it reads a rubric plus the response (we assumed a 400-character judge prompt). Running it only after the free checks saves 27% of its calls. Keeping 10,000 verified-and-judged rows takes ~15,000 generated rows (1.5×). The guest lecture’s rule was to overproduce 3–5× and keep the top tier; its text-to-SQL run kept 96.5K of 300K.
-
Use the cheapest correct column type. Asked to “pick one task type at random”, our simulated LLM chooses addition 45% of the time and repetition 6% (an assumed preference, but LLMs are known to be poor random number generators). It also costs 3,000 calls. A sampler gives 20% each for free. The guest lecture’s order of preference: sampler → expression → LLM text → structured → custom. Do not spend LLM tokens on decisions a coin flip can make.
-
Lineage. Each cell draws randomness from its own stream, seeded by (seed, column, row). An edit therefore changes only the columns downstream of it:
edit columns whose content changed rerun the same config none judge from the teacher’s family judge (but not keep: the exact check already decides) teacher quirk rate 6% → 0% response, format_ok, correct, judge, keep skill weights: addition ×2 everything except the persona and preamble columns This is “data as code”: reproducible rows, reviewable logic, traceable changes. One catch we hit: a config hash sees only what the config declares. A setting hidden inside a Python function does not change the hash, so model and judge settings belong in the config.
-
Personas multiply wording. A 480-entry persona table yields 159 distinct preambles in 3,000 rows (“As a welder from Idaho, …”), against 16 in a hand-written list. Persona sampling is how Data Designer adds entropy. Karpathy’s comment, quoted in the guest lecture, is that people do not appreciate enough how much diversity and richness matter.
4.4 Case A: text-to-SQL, checked by a real database (Demo 02)
The guest lecture’s Case A builds fine-tuning data for natural-language-to-SQL in six steps:
- Conditional samplers for the axes: industry → topic, difficulty → SQL concept (Advanced → window functions), instruction style (imperative, interrogative, declarative, contextual).
- A request in plain English, grounded in step 1.
- A schema: CREATE TABLE + INSERT statements.
- The SQL that answers the request.
- Syntax validation by a code validator.
- An LLM judge scoring relevance, correctness, readability and efficiency.
sql_world.py builds the same pipeline over six tables, six concepts and four styles. The SQL teacher is simulated: each query is either the gold query or a labelled mutation, so the truth is known. Every query really runs in sqlite3. On 3,000 rows:
| filter | kept | precision | recall | cost per row |
|---|---|---|---|---|
| none | 100% | 68.6% | 100% | – |
syntax validator (sqlite EXPLAIN) | 87.3% | 78.6% | 100% | 24 µs |
| judge only | 76.1% | 81.3% | 90.2% | 1 judge call |
| syntax + judge (Case A’s pipeline) | 74.2% | 83.4% | 90.2% | 1 judge call |
| execution = reference, on the 6 example rows | 79.3% | 86.5% | 100% | 103 µs |
| execution = reference, on a stress table | 68.6% | 100% | 100% | 247 µs |
| majority of 5 samples agree (no reference) | 67.2% | 91.7% | 89.8% | 4 more samples |
Which mistakes pass which check:
| teacher output | syntax ok | judge ok | exec on 6 rows | exec on stress table |
|---|---|---|---|---|
| syntax error / invented column | 0% | 15–16% | 0% | 0% |
>= for > | 100% | 64% | 92% | 0% |
ROW_NUMBER for RANK | 100% | 70% | 99% | 0% |
AVG for SUM, LIMIT k+1, ASC for DESC | 100% | 57–68% | 0% | 0% |
Four lessons:
- A syntax check is exact for what it checks. It rejects every typo and invented column, and passes every silent semantic error.
- Execution beats judgment, but only on data that separates the queries. A 6-row example table has no ties and no row at the threshold, so
ROW_NUMBER-for-RANKpasses 99% of the time and>=-for->92%.- The stress table plants boundary values, ties, a group of exactly rows and a row at the average. It is built from the request’s own constants, so it needs no gold query.
- Its 100% is by construction, since it was designed against this teacher’s mutations. A real stress test catches only the mistakes its author anticipated.
- Weak tests are a weak verifier.
- Voting removes random errors, not systematic ones. Without any reference, keeping a query whose result agrees with a majority of 5 samples reaches 91.7% precision. But for “rank with ties” the simulated teacher writes
ROW_NUMBERabout half the time, so the majority is wrong in 50% of rows and precision there is 24.4%. - Filtering reshapes the mix. Advanced tasks are 33% of what is generated and 23% of what survives the stress check. Keeping a target mix means generating per difficulty until each quota fills: 2.1× rows per kept Advanced row against 1.2× for Beginner.
4.5 The other cases
- InfiniByte (code). Cross-breed datasets, combining concept i from one dataset with concept j from another, to get new, harder problems, then generate solutions and reasoning.
- Multi-turn tool calling. A user-simulator agent seeded with Nemotron personas talks to the assistant. Lecture 20 describes Nemotron 3 Nano’s three-agent version: user, assistant and a simulated tool environment, filtered by a judge for consistency.
- Structured outputs. Seed topics → (document, schema, prompt) → JSON / YAML / XML completions. The released set has 5,000 samples, 6.8M tokens. In Nemotron Nano, the RL stage built on such data gained +8 points on a JSON-schema benchmark (89% → 97%) and on StructEval-Text (64.5% → 72.1%).
- Search tool calling. “Search riddles” built from multi-hop Wikidata paths, with a live search API through MCP. BrowseComp went from 0% to 12%.
- Prompt sensitivity. Keep each problem fixed and generate many judge-filtered variants of preamble and format instructions. Use them for SFT and RL, so accuracy holds across instruction styles. Section 5.5 measures the idea on our student.
4.6 The guest lecture’s design principles
- Diversity before volume. Samplers create coverage, and the LLM fills in content. Kimi K2: 10 rephrasings × 1 epoch beat 1 rephrasing × 10 epochs.
- Use the cheapest correct column type.
- Generate many, keep the best: overproduce 3–5×, filter to the top tier.
- Verify what you can (linters, parsers, schemas), including intermediate steps, and reserve judges for what is subjective. Feng et al.: without verification, synthetic data eventually degrades the model however much of it there is.
- Iterate on previews. Look at 5–10 rows, fix, repeat, then scale. The first generation is never good enough.
- Separate generation from scoring. The judge should not share the generator’s blind spots (Demo 01: 85.6% precision vs 80.1% for a same-family judge).
- Anchor generation in factual seeds.
- Build a curriculum by stratifying difficulty.
5. What the data does to a model
This section trains the student on the outputs of different pipelines. Recall §0.5: the teacher and judge are simulated, the student is real.
5.1 Rejection sampling: yield, cost and holes (Demo 03, Parts A–B)
The teacher’s output by skill (20,000 responses):
| skill | correct | random slip | systematic bug | “Sure! ” quirk |
|---|---|---|---|---|
| add | 71.3% | 22.5% | – | 4.4% |
| reverse | 68.2% | 6.6% | 18.8% (vowel-first words) | 4.8% |
| upper | 86.5% | 7.7% | – | 5.4% |
| json | 73.6% | 5.7% | 14.6% (ages ≥ 80 as strings) | 4.8% |
| repeat | 65.0% | 5.0% | 24.1% (k = 5 written 4 times) | 4.2% |
Rejection sampling with up to tries per prompt:
| prompts | P(pass) per try | kept, K = 1 | K = 4 | tries per kept row |
|---|---|---|---|---|
| addition, no carry | 83.3% | 83.3% | 99.9% | 1.20 |
| addition, with a carry | 54.2% | 54.2% | 95.6% | 1.85 |
| reverse, vowel-first word | 0% | 0% | 0% | never |
| repeat, k = 5 | 0% | 0% | 0% | never |
Two things happen:
- Hard prompts are under-represented, unless K is large. With K = 1 the kept set has 33.7% carrying additions against 44.2% of prompts; with K = 4 it has 43.9%, at 1.76 teacher calls per kept row.
- A systematic bug never passes, at any K. The verified set has holes exactly where the teacher is wrong: no vowel-first reversal and no “repeat 5 times” survives.
5.2 Random errors wash out; systematic errors are learned (Demo 03, Part C)
The same student is trained on five datasets of 30,000 examples each (reverse, upper, json, repeat; addition is left out here because its accuracy is luck at this scale, §5.4):
| training data | all | reverse | json | repeat | bug inputs that copy the teacher’s bug | “Sure!” greedy | “Sure!” sampled (T = 1) |
|---|---|---|---|---|---|---|---|
| oracle (true answers) | 99.8% | 99% | 100% | 100% | 0% | 0% | 0% |
| raw teacher | 83.8% | 76% | 84% | 76% | 96.2% | 0.0% | 6.6% |
| format-filtered | 85.9% | 76% | 91% | 76% | 67.5% | 0.0% | 0.0% |
| verified (K = 4) | 89.9% | 100% | 84% | 76% | 0% | 0.0% | 0.0% |
| verified + 300 human k = 5 rows | 96.8% | 100% | 88% | 100% | 0% | 0.0% | 0.0% |
- Random slips wash out. On the raw teacher’s data the student gets uppercase 100% right, although the teacher was right only 86% of the time. The slips point in different directions, and the model learns the majority.
- Systematic errors are learned. On the bug inputs, 96% of the student’s outputs are the teacher’s exact wrong answer. A consistent mistake is just another pattern to fit.
- A quirk is learned as a probability. Greedy decoding never shows “Sure!” (0.0%); sampling at T = 1 shows it 6.6% of the time, near the teacher’s rate. Evaluation is often greedy, so it hides the quirk; RL rollouts sample (Lecture 18), so the quirk is still there to be reinforced.
- Each filter removes what it can see. The format filter removes the quirk and the string-age JSON rows, but not the reversal and counting bugs.
5.3 Holes, and where human effort goes
Verified data removes every bug and leaves the holes. The student behaves differently in each:
- vowel-first reversals: 100%. Reversal is the same rule for every word, so it generalises into the hole;
- “repeat 5 times”: 0%. A count it never saw;
- ages ≥ 80: unpredictable. 46% after the format filter, 0% on verified data, 24% with the patch: the same hole, three outcomes. Asked for ages it never wrote, the verified-data student puts the 8 in the units place: 86 becomes “38”, 81 becomes “28”.
300 human-written k = 5 rows, 1% of the data, take “repeat 5 times” from 0% to 100%. Human effort pays most where the generator cannot produce the right answer and the verifier can only reject the wrong one. That is the slide’s “humans focus on what machines cannot check”, made concrete.
5.4 Mixtures (Demo 04)
Five pools of very different size:
- addition: 30,000 unique problems;
- reverse and upper: 8,000 each;
- repeat: 4,000;
- JSON: only 300.
The budget is fixed at 1,500 steps × 64 = 96,000 examples:
| mixture | add share | JSON share (epochs) | all | add | reverse | upper | json | repeat |
|---|---|---|---|---|---|---|---|---|
| proportional to pool size | 59.6% | 0.6% (1.9) | 31.2% | 8% | 43% | 62% | 0% | 42% |
| uniform (20% each) | 20% | 20% (64) | 88.2% | 50% | 100% | 100% | 92% | 100% |
| temperature τ = 0.5 () | 40% | 4% (12.8) | 76.0% | 59% | 94% | 98% | 30% | 99% |
| addition 40%, others 15% | 40% | 15% (48) | 96.8% | 98% | 100% | 100% | 88% | 100% |
What it shows:
-
A slice that is tiny in the mix can be absent from the model.
- The 300-row JSON slice gets 0.6% of the budget under proportional mixing, and JSON accuracy is 0% (2% even with twice the steps).
- Uniform mixing repeats each JSON row 64 times and gets 92%.
- Temperature sampling, the usual compromise, lifts small slices without flattening everything (30% at a 4% share).
-
Slices are not independent. Reverse, upper, JSON and repeat all copy letters from the prompt, and in the proportional mixture they are all weak together (0–62%). That happens although each one’s own share (15.9% for reverse) is the same as in the add-40% mixture, where they score 88–100%. Two explanations fit:
- one shared sub-skill (copying) gets 40% instead of 60% of the budget;
- addition, the slowest slice, dominates early training.
This run cannot tell them apart.
-
The verdict depends on the budget. With twice the steps, the proportional mixture reaches 78% (addition 99%, reverse/upper/repeat 96–98%). Most of its gap was slow learning, not a worse end point, except for JSON. Mixtures compared at one short budget measure speed as much as quality: the same caution as Lecture 13’s mid-run optimizer rankings.
-
Near the edge of what a model can learn, results are luck. Three seeds of the uniform mixture give addition 50%, 61% and 14%. With 40% of the budget it is 98%. A mixture comparison on one seed at this edge is noise.
-
Share is not the same as data. 40% of the budget spent on 1,000 addition problems seen 38 times each gives 99% on those problems and 78% on fresh ones. The same budget spread over 30,000 problems gives 98% on fresh ones. Nemotron trains small datasets for many epochs (Lecture 20). That is safe while the model generalises, and the gap between training and fresh accuracy is the signal to watch.
5.5 Prompt diversity and prompt sensitivity (Demo 05, Part A)
Four students are trained on 30,000 examples each. Only the wording of the prompts differs. They are evaluated on the training wording and on held-out phrasings and preambles. Held-out phrasings reuse the key words (“backwards”, “capitals”, “JSON”) in frames never seen in training.
| training prompts | seen phrasing | other training phrasings | held-out phrasings | held-out phrasing + held-out preamble | prompt sensitivity (std, points) |
|---|---|---|---|---|---|
| 1 phrasing per skill | 100% | 0% | 0% | 0% | 0.0 |
| 8 phrasings | 100% | 100% | 14.2% | 3.3% | 12.7 |
| 8 phrasings + persona preambles (50%) | 100% | 100% | 16.2% | 15.0% | 9.4 |
| composed (openers × 8 phrasings × closers) + preambles | 81.2% | 83.3% | 21.7% | 26.7% | 6.4 |
- One phrasing teaches the template, not the request. This student is perfect on its phrasing and scores 0% on every other one, even phrasings of the same request it could have learned.
- Diversity buys robustness to wording never seen. Preambles in training fix the preamble case (3.3% → 15.0%), and composing openers and closers raises held-out wording further. This is what Data Designer’s persona and phrasing samplers, and Nemotron’s prompt-sensitivity data (§4.5), are for.
- Diversity has a price at a fixed budget. The composed run is only 81% on the plain training phrasings, because the same steps are spread over far more wordings.
- A spread must be read next to the mean. Prompt sensitivity is the standard deviation of accuracy across phrasings, the metric Nemotron 3 Nano reports. The one-phrasing run scores a perfect 0.0 only because every held-out phrasing is at 0%.
A caveat on scale: the absolute held-out numbers are low because this student has no pre-training. A pre-trained model starts from far better generalisation across wording. The toy shows the direction of the effect, not its size.
5.6 Collapse at the source (Demo 05, Part B)
A simulated generator writes 5,000 reverse/uppercase prompts. It picks phrasings and words with a Zipf-like preference sharpened by temperature, an assumption standing in for an LLM’s preference for high-probability text:
| generator temperature | distinct words (of 2,000) | exact duplicates | left after exact dedup |
|---|---|---|---|
| 0.3 | 20 | 98.9% | 56 |
| 0.7 | 408 | 81.0% | 952 |
| 1.5 | 1,543 | 22.2% | 3,889 |
| 4.0 | 1,788 | 8.6% | 4,570 |
| sampler columns (uniform) | – | 7.8% | 4,611 |
Diversity is set where the data is generated; deduplication only removes the waste afterwards. At low temperature, 99% of the generation budget produced duplicates.
5.7 Contamination (Demo 05, Part C)
300 addition problems serve as an evaluation set. Of these:
- 100 leak into training as exact copies (20 copies each, as a benchmark copied onto many web pages would);
- 100 leak as paraphrases: same numbers, other phrasings, the “synthetic derivatives” of §3.4;
- 100 stay clean.
| eval items | student accuracy |
|---|---|
| exact copies in training | 90% |
| paraphrases in training | 56% |
| not in training | 13% |
| reported score on all 300 | 53.0% (vs 13% on clean items) |
| detector | flags exact copies | flags paraphrases | flags clean items |
|---|---|---|---|
| exact prompt hash | 100% | 1% | 0% |
| word 3-gram overlap | 100% | 87% | 3% |
| same numbers in a training addition prompt | 100% | 100% | 18% |
- Leaks inflate scores, here about fourfold, and paraphrased leaks inflate them too.
- Exact hashing misses paraphrases.
- Content matching catches everything, at a false-positive cost. It flags 18% of clean items, because random two-number problems collide with the ~22% of number pairs that occur in training anyway.
Short, templated items make decontamination hard. Lineage, knowing where each item came from, is the reliable defence.
One measurement subtlety: the leaked rows are also 4,000 extra addition examples, which changes how much addition the student learns at all. Accuracy on clean items moved from 72% to 13% between two runs that differed only in which eval items leaked: addition’s luck again (§5.4). The inflation is therefore measured within one run, as the gap between leaked and clean items.
6. Why SFT is not enough
The slides list four limits of behaviour cloning.
- It cannot discover strategies absent from the data. If no example shows backtracking, query reformulation or selective retry, the model has (almost) zero probability of producing them. The cases where this matters are debugging (try several edits, read the logs, revise), search (reformulate after irrelevant results) and agents (abandon a failing plan instead of repeating it).
- Covariate shift compounds over trajectories (协变量偏移). SFT trains on expert states; at inference the model visits its own, often wrong, states, and in multi-step tasks errors compound. Demo 06 Part D computes it. At a 5% error rate per step, a policy that never practised recovery finishes a 20-step task 36% of the time and a 50-step task 8%. Recovering from 80% of its errors raises those to 82% and 61%. On-policy rollouts are where recovery gets practised.
- SFT memorises, RL generalises (Chu et al., 2025). In two controlled environments (a card-arithmetic game and a navigation task) trained on one rule variant and tested on others, SFT’s held-out accuracy fell as training continued, while outcome-reward RL’s rose. SFT is still necessary first: without it RL is unstable and slow. SFT fixes the format and protocol; RL then optimises success within it.
- Conflicting annotators create incoherent defaults. Annotators resolve verbose vs concise, cautious vs confident, refuse vs comply differently and consistently, so the disagreement is not noise. Cross-entropy averages the contradictions into a model that hedges rather than following any coherent policy. The standard decomposition:
- SFT for unambiguous protocol defaults;
- preference learning for subjective trade-offs;
- verifiers for objective correctness.
So beyond SFT records we need:
- preference pairs;
- verifier-labelled outcomes;
- interactive rollouts with states, actions and rewards;
- failure traces: logs, tool errors, self-corrections.
Once success can be measured automatically, optimising against the measurement beats copying examples.
7. RL environments
7.1 What an environment is
For an LLM, the state is the token sequence so far: conversation, tool outputs, retrieved documents, scratchpad. An action is a token emission, a structured tool call, or a high-level action in a wrapper (click, type, open file). The environment returns the next observation, a reward and a done flag:
Environments add three things SFT cannot:
- multi-step credit assignment: which steps mattered, not just whether the end looked right;
- on-policy exploration: data from what the model itself does, including states no expert showed;
- adaptive stopping: when to keep going and when to commit.
The shift is from “reproduce an expert demonstration” to “maximise a success predicate through trial and feedback”.
Families in use in 2025–26:
- execution sandboxes: MiniMax’s Docker per PR, with fail-to-pass and pass-to-pass tests;
- tool simulators: Kimi K2’s 20K+ synthetic tools;
- web and browsing sandboxes: MiniMax WebExplorer, 200K-token trajectories; DeepSeek-V3.2’s synthesised agent tasks;
- math checkers: DeepSeek-R1, Qwen3;
- safety environments: adversarial prompts with refusal-correctness checks.
Good environments log everything, so a run can be replayed, debugged and distilled.
7.2 RL data is G rollouts per prompt
In GRPO/DAPO (Lecture 16 §5, Lecture 18), each prompt gets independent rollouts. A rollout is a single completion (math) or a trajectory (agent), and each one is scored. The advantage is relative to the group: the gradient comes from the contrast between successes and failures on the same prompt. Groups that are all right or all wrong carry no signal (DAPO’s dynamic sampling drops them).
envs.py implements a calendar task in the style of NeMo Gym’s Workplace Assistant: “Schedule a 1-hour meeting for lin and sarah at a time both are free.” It has tools free_hours, create_meeting and send_email, errors for conflicts and bad arguments, a step budget, and a reward computed from the final calendar. Demo 06 Part A shows one prompt’s group of 8 rollouts from a mix of behaviours:
| behaviour | reward | group advantage |
|---|---|---|
| check both calendars, then book | 1 | +0.72 |
| try hours, read the conflict errors, try the next | 1 | +0.72 |
| book a random hour | 0 | −1.21 |
| only claim success (send an email) | 0 | −1.21 |
Over 200 tasks per behaviour:
- checking and booking, and trying-and-recovering, succeed every time;
- guessing succeeds 22% of the time;
- booking twice, or merely claiming success, earns nothing.
Grading the state rather than the transcript is what makes the reward hard to fake: saying “I scheduled it” earns nothing, only a meeting in the calendar does.
7.3 Designing environments
- Align with the production API. If tools are presented differently in training than in production (schemas, error messages, rate limits), the model learns habits that break when deployed.
- Include realistic failures: timeouts, invalid arguments, partial results (our environment returns errors for conflicts and bad arguments).
- Enforce budgets on steps, tokens and tool calls.
- Version the environment with the model and the tool catalogue.
- Diversify, so the model meets as much kinds of feedback as possible.
Environments are engineering projects:
- security: sandboxing, no data exfiltration, no unsafe execution on an unvirtualised file system;
- reproducibility: seeds, pinned dependencies, cached verifier results;
- throughput: batched tool calls, parallel tasks, amortised start-up;
- observability: structured logs, failure clustering, cost tracking.
Open stacks (verl, NeMo-RL) treat environment servers and rollout orchestration as core components (Lecture 19).
7.4 Rewards, and how shaping can change the optimum
Reward sources:
- deterministic: unit tests, schema validity, exact or numeric match, task-completion predicates;
- learned: preference models, rubric graders;
- hybrid, the most common: deterministic checks gate correctness, a learned judge scores style and helpfulness, and safety constraints act as hard penalties.
Sparse binary rewards give zero-signal batches on hard problems, so every recent system shapes them in some way. DAPO adds four mechanisms on top of GRPO:
- dynamic sampling;
- a soft penalty for overlong responses instead of a hard −1;
- a token-level loss;
- asymmetric clipping (“clip-higher”).
MiniMax gives per-step process rewards, and Kimi k1.5 drops prompts with very high pass rates (Lecture 18 explains each one).
Shaping changes the optimal policy unless it is potential-based. A model may emit redundant tool calls for step bonuses, pad outputs to hit length targets, or exploit format loopholes. Demo 06 Part C makes it concrete with a progress task:
- work advances with probability 0.8;
- submit succeeds only at progress 3;
- the budget is 10 steps.
| reward | success | tool calls / episode | useless calls / episode |
|---|---|---|---|
| outcome only | 93% | 4.4 | 0.5 |
| outcome + 0.25 per tool call | 4% | 9.8 | 9.4 |
| outcome + potential shaping ( = 0.3 × progress) | 93% | 4.4 | 0.5 |
A per-call bonus makes “keep calling tools” optimal, and the policy learns exactly that. Potential-based shaping (Ng, Harada, Russell 1999) adds with at the end. Over an episode the added terms telescope to zero, so the optimal policy cannot change. In our REINFORCE learner it changed nothing at all. Its term depends only on the state, so the per-state baseline absorbs it. Its value is for learners that bootstrap from intermediate rewards (value-based methods).
The other mitigations:
- hard constraints (penalties, budgets) rather than positive rewards for intermediate steps;
- entropy bonuses or clip-higher rather than fake reward to keep exploration alive;
- auditing intermediate behaviour per slice before scaling: aggregate reward hides per-task gaming.
8. Verifiers
8.1 Verifier vs judge, and why precision matters more than recall
A verifier or checks objective correctness (tests, parsers, symbolic equivalence): run it twice and you get the same answer. A judge scores subjective qualities with a learned model, and its results depend on how it was trained and prompted. Desiderata for a verifier:
- high precision: few incorrect outputs pass;
- stability: small prompt perturbations do not flip decisions;
- low cost: millions of rollouts per run;
- decomposability: syntax → static → execution stages.
The slides argue that precision matters more than recall. A false positive tells the model “good job” for a wrong answer, while a false negative only withholds credit. Demo 06 Part B tests the claim with GRPO on tabular policies over 25 easy and 25 hard problems. Each problem has a correct answer in two surface forms, A and B, a hedged wrong answer, and three wrong answers. Two faulty verifiers misjudge the same 12% of the starting samples:
- low recall rejects correct form B;
- low precision accepts the hedge.
| verifier (after 300 steps) | easy: true accuracy | hard: true accuracy | hard: P(hedge) | hard: verifier’s pass rate |
|---|---|---|---|---|
| exact | 99.7% | 99.7% | 0.1% | 99.7% |
| low recall | 99.8% | 99.7% | 0.1% | 99.6% |
| low precision | 98.9% | 57.8% | 41.9% | 99.7% |
- Low recall only removes signal. Probability moves to the accepted correct form, and true accuracy ends where the exact verifier’s does.
- Low precision adds a competing target. On easy problems the correct answer starts likelier and out-grows the hedge: with equal rewards, softmax policy gradient favours whatever is already likelier. On hard problems the hedge starts as likely as the correct answers, keeps 42% of the probability, and true accuracy is 57.8% while the verifier reports 99.7%.
A false positive wins wherever it is at least as easy to produce as the right answer, which is where the model is weakest. That is also where Lecture 16’s foolable checker took over.
8.2 Patterns, graders, ensembles
- Deterministic verifiers by vertical: tests and lint for code, schemas and regexes for instruction following, equivalence and unit checks for math, task predicates for agents.
- Hybrid verifiers: grounding + entailment + judge for knowledge and search; span and contradiction checks for long context; back-translation + native-speaker audits for multilingual.
- RLVR / RFT optimise . Scaling then needs more rollouts, not more labels, and the bottleneck moves from annotation throughput to verifier precision and rollout infrastructure.
- Use direct verification wherever the task is executable. Learned reward models are cheaper than humans but approximate and gameable (Goodhart). When no deterministic check exists, teams train graders on human rubric labels (gold), adjudicated multi-judge outputs (silver) and red-team hard negatives. The graders must be calibrated against humans, or RL optimises the grader’s quirks.
- Ensembles: take the median or majority of independent judges. Treat disagreement as uncertainty: send it to a human or give a conservative reward of zero, and down-weight noisy slices.
8.3 Reward hacking and curriculum
Reward hacking is the default failure mode of RL:
- valid JSON with nonsense content;
- passing weak tests (Demo 02’s 6-row table is exactly that);
- persuasive fluff for a judge.
The mitigations:
- strengthen verifiers with more tests, fuzzing and property-based checks (Demo 02’s stress table);
- randomise prompts and test cases;
- keep private evals the policy never trains against;
- watch reward against held-out metrics: divergence is the alarm.
Curriculum by verifier difficulty.
- Start where the model often succeeds and the verifier is reliable, then add harder tasks and longer horizons.
- Bucket tasks by current pass rate and up-weight the frontier, where the model almost passes and learns most.
- Always keep a stability suite (instruction following, multilingual, safety) in the mix.
Lecture 20 shows Nemotron’s version: a Gaussian pass-rate curriculum.
8.4 One verifier, two uses
The same verifier filters SFT data offline (rejection sampling, §3.3) and computes rewards online (RL). Improving the verifier pays twice.
9. From rollouts back to data
Every rollout trace is a record: the serialised context (messages, tools, state), the actions, the observations, the rewards and verifier decisions. It has two uses: online RL updates, and offline distillation into new SFT data. Demo 06 Part D keeps 340 successful traces out of 500 logged rollouts:
- 215 check-then-book traces;
- 91 traces of recovering from a tool error, a behaviour the clean expert data did not contain;
- 34 lucky guesses that an outcome-only filter cannot tell from skill.
Distillation comes in three forms:
- Rejection-sampling distillation (offline, off-policy): run the RL-trained model, keep verified outputs, add them to the SFT set. The student never sees logits. DeepSeek-R1 does this twice, after each RL stage.
- On-policy distillation (online, logit-level): the student generates, and the loss is the token-wise KL to the teacher on the student’s own tokens, so it learns to match the teacher in the states it actually visits. Qwen3 does this.
- Off-policy distillation (offline imitation): SFT on the teacher’s pre-generated outputs. It is cheap, but subject to covariate shift.
Qwen3 used on-policy distillation for reasoning and off-policy distillation to fuse thinking and non-thinking modes, and reports about 10× less GPU time than RL for comparable math and code accuracy.
The flywheel: train or run RL in environments → evaluate by slice → mine and cluster failures → curate new SFT data and verifiers → repeat. The slides’ summary of strong post-training stacks:
- Verifier-centric scaling. A better verifier usually helps more than a different RL algorithm.
- Trajectory data for agents. Single-turn SFT cannot teach state tracking, recovery or stopping.
- Multi-slice stability suites in every mix and every release gate, because optimising one vertical (say, coding RL) can harm others.
The RL infrastructure itself has a policy (an inference engine), environment servers, a verifier service, a trainer, a reference policy for KL and a replay buffer. Most of the engineering is in the arrows between them. It is the subject of Lecture 19.
10. Summary
- Post-training data is records plus feedback. SFT records clone behaviour, and their metadata drives mixing and debugging; environments with verifiers provide what cloning cannot.
- A synthetic dataset is code. Declare it as columns in a DAG: samplers for decisions a coin flip can make, LLMs for content, validators and judges for checks. Preview it, give every cell a seeded stream, and record the config in a manifest.
- Verification sets the quality.
- Syntax checks are exact but shallow.
- Execution needs data that separates right from almost-right: weak tests are weak verifiers.
- Majority voting removes random errors, not systematic ones.
- Judges should come from a different family than the generator.
- What the student learns from the data (measured on a real small model):
- random teacher slips wash out; systematic bugs are copied (96%); quirks are learned as probabilities that greedy decoding hides;
- rejection sampling leaves holes where the teacher is wrong, and human-written rows fill them cheaply;
- mixtures decide which slices exist at all, and their effects depend on the budget and on shared sub-skills;
- near a capability edge, single-seed comparisons are noise.
- SFT cannot discover, recover or arbitrate. Environments add on-policy exploration and recovery.
- Environments should grade the final state, include failures and budgets, and log everything. Verifier precision matters more than recall, because a false positive becomes a target where the model is weakest. Shaping that is not potential-based changes the optimum.
11. Common pitfalls
- Asking an LLM to make decisions a sampler should make (task types, difficulty, personas): collapsed, skewed data and wasted calls.
- Not reading the preview.
- A judge from the same family as the generator, or a judge as the only filter for checkable properties.
- Execution checks on tiny example tables; majority voting as if it were verification.
- Filtering without watching what the filter removes: hard problems, rare inputs, whole regions of the input space.
- Treating greedy-decoding evaluation as proof that a quirk is gone.
- One seed per mixture, near the edge of what the model can learn.
- Comparing mixtures at one short budget.
- Repeating a small slice for many epochs without tracking train-vs-fresh accuracy.
- Only one phrasing per task, or evaluation on the training phrasings only.
- Decontaminating only by exact hash.
- Settings hidden in code instead of the config, so the manifest cannot see them.
- Rewarding intermediate steps with positive bonuses.
- Grading the transcript instead of the state.
- Distilling every reward-1 trace, lucky guesses included.
12. Exercises
- Rejection sampling cost. A teacher solves a problem class with probability 0.3 per try. With K = 4 tries, what fraction of prompts yields a row, and what is the expected number of teacher calls per kept row? What if a quarter of the prompts are ones the teacher always gets wrong?
Answer
Yield . Calls per prompt: , so calls per kept row. With a quarter of the prompts unsolvable (4 wasted calls each): yield ; calls per prompt ; per kept row . Unsolvable prompts are expensive, and they leave a hole.
- Random vs systematic. A teacher gives a wrong answer 20% of the time. In case (a) the wrong answer is random among 9 alternatives; in case (b) it is always the same wrong answer, on a fixed 20% of inputs. A student trained to convergence on unfiltered data predicts the most frequent label for each input. What is its accuracy in each case?
Answer
(a) For every input the correct answer has probability 0.8 and each wrong one ≈ 0.022, so the mode is correct: ~100%. (b) On the 20% of inputs where the teacher is always wrong, the mode is the wrong answer: 80%. Demo 03 shows the same thing: uppercase 100% from an 86%-correct teacher, and 96% of bug inputs reproducing the bug.
- Mixture by temperature. Pools of 30,000, 8,000, 8,000, 300 and 4,000 examples. Compute the shares for τ = 1 (proportional), τ = 0.5 and τ = 0 (uniform). How many epochs does the 300-row slice get in a 96,000-example budget under each?
Answer
τ = 1: 300/50,300 = 0.6% → 573 examples ≈ 1.9 epochs. τ = 0.5: weights √n = 173.2, 89.4, 89.4, 17.3, 63.2 (sum 432.6) → 4.0% → 3,840 ≈ 12.8 epochs. τ = 0: 20% → 19,200 = 64 epochs. Demo 04’s JSON accuracy for the three: 0%, 30%, 92%.
- Precision vs recall. On a hard problem the policy gives the correct answer probability 0.14 and an accepted wrong answer probability 0.12. Both get reward 1. Using the exact policy gradient for a softmax policy, , show that the ratio of the two probabilities never changes. What does that imply for the final policy?
Answer
With for both, and . With learning rate , changes by , which is small when . The log-ratio of the probabilities is , so it stays nearly fixed. All the other answers lose mass, and the policy converges to ≈ 0.14/(0.14+0.12) = 54% correct, 46% hedge. Demo 06 measured 57.8% / 41.9% on hard problems. With a sampled gradient the ratio drifts slowly toward whichever is likelier (“rich get richer”), which is why easy problems recover.
- Shaping. In Demo 06 Part C, why does +0.25 per tool call make spamming optimal, while +0.1 might not? (Hint: compare the return of idling for the whole 10-step budget with working to progress 3, which takes ~3.75 steps on average, and submitting.)
Answer
Idling for 10 steps earns 10 × 0.25 = 2.5. Working then submitting earns ~3.75 × 0.25 + 1 ≈ 1.94. With +0.1: 1.0 vs ≈ 1.375, so submitting stays better. Whether a bonus breaks the optimum depends on its size relative to the outcome reward and the budget, so it can look harmless in a short test and break later. Potential-based shaping is safe at any size.
- Decontamination by number matching. An eval set has 100 two-number addition problems (operands 10–99), and the training set contains 2,000 random addition problems. Roughly what fraction of clean eval items share their number pair with some training item? (Demo 05 counts it exactly for its data.)
Answer
There are 90 × 90 = 8,100 ordered pairs. 2,000 random draws cover about of them, so ~22% of clean items would be flagged: a high false-positive rate. Short templated items need lineage, not just matching.
13. The related assignment (concepts only)
Spring 2026’s NeMo Data Designer take-home suggests three projects:
- adapt the multi-turn tool-calling notebook to creative writing;
- adapt the structured-output notebook to other formats (XML, YAML, Markdown);
- design your own dataset from high-quality seeds such as Wikipedia.
It asks students to apply the design principles of §4.6, and to iterate with rule-based heuristics or a judge if SFT experiments are out of reach. The lessons of this lecture carry over:
- read previews;
- put decisions in samplers and checks in validators;
- separate the generator and the judge;
- track the mix after filtering;
- record everything in the config.
No solutions are given here.
14. Research directions
- Verifiers for open-ended tasks with measured precision; property-based test generation from task specifications (Demo 02’s stress table, automated).
- Holes in verified data. Detecting the inputs where the generator never passes, and deciding when to fill them with humans, a stronger teacher or programmatic answers.
- Mixture search under shared sub-skills. Choosing slice weights when slices transfer to each other; mixtures that are robust to the training budget.
- Diversity metrics that predict generalisation, beyond distinct-n and embedding spread.
- Environment portfolios. How many environments, of what kinds, and how to version them; detecting reward hacking across environments.
- Data lineage at scale. Invalidation that propagates through generated data; contamination audits for synthetic derivatives.
15. Further reading
- DeepSeek-AI, DeepSeek-R1 (arXiv:2501.12948); Qwen Team, Qwen3 (arXiv:2505.09388); Kimi Team, Kimi K2 (arXiv:2507.20534); MiniMax, Forge: scalable agent RL (minimax.io, 2026); DeepSeek-AI, DeepSeek-V3.2 (arXiv:2512.02556).
- Chu et al., SFT Memorizes, RL Generalizes (arXiv:2501.17161).
- Feng et al. (arXiv:2406.07515); Shumailov et al. (Nature 2024); Gerstgrasser et al. (arXiv:2404.01413).
- Ge et al., 1,000,000,000 Personas (arXiv:2406.20094); NVIDIA, Nemotron-Personas datasets (Hugging Face).
- Zhou et al., IFEval (arXiv:2311.07911); Pyatkin et al., IFBench (arXiv:2507.02833); Lambert et al., Tülu 3 (arXiv:2411.15124).
- Ng, Harada, Russell, Policy Invariance under Reward Transformations (ICML 1999).
- Ouyang et al., InstructGPT (arXiv:2203.02155); Gunasekar et al., Textbooks Are All You Need (arXiv:2306.11644).
- NeMo Data Designer (github.com/NVIDIA-NeMo/DataDesigner); NeMo-RL and NeMo Gym (github.com/NVIDIA-NeMo); verl (github.com/volcengine/verl).
16. Next lecture
Lecture 18 · Reasoning Models: RL Algorithms for Post-Training. This lecture built the data and the environments. Lecture 18 opens the update:
- the policy gradient and why it is noisy;
- baselines (critic, group mean, leave-one-out);
- importance weights and clipping (PPO, GRPO);
- the 2025 fixes (DAPO, Dr. GRPO, GSPO, CISPO) and which part of the objective each repairs;
- what RL does to a model: sharpening or discovery, pass@k, entropy, forgetting.
术语表 (Glossary, English → 中文)
| English | 中文 |
|---|---|
| static data / executable feedback | 静态数据 / 可执行反馈 |
| behaviour cloning / protocol SFT / vertical SFT | 行为克隆 / 协议式 SFT / 垂直领域 SFT |
| vertical / slice / data taxonomy | 垂直能力 / 数据切片 / 数据分类体系 |
| record / metadata / loss mask | 数据记录 / 元数据 / 损失掩码 |
| mixture weight / temperature sampling | 混合权重 / 温度采样 |
| rubric / annotator / adjudicator | 评分细则 / 标注员 / 仲裁员 |
| synthetic data generation (SDG) / compound AI system | 合成数据生成 / 复合 AI 系统 |
| sampler column / conditional sampler / expression column | 采样器列 / 条件采样器 / 表达式列 |
| persona / seed data / seed anchoring | 人设 / 种子数据 / 种子锚定 |
| validator / LLM judge / verifier cascade | 校验器 / 大模型评审 / 验证级联 |
| rejection sampling / overproduction / yield | 拒绝采样 / 超量生成 / 产出率 |
| syntax check / execution match / stress table | 语法检查 / 执行结果匹配 / 压力测试表 |
| self-consistency / majority vote | 自洽性 / 多数投票 |
| random error / systematic error / style quirk | 随机错误 / 系统性错误 / 风格怪癖 |
| coverage hole | 覆盖空洞 |
| prompt sensitivity / held-out wording | 提示敏感度 / 留出措辞 |
| model collapse / deduplication / distinct-n | 模型坍缩 / 去重 / distinct-n 多样性指标 |
| contamination / decontamination / lineage / manifest | 数据污染 / 去污染 / 数据血缘 / 数据清单 |
| covariate shift / compounding error | 协变量偏移 / 误差累积 |
| RL environment / sandbox / environment server | 强化学习环境 / 沙箱 / 环境服务器 |
| state-based verification / step budget | 基于状态的校验 / 步数预算 |
| rollout / trajectory / group advantage | 推演 / 轨迹 / 组内优势 |
| reward shaping / potential-based shaping | 奖励塑形 / 基于势函数的塑形 |
| precision / recall / false positive / false negative | 精确率 / 召回率 / 假阳性 / 假阴性 |
| grader / calibration / ensemble | 评分器 / 校准 / 集成 |
| reward hacking / stability suite / curriculum | 奖励投机 / 稳定性测试集 / 课程学习 |
| rejection-sampling distillation / on-policy distillation | 拒绝采样蒸馏 / 同策略蒸馏 |
| data flywheel | 数据飞轮 |