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 5: Order and context change a representation
How can the same word behave differently in different sentences?
After this chapter: Distinguish position information from context-dependent attention.
Consider the two occurrences of “the” in “the cat sat on the mat”. Their token IDs match, so their initial token embeddings match too. But they occupy different positions. We need a way to represent that difference.
Our teaching model looks up a position vector and adds it to the token vector, number by number. The result contains information about both which token this is and where it occurs. This model uses learned position vectors; that is not the only way to represent position.
Position is not the same as context. Compare “the cat” with “on cat”. In both examples, “cat” occupies the second position, so its initial token-plus-position vector is the same.
After processing the preceding words, the two representations of “cat” can differ. A representation influenced by the available text is called a contextual representation. In our causal model, a position can use itself and earlier positions, but not later ones.
The model map introduces the Transformer: the neural-network architecture that will mix information between positions and transform each position’s features. You do not need to understand every box yet. The next two chapters open those boxes.
Keep this idea
Token identity, position, and context are three different things.
Now explore the visual
First compare the same token at different positions. Then compare “cat” at the same position with different preceding words.
Use Next step below to move at your own pace. You can reopen this explanation from any scene in the chapter.
Next, attention will show us how information moves between positions.
Chapter 5 / 12 · Order and context change a representation
Represent position too
Chapter scene 1 of 3 · Next step controls this detailed explanation
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 position information from context-dependent attention. Try aloud first, then write your explanation. Compare it with a worked explanation, not a keyword score.
Change the situation: Can RoPE alone guarantee reliable answers at an arbitrarily long context?
No. A positional mechanism is not a guarantee of generalization, training coverage, or long-context retrieval quality.
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
- 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) ↗