Start with the data the model actually gets to see:

  1. Give it a good answer to imitate. What does supervised fine-tuning (SFT) teach, and what if the demonstrations leave something out?
  2. Ask someone to choose between two answers. Knowing which answer they preferred isn't the same as knowing why.
  3. Try four answers to one multiplication problem. PPO compares each result with the critic's prediction. GRPO compares it with its peers. Offline DPO takes a labeled pair instead.

For a closer look, work through a clipped PPO update, or check whether a lower DPO loss means the preferred answer got more likely. The full directory includes classic RL and training infrastructure; neither is a prerequisite for trying the example.

33 core notes, about 5 h. 23 deep dives fold under the notes they extend.

Fine-tuning & distillation5 core · 2 deep

Teaching by example after pretraining: SFT, rejection sampling, LoRA-style tuning, distillation

  1. Post-Training: what does a model still have to learn after pretraining?Separate signal from parameters, then SFT, preferences, RL, systems and costs8 min
  2. SFT: how a conversation becomes a training signalMean loss hides key tokens: a refund call falling from 0.9 to 0.1 adds only 0.01112 min
  3. Rejection sampling: generate more, then keep what?Returning the best answer is not training on survivors, which skews easy:hard to 8:18 min
  4. Model Adaptation: Full Fine-Tuning, LoRA, Prompt Tuning, and DistillationSignal and parameters are separate axes; scoring or constraints keep labels valid11 min
  5. Prompt, prefix, and adapter tuning: what can change around a frozen model?Model frozen, what's left to train: prompts, prefixes, adapters and LoRA, counted6 min
  6. LoRA and QLoRA: fewer parameters, but still out of memory?r=8 trains 0.39% of a 4096×4096 matrix, yet activations stay; QLoRA shrinks the base8 min
  7. Distillation: what is the student learning from the teacher?Answers, probabilities or feedback on the student's prefixes; top-k hides the tail20 min

Rewards & preferences2 core · 2 deep

Where feedback comes from: what reward models learn, ranking answers, programmatic checks

  1. Where preferences come from, and what a reward model actually learnsPreferences fix order, not scale: adding 10 keeps 0.731, doubling turns it into 0.88113 min
  2. What a reward model predicts: preferences, outcomes, steps, and valueThe same 0.8 can mean different things: check labels, loss positions and scoring11 min
  3. Reward models: training on several responses to one promptFour ranked answers give six pairs, not six judgments; scores compare within a prompt9 min
  4. Verifiable rewards: did passing the tests complete the task?With one test, [3, 1, 2], always returning [1, 2, 3] passes: repeatable, not airtight11 min

How RLHF runs8 core · 1 deep

RL on a language model: three stages, four models, and what value, KL and clipping do

  1. RLHF: learning from feedbackComparisons as feedback, then token actions, value, old data, clipping and evaluation3 min
  2. RLHF: mapping ordinary RL onto a language modelPrefix as state, next token as action: in “2 + 3 =”, the point comes only at the end5 min
  3. RLHF: reward, value, and advantageReturn, value and advantage per token, worked on three tokens with a 0.1 KL cost4 min
  4. On-policy and off-policy: can we train on old answers?Every second-step ratio is 1, yet success goes from 0.35 to 0.65: prefixes shift too11 min
  5. RLHF: three stages and four modelsA three-sentence email summary via demos, comparisons and RL; Actor and Critic train3 min
  6. Reference and Critic: measuring drift versus estimating returnScoring 1 is +0.1 on an easy prompt, +0.9 on a hard one; the Reference prices drift7 min
  7. Three KL estimators: similar values, different gradientsOne k1 sample is −0.92, the mean 0.19; backprop through k3 gives 0.30, not 0.228 min
  8. PPO clipping: why not keep increasing the probability?“5” goes from 40% to 60%; ratio 1.5 is capped at 1.2: no extra push, no rollback7 min
  9. RLHF: evaluation and review questionsAt 0.5 per try, four tries succeed 93.75% of the time: rule out budget, length, judge8 min

Methods after PPO2 core · 4 deep

GRPO, DPO, RLOO, DAPO, GSPO: which part each changes, from baselines to clipping

  1. PPO, GRPO, and DPO: turning feedback into an updateOne sum, 17×24: PPO uses R−V, GRPO compares four answers, DPO reads 408 over 38826 min
  2. RLOO: use the other answers as a baselineBaseline from the other answers to a prompt; a plain group mean shrinks it by (K−1)/K7 min
  3. GSPO and ASPO: how should one answer share its gradient?A good answer, a falling token: GSPO's sequence-level mean, ASPO's inverted weight6 min
  4. Asynchronous RL: the model changes before the answer finishesGroup waits cost 23.5 s on average; skip them and ratios need rollout-time log-probs6 min
  5. DAPO: how sampling, length, and clipping change trainingDetails change the objective: one batch averages 2 per answer but 2.5 per token5 min
  6. What exactly is being clipped?Gradient left past the clip: PPO and dual-clip give zero, CISPO and SAPO keep some5 min

