8.0 KiB
theme, title, info, author, transition, mdc, lineNumbers, monaco, aspectRatio, canvasWidth, layout, class
| theme | title | info | author | transition | mdc | lineNumbers | monaco | aspectRatio | canvasWidth | layout | class |
|---|---|---|---|---|---|---|---|---|---|---|---|
| seriph | Lesson 27 — When Should You Teach with Examples—and When with Rewards? | English video course for AI Agents in Depth | Bojie Li | slide-left | true | false | false | 16/9 | 980 | cover | cover |
When Should You Teach with Examples—and When with Rewards?
SFT, loss masking, distribution shift, and the form-first rule
layout: center class: text-center
Why this problem matters
SFT
Dense token-level supervision; stable and sample-efficient.
RL
Sparse trajectory feedback; costly but allows exploration.
Shift
Test whether the learned behavior survives changed rules and inputs.
Three ideas to keep in view
Loss masking
Supervise the assistant response—not the user prompt
Form first
Stabilize parsable output before optimizing strategy
Holdout shift
Change values or environments while preserving the rule
The book's visual model
Use SFT vs. Consider RL
Use SFT
- Known demonstrations
- Format/style/protocol
- Deployment matches training
Consider RL
- Outcome can be verified
- Many valid strategies
- Generalization under shift matters
SFT masks the prompt tokens
tokens = prompt_ids + response_ids
labels = [-100] * len(prompt_ids) + response_ids
loss = cross_entropy(model(tokens), labels)
loss.backward()
# only the demonstrated response is supervised
Test the claim
Audit retained VLM pre-training and SFT evidence
Observe: Hashed outputs, blind judgments, matched configurations, and negative results
Audit continued-pretraining trade-offs
Observe: New-language gain, retained English ability, and persistent factual errors
class: course-terminal
Switching to the terminal
$ python chapter7/MiniMind-pretrain/validation/validate_vlm_evidence.py
$ python chapter7/continued-pretraining/validation/validate_evidence.py
What the evidence supports
Finding 1
SFT efficiently learns explicit protocols represented in examples.
Finding 2
RL is justified when a verifier can reward strategies beyond one reference answer.
Finding 3
Training gains must be tested beside retention and distribution-shift failures.