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 18 of 62 · How a model learns

Adam vs AdamW

Medium

What changes between Adam with L2 regularization and AdamW, and why does it matter?

Why this mattersDecoupling weight decay from Adam’s adaptive moments is standard in modern LLM pretraining, and Adam’s two FP32 moments are a major reason training state takes ~16 bytes per parameter.

1 · Start with the intuition

There are two different jobs here. Adam uses past gradients to choose an update for each parameter. Weight decay asks each selected weight to shrink by a small fraction. If we put that shrinkage into the gradient, Adam will treat it like any other signal: mix it into its history and adaptively scale it. AdamW keeps the jobs separate, so the shrinkage means what we intended.

2 · How the mechanism works

Mechanism step 1 of 3 · no question to answer

Update task moments

Update the exponential moving averages of the task gradient (mₜ) and squared task gradient (vₜ).

Next, we will look at: Compute the adaptive step. Move on when this operation makes sense.

Visualizing the behavior

How much each weight shrinks per step (η = 0.001, λ = 0.1, θ = 1)

Illustrative

AdamW: decay = η·λ·θ, the same for every weight

A: large gradients (√v̂ = 1)
1e-4
B: small gradients (√v̂ = 0.01)
1e-4

Adam + L2: decay part ≈ η·λ·θ / √v̂

A: large gradients (√v̂ = 1)
1e-4
B: small gradients (√v̂ = 0.01)
1e-2
First-order view, holding √v̂ fixed and ignoring momentum. With coupled L2, Adam’s per-coordinate normalization rescales the penalty, so here weight B shrinks 100× faster than A. Weights with large gradient history are regularized relatively less. AdamW applies one uniform shrink rule. Log scale.