TensoriumInterview preparation
← Home

Tensorium onboarding flow

From “the cat …” to a language model

A self-paced introduction for technical people new to LLMs. Read each chapter’s explanation first, then explore its visuals one step at a time. Follow the same sentence through text, representations, a Transformer, generation and learning.

12 chapters · 59 short scenes · optional practice · no locked steps

An explanation you can defend

Learn the mechanism, then explain the trade-off.

First follow one sentence through a small Transformer. Then use optional teach-backs, experiments, and short coding exercises to make the explanation your own. Nothing locks the next chapter.

  1. Distinguish a Transformer from attention alone.
  2. Trace tokens, states, block operations, and logits.
  3. Derive attention and detect future-token leakage.
  4. Separate training updates from inference.
  5. Compare model changes by benefit, cost, and evidence.
Already know the basics? Explore GPT-2 → DeepSeek-V3 → Kimi K2 design trade-offs

Viewing a chapter is not proof of understanding. Teach-backs use self-review; code checks validate small examples, not overall mastery.

Read chapter 10: Gradients and optimizers change parameters

How does a loss tell us what to change?

After this chapter: Distinguish the forward pass, backpropagation, and the optimizer update.

A loss measures the training objective, but it does not change the model by itself. We need to determine how the loss depends on each parameter.

A gradient describes the local rate of change: if we slightly increase a parameter, which way does the loss move, and how strongly? On the curve, think of the gradient as the slope at the current parameter value. It describes nearby behavior, not a guarantee about a large move.

Backpropagation calculates gradients by following the dependencies of the computation backward. An optimizer then uses those gradients to update the parameters. These are separate jobs: computing a gradient does not itself change a weight.

For simple gradient descent, new parameter = old parameter − learning rate × gradient. In the standalone scalar example, the parameter is 0.8, the gradient is 0.5, and the learning rate is 0.1. The new value is 0.8 − 0.1 × 0.5 = 0.75. A positive gradient makes this update move downward; a negative gradient makes it move upward.

The chapter then returns to an actual output-head weight in our toy model. After changing it, we recompute the same prefix’s probabilities and loss. This particular local update improves its target loss. That does not mean every training update improves every example.

AdamW is another optimizer. It maintains running statistics of gradients and squared gradients, corrects their initial bias, and uses them to scale updates. It also applies weight decay separately from those gradient statistics. Understand that division of responsibilities before trying to memorize the full formula.

Earlier embedding, attention, and feed-forward parameters can also be trained. The walkthrough labels its methods separately: the output-head calculation uses an analytic gradient, while the earlier-parameter examples estimate gradients by small numerical perturbations.

Keep this idea

Backpropagation computes gradients. The optimizer changes parameters.

Now explore the visual

Follow the slope, the resulting parameter update, and the recomputed output. Keep the standalone 0.8 → 0.75 arithmetic example separate from the actual toy-model weight.

Use Next step below to move at your own pace. You can reopen this explanation from any scene in the chapter.

Next, we will look at the learning rate that sets the scale of each update.

Chapter 10 / 12 · Gradients and optimizers change parameters

Follow the calculation backward

Chapter scene 1 of 6 · Next step controls this detailed explanation

Our recurring sentence: the cat sat on the mat
parameter W[feature 1, sat]-1.222
× state feature -1.667 ↓
add other products + biassat logit -0.431
softmax across vocabulary ↓
P(sat)65.0%
− natural log ↓
target loss0.431
Backward: loss → probability → logit → parameter gradient 0.583

Continue backward through the head into the block and embedding lookup. Earlier parameters also affect the loss; no parameter has changed yet.

Play advances within this chapter every 14 seconds. Pause to inspect; Next never requires an answer.

Place remembered on this device. Chapters are directly linkable; use the address bar to share the current scene. Keyboard: left/right arrows when outside a control.

Make this chapter your own · optional practice

Read and explore first. Then explain it without looking, compare the worked answer, and try a changed example. You can leave and return without losing your draft in this browser.

Explain it in your own words

Distinguish the forward pass, backpropagation, and the optimizer update. Try aloud first, then write your explanation. Compare it with a worked explanation, not a keyword score.

No reference consulted yet.
Change the situation: Would using w += rate × gradient minimize this loss locally?

It goes in the ascent direction for a positive learning rate, rather than the negative-gradient direction.

Draft and self-review saved in this browser, not to your account. Do not enter confidential information on a shared device.

Show the model details and provenance

Deterministic teaching trace v1, vocabulary IDs permuted to distinguish identity from position; each word retains its original embedding and next-token probabilities. The numerical model has 8 vocabulary entries, 4 features, 2 attention heads of 2 features, one pre-LayerNorm block, 8 GELU hidden units, learned-position tables, final LayerNorm (epsilon 0.00001), and an untied output head. Parameters are hand-authored, not learned from a corpus. The output head is calibrated by a four-equation solve to give the next token 65% and each of seven alternatives 5% on four demonstration prefixes. All later activations, probabilities, losses and local derivatives are computed from these same parameters. The output-head gradient is analytic; earlier embedding, query-weight and feed-forward-bias slopes are explicitly labelled central-finite-difference estimates. The Word2Vec map and the standalone SGD/AdamW examples are separately labelled illustrations. Source: src/lib/llmJourney/{numbers,model,training}.js. No actual LLM is called or downloaded.

{
  "attentionOutputProjection": [
    [
      0.14641127923648062,
      -0.2694030992674085,
      -0.28534247505748717,
      0.12225196631435749
    ],
    [
      -0.3499898627155085,
      0.304777848091882,
      -0.17851121408531348,
      0.00477013728751681
    ],
    [
      0.1512332961032762,
      -0.3304774710513706,
      0.31472392260927506,
      -0.11326800780012626
    ],
    [
      0.22137536557939866,
      0.3456861375716631,
      0.12671029797581895,
      -0.21809629998076752
    ]
  ],
  "feedforward": {
    "up": "4 × 8",
    "activation": "GELU (tanh approximation)",
    "down": "8 × 4"
  },
  "layerNorm": {
    "epsilon": 0.00001,
    "scale": 1,
    "offset": 0
  }
}
Show the code structure
# Architecture pseudocode, not an executable training script
x = token_table[token_ids] + position_table[positions]
x = x + attention(layer_norm_1(x), causal_mask=True)
x = x + linear_down(gelu(linear_up(layer_norm_2(x))))
state = final_layer_norm(x)
logits = output_projection(state)
probabilities = softmax(logits, vocabulary_axis)
# Training only: loss = mean(-log(P(observed_next_token)))
# backward computes gradients; optimizer changes parameters
# Inference only: select token, append, run again

Executable deterministic calculation and focused tests are maintained with this course; no external LLM service is used.

Primary references