Experiments & trade-offs2 core · 2 deep

Running it for real: infrastructure, how far one base goes, alignment tax, and history

  1. Post-training infrastructure: sampling, numerics, contextLog tokens, weight versions, stop reasons; a wrong denominator can flip a ratio13 min
  2. How far one base model can goGLM-5.3 reportedly keeps 5.2's base; no one change can claim the 4.6% to 28.3% rise9 min
  3. Tech history: RL and post-trainingFrom Q-learning in 1989 to R1 and DAPO in 2025: what each solved and changed10 min
  4. Alignment tax: what else changed when the model improved?What to recheck after post-training: lower entropy shows focus, not correctness11 min

Classic RL: from MDPs to PPO7

Estimating value, turning reward into gradients, sizing a step: from Bellman to PPO

  1. Deep reinforcement learningTake 2 now or wait for 4: MDPs and TD, then policy, value, models, offline data11 min
  2. Q-learning, PPO, and DPO: what is each learning?Values, probabilities or pairs: DPO loss can fall while the chosen answer gets rarer7 min
  3. MDPs and Bellman: breaking the future into one stepStop for 2 or charge for 4 later: charging is worth 3.6 at γ=0.9, only 1.6 at γ=0.42 min
  4. MC and TD: wait for the outcome or bootstrap?Rewards [1, 0, 2]: MC targets 2.62, one-step TD 2.35; a time limit is not termination6 min
  5. Policy gradients: how does reward become a gradient?Reward 1 loses below a mean of 2; the min-variance baseline is 1.4, not the mean 2.68 min
  6. Actor–Critic and GAE: making credit assignment concreteλ trades bias for variance: the same TD errors give advantages from 1 to 1.997 min
  7. How much should a policy change? From natural gradient to PPOA coin policy with a 0.01 KL budget moves its logit 0.283; adding 2 costs KL 0.436 min

Value methods and model-based RL2 core · 6 deep

Why a learned Q drifts, choosing continuous actions, and planning with a learned model

  1. DQN: why learning Q with a network can be unstableTrue values 0, zero-mean noise, yet the max averages 0.5; Double DQN decouples them8 min
  2. From tables to networks: why better regression can mean worse valuesTwo states with true value 0: each regression improves, yet θ grows 1.08× per round6 min
  3. From DDPG to TD3: choosing continuous actionsThe actor follows the Critic's slope; TD3's smaller-of-two Q can underestimate11 min
  4. SAC: why add entropy to reward?Entropy redefines value: with Q = [0, 1] and α = 0.5, soft value is 1.06, above max Q7 min
  5. Model-based RL: prediction is not planningNext state −1 or +1, MSE predicts 0, maybe a wall; harder search exploits the errors9 min
  6. Which model to learn: states, observations, latent states, or just values?Eight cloud pixels cost as much as a misplaced box; value-only models may ignore it13 min
  7. Inside planning: CEM, LQR, and learning in a modelCEM keeps the best 10 of 100 sampled plans; LQR's exact u = −1 fails once |u| ≤ 0.29 min
  8. Combining planning and learning: search, value estimates, and policy distillationDyna replays one stored step to pass value back; a distilled planner can't replan14 min

Imitation, offline data and exploration3 core · 5 deep

Learning from demos, judging policies from old data, and exploring when rewards are rare

  1. Imitation and rewards: what demonstrations do not tell usSmall per-step errors compound to O(T²ε); DAgger asks the expert where learners go8 min
  2. MaxEnt IRL: inferring rewards from demonstrationsInferring reward from demos: the gradient is demo features minus the model's9 min
  3. GAIL: learning expert-like behavior without a task rewardNo reward written: a discriminator tells expert from policy, and that is the reward5 min
  4. Offline RL and OPE: what can old data tell us?A million logs of the same behaviour never reveal an untried action: check support11 min
  5. Offline model-based RL: which predictions should train the policy?Simulated steps aren't real attempts: MOPO penalizes risk, MOReL halts, COMBO curbs Q8 min
  6. Off-policy evaluation, one layer deeper: per-decision weights, doubly robust, and LSTDOn one bandit, IS has variance 21.28; DR with a biased model stays unbiased at 4.7518 min
  7. Exploration and uncertainty: what should we try next?A won 8 of 10, B 1 of 2: how UCB, Thompson sampling and information gain choose8 min
  8. Exploration and hierarchy: randomness is not a strategyTwenty right steps in a row: one-in-a-million by chance, half the time with skills6 min

Debugging, and the bridge to LLMs2 core · 1 deep

Check that RL learns the right thing, carry its intuitions to LLMs, and see why it stays hard

  1. The LLM bridge: which RL intuitions transfer?At 2% success only 14.9% of 8-sample groups differ; long tasks need not drop GRPO16 min
  2. Why RL remains hard to train: signal, cost, and stabilitySampling costs: keep a quarter of 64 × 8 long answers, still pay for 786,432 tokens13 min
  3. RL experiments: correctness before speedBoth average 18 over five runs, one via a lucky 50, one a steady 16–20: means hide it5 min