A model reading "the bank by the river" must decide which other words matter for each word. Attention is the mechanism that lets every token look at every other token and pull in the information it needs.
Starting with Q / K / V projections, Scaled dot-product, Softmax & temperature, Causal masking, Multi-head attention, KV cache, FlashAttention, GQA/MQA
In a picture
A tokenizer cuts text into sub-word pieces it knows.
Each piece becomes a number the model can work with.
Tokens decide cost, speed and what fits in the window.
Stage 1 of 3: Split
Open the full conceptMade for you now: slide lessons from basics to production, usually with code and a quiz.
Think of a library search. Each token writes a question (Query), every token also holds a label (Key) and a content (Value). A token compares its question against all labels, then reads a blend of contents, weighted by how well the labels matched.
So attention is a soft lookup: instead of fetching one best match, it returns a weighted average of all values.
In learning order. Start with the ones marked with a bar.
Three learned views of the same input let one token ask, advertise and carry information separately.
Why similarity is a dot product and why it is rescaled.
How scores become weights and how sharpness is controlled.
Stopping a token from seeing the future.
Several attentions in parallel, each free to specialise.
Reusing past keys and values so decoding is not recomputed.
Making attention fit in memory and serve more users.