TensoriumInterview preparation
← Home

Core concepts · 62 topics

A guided path through the ideas behind modern LLMs.

Read the stages in order: how text becomes a prediction, what happens inside the Transformer block, how a model learns, then serving, scale, and post-training. Every topic names what to know first, then gives the intuition, the math with concrete numbers, the common misconception, and a self-check. Already comfortable with the basics? Switch to By area and jump straight to a topic.

New to machine learning? Start here instead.

These topics work best as a refresher; they assume ideas like probability and loss. Begin with three short beginner lessons (tokens, embeddings, next-token prediction), then the visual walkthrough for attention and the Transformer.

Finish line: You can explain how text becomes a prediction and what training does to improve that prediction.

Topic 46 of 62 · Post-training

PPO, advantages, and clipping

Hard

What does PPO clip, and why doesn’t clipping the objective guarantee that KL divergence stays small?

Why this mattersPPO’s clipped importance ratio lets you take multiple gradient steps on a batch of rollouts without incentives for destructive policy jumps.

1 · Start with the intuition

When you collect a batch of rollouts from the policy π_old and want to take multiple gradient steps on that same batch to improve sample efficiency, standard policy gradient breaks down: as πθ moves away from π_old, the importance sampling ratio rₜ(θ) = πθ(aₜ|sₜ) / π_old(aₜ|sₜ) can explode and cause a destructive policy update. PPO’s clipped surrogate objective caps the reward incentive whenever rₜ(θ) moves outside [1 − ε, 1 + ε] in the direction that improves the objective—removing the gradient push on that token once it has moved far enough.

2 · How the mechanism works

Mechanism step 1 of 3 · no question to answer

Collect rollouts & advantages

Sample completions from π_old and compute token advantages Âₜ (using a critic + GAE, or group normalization in GRPO).

Next, we will look at: Form the probability ratio. Move on when this operation makes sense.

Visualizing the behavior

Where this sits: the RL-for-LLMs progression

VPGΨ = returnREINFORCER − baselineActor-criticlearned V(s)PPOclipped ratioGRPOgroup baselineVariantsDAPO · Dr. GRPO
Each step changes one thing: how Ψ (the weight on ∇ log π) is estimated, or how far one batch of samples may move the policy.

Clipped surrogate min(r·A, clip(r, 0.8, 1.2)·A), with ε = 0.2

Derived
-2-1010.40.811.21.6probability ratio r = πθ / π_oldobjective1 − ε1 + ε
  • A = +1 (good action)
  • A = −1 (bad action)
Good action: the objective stops rising once r > 1.2, so there is no incentive to push its probability further this update. Bad action: it goes flat below r = 0.8. In the unfavorable direction, the unclipped term stays active, so mistakes are still corrected.