Nathan Lambert
Corrections and reader questions from the GitHub, Discord, and YouTube comments. Lectures 5-7-ish.
A sharp-eyed viewer flagged the “KD as an RL advantage” slide:
The slide is missing a \pi_\theta(a_t \mid s_t) multiplier for A_t^{\mathrm{OPD}} (since it’s for a single token, else it would be the expectation). Also, the negative reverse-KL on the top line looks like the forward-KL on the second line, which can be confusing.
What the slide showed:
Source: viewer feedback on Lecture 7
The reverse KL at state s_t is an expectation over student-sampled tokens:
You never sum over the vocabulary: the single sampled token is an unbiased estimate \hat{D}_{\mathrm{KL}} of that KL, and the advantage is its negative:
I called the KL divergence a “distance” a few times. A viewer rightly pushed back:
KL is asymmetric (D_{\mathrm{KL}}(P\|Q)\neq D_{\mathrm{KL}}(Q\|P)) and violates the triangle inequality — so it is not a metric.
Fair — and I battled my editors on this too. In post-training teams “KL distance” is common colloquial shorthand as “how much has the model changed,” but technically it is a divergence.
For reference, some information theory:
Source: viewer feedback on Lecture 0
In RL we rarely compute the exact KL — we estimate it from sampled tokens. John Schulman’s note on the k_1 / k_2 / k_3 estimators (which is low-variance, which stays positive) is essential lore for anyone touching a KL penalty:
The reward model maximizes the Bradley-Terry preference probability, then manipulates it into the loss (all for a single example (x, y_c, y_r)):
Clean per-example — but training is over a dataset. Where does the average go?
A reader noted the reward-model derivation maximizes the per-example preference probability, then converts straight to the -\log\sigma loss (writing \Delta = r_\theta(y_c \mid x) - r_\theta(y_r \mid x)):
That last step is only valid pointwise. Training is over the dataset, and \mathbb{E}[P] \neq \mathbb{E}[\log P] – so you take the \log before averaging. The honest version is maximum likelihood:
Source: issue #461 (chrisnota)
Yes — five chapters end with a Suggested Experiments section: runnable code in the companion code/ library, each with knobs to vary and a question to answer.
reasoning-gym task with Qwen3-1.7B.Start with Ch 8 (DPO) or Ch 4 (SFT) — both run offline, no reward-model server or rollout loop. For “did I get the math,” the lecture derivations (DPO in Lecture 6; policy gradients in Lectures 3–4) are the worked problem sets.
I’m happy to see more PRs on GitHub discussing how to improve this!
Source: viewer question on Lecture 0
An interactive way to see what each post-training stage does — read the same prompt answered by instruction-tuned and RLHF’d model variants, side by side.
Pick a prompt, compare completions across stages, and watch the base → assistant → aligned transition in real outputs. (Let’s open it.)
A careful reader (issue #464, chrisnota) caught three notation inconsistencies in the policy-gradient chapter.
Source: issue #464 (chrisnota)
The chapter opens in Sutton & Barto indexing — the reward after (S_t, A_t) is R_{t+1} — but later equations silently switch to zero-indexed r_t:
Fix: pick one. The section is framed in Schulman’s notation (rewards from zero), and the rest of the chapter uses lowercase r_t — so Eq. 24-25 should match: lowercase r_t, indexed from zero throughout.
Source: issue #464 (chrisnota)
Which part is inside the derivative? This is ambiguous — it reads like A might depend on \theta:
Fix: move the scalar advantage to the front. Now it’s unambiguous that \nabla_\theta acts only on \log \pi_\theta, and A is just a weight:
The advantage is a detached scalar — it scales the score-function gradient, it is not differentiated.
Source: issue #464 comment (chrisnota)
The chapter bounces between two expectation subscripts, and one is under-specified:
Fix: the trajectory distribution is p_\theta(\tau) — induced by the initial state, the policy, and the environment dynamics — which the chapter already defines in Eq. 33:
\pi_\theta alone is a per-step action distribution; only p_\theta is a distribution over whole trajectories.
Source: issue #464 (chrisnota)
REINFORCE is written as a gradient; PPO as an objective (Chapter 6, Eq. 71 vs 72). Why?
Same idea, two forms — so why write them differently?
Source: @awais on Discord (Chapter 6)
The clipped surrogate:
The gradient does exist – but \min and clip make it piecewise: it equals \rho_t A_t\, \nabla_\theta \log \pi_\theta(a_t \mid s_t) in the active region and goes to zero once \rho_t leaves the trust region on the penalized side.
In code both are one scalar loss you call .backward() on – so the distinction is mostly pedagogical.
Source: reader follow-up (Chapter 6)

New figure added to Chapter 6 (PR #462, zafstojano)
Questions, comments, and future Q&A prompts: