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

Positions and RoPE

Hard

Why does attention need positional information, and how does RoPE encode it?

Why this mattersRoPE encodes relative position by rotating query and key pairs, which interacts directly with long-context extension and latent KV compression (like DeepSeek MLA).

1 · Start with the intuition

Without positional information, self-attention treats a sequence as an unordered bag of tokens: permuting the input words simply permutes the output rows. Rotary Position Embedding (RoPE) encodes position directly into the geometry of attention: it groups each query and key vector into 2D coordinate pairs and rotates each pair by an angle proportional to the token’s position index. When you take the dot product between a query at position m and a key at position n, only the relative angle (n − m)ω survives.

2 · How the mechanism works

Mechanism step 1 of 3 · no question to answer

Pair head coordinates

Split the d-dimensional query and key vectors into d/2 two-dimensional pairs.

Next, we will look at: Rotate by token index. Move on when this operation makes sense.

Visualizing the behavior

One coordinate pair, rotated 30° per position

Derived
r = 1m=0m=1m=2m=3
Rotating by m·ω keeps the vector’s length (its content) and encodes position as an angle. Any two positions k apart differ by 30k°, so q·k depends only on the offset n − m, not on absolute position.

Tokens per full rotation, d = 128, base 10,000

Derived

wavelength 2π / ωᵢ with ωᵢ = 10000^(−2i/d)

pair i = 0
6.3
pair i = 16
63
pair i = 32
628
pair i = 48
6,283
pair i = 63
≈ 54,400
Fast pairs tell nearby positions apart; slow pairs change little over thousands of tokens. Log scale. Context-extension methods such as position interpolation and NTK/YaRN-style scaling work by adjusting these frequencies.