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

Positional encoding

Easy

Self-attention ignores word order. How did the original Transformer tell the model where each token sits?

1 · Start with the intuition

Attention builds each output from weighted sums over the other tokens, and nothing in that calculation depends on where a token sits. Shuffle the input and the outputs shuffle in the same way, so “dog bites man” and “man bites dog” would look like the same collection of words. The original fix is simple: before the first layer, add a position vector to each token embedding. The paper builds those vectors from sine and cosine waves of many different wavelengths, so every position gets its own pattern of values.

2 · How the mechanism works

Mechanism step 1 of 3 · no question to answer

Build one vector per position

For each position, fill a vector of width d_model with sines in the even slots and cosines in the odd slots, using slower waves for later slots.

Next, we will look at: Add it to the embedding. Move on when this operation makes sense.

Visualizing the behavior

Position is added to the embedding before the first layer

Token embeddingwhat the token isPosition vectorwhere it sits+Input to layer 1same widthLayer stackencoder or decoder
The two vectors have the same width and are added number by number. Nothing is appended, so the vector entering layer 1 is still d_model wide.

Sinusoidal position vectors for d_model = 4

Derived
Sinusoidal position vectors for d_model = 4
position ↓ · slot →sin, fastcos, fastsin, slowcos, slow
pos 00.001.000.001.00
pos 10.840.540.011.00
pos 20.91-0.420.021.00
pos 30.14-0.990.031.00
The fast pair uses angle pos and the slow pair uses angle pos / 100, both in radians. The fast pair changes sharply from one position to the next, while the slow pair barely moves, so it only separates positions that are far apart. Shading shows the size of each number, ignoring its sign.