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 7: Assemble the Transformer

How do these operations fit together?

After this chapter: Reconstruct a pre-normalized decoder block, including its two residual paths.

We have examined individual parts. Now follow one representation through the whole Transformer block. Do not try to understand every arrow at once: trace the main path, one operation at a time.

First, normalize the representation. Layer normalization re-centers and rescales one token’s vector as a whole: all features share one mean and one stabilized standard deviation, with population variance computed by dividing by n, not n − 1. Learned per-feature γ and β can then scale and shift the result; ours are 1 and 0. Our block normalizes before attention, which is why it is called a pre-LayerNorm block.

Next comes attention. Our model has two heads. Both receive the same normalized input but use different learned query, key, and value projections, allowing them to produce different mixtures. The heads do not have predefined jobs such as “find nouns”.

Join the two head outputs side by side, then apply a learned output projection. This produces a four-number attention update. Keep a copy of the representation from before normalization and add the update to it, coordinate by coordinate. This is a residual connection: the existing representation plus an update, rather than a complete replacement.

Normalize this result again, then apply the feed-forward network from Chapter 4. It expands four features to eight, applies GELU, and returns four features. Unlike attention, this operation works on each position separately. All positions use the same feed-forward weights.

Add this feed-forward update to the representation saved before the second normalization. That is the second residual connection, and it completes the block: normalize → attention → add; normalize → feed forward → add.

Larger GPT-style models stack many blocks with different parameters. Our tiny model deliberately uses one. A separate final normalization and the same output head act at every position to produce eight vocabulary logits per position. Generation from “the cat sat” reads only the final position, “sat”; training scores every supplied position against its own next-token target, without allowing future-token access. The next chapter explains how those scores lead to a continuation.

Keep this idea

Attention mixes information across positions. The feed-forward network transforms information within each position. Residual connections add their updates to the existing representation.

Now explore the visual

Use the diagram’s step controls to follow normalize → attention → add → normalize → feed forward → add. Trace each bypass separately to see what is being preserved and added.

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

Next, we will turn the final representation into probabilities for the next token.

Overview operation 1 of 14

Token IDs

One Transformer, end to end: follow “the cat sat” through the same toy model. These 14 overview operations have their own controls; the 8 detailed chapter scenes and Next step are below.

Operation 1 / 14
Complete decoder-only Transformer: input to next tokenOne pre-normalized decoder block with two parallel causal attention heads and two residual bypasses. Arrows show data flow. Select an operation to inspect it.INPUT REPRESENTATIONSONE PRE-LN DECODER BLOCK · 2 HEADSNEXT-TOKEN OUTPUTSaved input · bypassSaved input · bypassthe · cat · satToken IDs: 5 · 2 · 7Token embeddings3 tokens × 4 features+ Position vectorsPositions: 0 · 1 · 2LayerNorm 1Normalize each tokenHead 1Q K V · causalHead 2Q K V · causalConcat → projection2 + 2 = 4 → W_O → 4+ Residual inputInput + attention updateLayerNorm 2Normalize each tokenFeed-forward4 → 8 (GELU) → 4+ Residual inputInput + feed-forward updateFinal LayerNormCompleted block stateLanguage-model head4 → 8 at every positionSoftmax8 vocabulary probabilitiesNext token: on65.0% · greedy selection

1. Token IDs

Start with “the cat sat”: three token IDs. Follow the last position, sat, while all three positions are processed.

Select any block to inspect it; scroll the diagram horizontally on small screens. Moving arrows show logical data flow, not measured timing. The same language-model head runs at every position. Generation reads only the last position, “sat”; training scores each supplied position against its own next-token target. Hand-set toy parameters; no weights change during this forward pass.

Chapter 7 / 12 · Assemble the Transformer

Normalize each token

Chapter scene 1 of 8 · Next step controls this detailed explanation, not the overview above

Our recurring sentence: the cat sat on the mat

Follow sat at position 2 · all numbers belong to the same toy block

sat before attention · incoming features
-0.113-0.2660.488-0.422
Row mean-0.078
subtract from each feature →
Population variance · ÷n = ÷40.119
divide by √(variance + 0.00001) →
Centered features
-0.035-0.1880.566-0.344
Normalized features · learned scale 1, offset 0
-0.101-0.5441.643-0.998

One mean and one standard deviation re-center and rescale this token’s vector as a whole. Other token positions do not enter this calculation. Per-feature adjustment comes afterward from learned γ and β; here every γ = 1 and β = 0.

Computed from unrounded values; the displayed numbers are rounded. Variance = Σ(xᵢ − mean)² ÷ 4, not ÷ 3. Small differences in hand calculations from rounded inputs are expected. Epsilon makes the normalized variance slightly less than 1.

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

Reconstruct a pre-normalized decoder block, including its two residual paths. Try aloud first, then write your explanation. Compare it with a worked explanation, not a keyword score.

No reference consulted yet.
Change the situation: If both learned sublayers return zero, should the block output zero or its input?

Its input: each residual path adds a zero update to the stream. Replacing addition with assignment breaks this identity path.

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