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.
- Distinguish a Transformer from attention alone.
- Trace tokens, states, block operations, and logits.
- Derive attention and detect future-token leakage.
- Separate training updates from inference.
- Compare model changes by benefit, cost, and evidence.
Viewing a chapter is not proof of understanding. Teach-backs use self-review; code checks validate small examples, not overall mastery.
Read chapter 12: See the complete system
How do training and generation relate?
After this chapter: Explain the complete model and identify which design changes affect compute, cache, or weights.
Return to our opening text: “the cat …”. We can now explain what happens inside the model rather than treating it as a mysterious box.
Text becomes tokens. Token IDs select embedding rows. Position information is added. Transformer operations mix available context and transform each position’s representation. The output layer produces vocabulary scores, and softmax turns them into probabilities.
This forward computation appears in both training and generation. The difference is what we do with its results.
During training, we compare probabilities with observed targets, calculate a loss, compute gradients, and update parameters. The scheduler supplies the learning rate for those updates. New examples can then be processed using the changed parameters.
During generation, we select a token, append it to the input, and repeat with the longer prefix. We do not need a loss target, a backward pass, or an optimizer update. The parameters stay fixed while the available text and activations change.
You do not need to remember every formula to understand this overall map. Start with the distinction between stored parameters and calculated activations, and between training and generation. Use the glossary to revisit any operation whose purpose is still unclear. Reading a chapter is a starting point, not a verdict on your understanding.
Keep this idea
Training changes parameters. Generation grows the text.
Now explore the visual
Trace the shared forward path first. Then follow the different endings: target and parameter update for training; token selection and a longer prefix for generation.
Use Next step below to move at your own pace. You can reopen this explanation from any scene in the chapter.
Return to any chapter freely. When you can trace one token through the full computation, continue to guided model design: explain how GPT-2, DeepSeek-V3, and Kimi K2 change the same underlying components, then defend the benefits and costs.
Chapter 12 / 12 · See the complete system
Training changes stored parameters
Chapter scene 1 of 4 · Next step controls this detailed explanation
Training
Next batch runs with the updated parameters.
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
Explain the complete model and identify which design changes affect compute, cache, or weights. Try aloud first, then write your explanation. Compare it with a worked explanation, not a keyword score.
Change the situation: A colleague says “fewer active parameters means the weights fit on one small GPU.” What additional information do you need?
Total stored weights, precision, distribution/offload strategy, KV cache, activations, and runtime overhead. Active parameters concern per-token computation, not the complete memory footprint.
Draft and self-review saved in this browser, not to your account. Do not enter confidential information on a shared device.
Now explain why real models differ
Keep the same Transformer skeleton. Compare what GPT-2, Llama 2 70B, DeepSeek-V3, and the original Kimi K2 change, what each change buys, and what it costs.
Continue to guided model designShow 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
- Word2Vec: skip-gram predicts context words from a center word ↗
- Attention Is All You Need: scaled dot products, heads, masking ↗
- GPT-2 report: pre-normalization and final normalization ↗
- GPT-2 reference operations: learned positions, GELU, pre-LN ↗
- PyTorch: LayerNorm, population variance and per-feature affine parameters ↗
- Adam: gradient statistics, bias correction and learning-rate multiplier ↗
- PyTorch: backpropagation and automatic differentiation ↗
- PyTorch: AdamW and decoupled weight decay ↗
- PyTorch: cosine decay (warmup is supplied separately here) ↗