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 07 of 62 · Inside the Transformer block

Multi-head attention

Medium

Why run several attention heads side by side instead of one, and what does it cost?

1 · Start with the intuition

One attention head gives each token a single set of weights over the other tokens, so it produces one weighted average. A token often needs more than one relationship at once: in “The animal didn’t cross the street because it was too tired”, the word “it” benefits from both “animal” and “tired”. Multi-head attention runs several smaller attention calculations in parallel. Each head has its own query, key, and value projections, so each can score the sequence differently. Their outputs are placed side by side and passed through one more learned projection to return to the model width.

2 · How the mechanism works

Mechanism step 1 of 4 · no question to answer

Project per head

Each head projects the input into its own smaller query, key, and value vectors of width d_model / h.

Next, we will look at: Attend per head. Move on when this operation makes sense.

Visualizing the behavior

Eight narrow heads in parallel, then one projection (base model)

Derived
X512 wideHead 1Q, K, V · 64 wideHead 2Q, K, V · 64 wideHeads 3 to 8same shapeConcatenate8 × 64 = 512W_OZ512 wide
Every head receives the same input and applies its own query, key, and value projections, so each can produce a different attention pattern. The eight 64-wide results are placed side by side and mixed by W_O, so the output has the same width as the input.