Foundations — Long-context architectures
This page assumes nothing. Before we can talk about "why is bad" or "what a hidden state is", we must first agree on what every letter, arrow, and picture means. We build the vocabulary in the order the parent note needs it.
1. A sequence, and what means
Everything starts with a sequence — an ordered list of pieces of text.
Picture a row of numbered boxes. Box 1 holds the first token, box 2 the second, and so on up to box . That row is the sequence.

Why does the topic obsess over ? Because every cost we will meet — memory, compute, speed — is measured as a function of . When the parent says "contexts beyond ~8k tokens", it means . "100k+ token contexts" means . The whole chapter is the fight to keep costs small as grows large.
2. Turning a token into numbers: the embedding vector
A computer cannot multiply the word "cat". It works with numbers, so each token is turned into a list of numbers called a vector.
Picture an arrow floating in space. In everyday life space has 3 directions; here it has directions. Two tokens with similar meanings point in similar directions.
Why does the topic need this? Because "how related are two tokens?" becomes a geometry question: are their arrows pointing the same way? That question is answered by the next tool.
3. The dot product: measuring "how aligned"

Why this tool and not another? We want one number that says "how much does token care about token ?" The dot product is the cheapest, most natural "alignment score" between two arrows — multiply matching entries, add them up. That is exactly the raw material attention is built from. (You will also see it written ; the little means "written as a row so the multiplication lines up" — same number.)
4. Q, K, V: three roles for the same tokens
Attention gives each token three different vectors, playing three different roles.
Picture a library. Your query is the question in your head. Each book has a spine label — its key. You compare your question against every spine (dot products), and the books you pick hand you their contents — their value.
Why three roles? Because "what I want", "what I advertise", and "what I deliver" are genuinely different things, and letting the model learn them separately is what makes attention expressive.
5. Softmax: turning scores into a weighted average
Dot products give raw scores that can be any size. To combine values we need weights that are positive and add up to 1 — a recipe for a weighted average.

Why the exponential and not just "divide by the sum"? Plain division breaks with negative scores (you could get negative or undefined weights). The exponential is always positive and grows fast, so the highest-scoring key dominates gently — a soft version of "pick the maximum", which is why it is called soft-max.
Now the full attention formula the parent opens with reads in plain words: "Score every query against every key (), shrink the scores so they don't explode (divide by ), turn scores into a weighted average (softmax), then use those weights to blend the values ()." The is just a scaling constant ( = key dimension) that keeps the numbers in a sane range.
6. Where comes from: Big-O and the cost picture
The heart of the whole chapter is one picture: the attention grid.

Every query (a row) must dot-product with every key (a column). That fills an -by- grid of scores — comparisons. At that is (ten billion) comparisons per layer. This single grid is the enemy. Every architecture in the parent note — sparse patterns, linear attention, state-space models, memory banks — is a different way to avoid filling the whole grid. See Computational Complexity for the general language of these growth rates.
7. Two escape hatches you'll meet
Two more ideas make the "escape from " possible. You don't need to master them yet — just recognise the words.
Two more names appear as destinations of these tricks: Retrieval-Augmented Generation (fetch relevant chunks instead of reading all of them) and the Information Bottleneck (the theory of what a fixed-size summary is forced to throw away). We only flag them here.
How the foundations feed the topic
Read it top to bottom: sequences become vectors, vectors get compared by dot products, dot products become Q-K-V attention, softmax blends the values, that fills an grid whose cost explodes as — and that explosion is the problem long-context architectures exist to solve, using extra tools like the hidden state and the feature map .