Back to Discover
Curiosity

What Is Attention Actually Comparing?

Attention compares a query vector to a bank of key vectors via a dot product, and the resulting scores weight how much of each value vector is read — a similarity operation over learned representations, not over surface words.

Before you enter

A complete interactive classroom, not just a preview.

Start when you are ready to enter this Stage's 8 scenes and explore, respond, and learn as you go.

8
Scenes
16 min
Estimated
Content language: en-US
Start this Stage
Sign-in may be required to play
What happens inside
  1. 01The Hidden Comparisonslide
    Question

    Open with the mechanical feeling of attention: a token is read, and the model's 'focus' shifts. Pose the driving question visually with two arrows pointing at each other — what is on each side of the comparison?

    • Attention is often described as 'looking back' at previous words
    • But the actual operation is more specific than that
    • Driving question: what two things are being compared when a head scores a match?
  2. 02Your First Guessquiz
    Prediction

    A single forced-choice question: when the model attends from the word 'sat' in 'The cat sat on the', what is it actually comparing? Commit to an intuition before the mechanism is shown.

    • Choose the most concrete comparison you think is happening
    • No penalty for being wrong — the point is to surface the assumption
  3. 03Watch the Three Vectors Forminteractive
    Evidence

    A small, focused simulator: pick a token, and watch three vectors light up — the query (blue), one key from the bank (orange), and the value (green). The learner can swap keys and see the dot-product score change in real time.

    • Every token produces three vectors: Q, K, and V
    • The query is the seeker; the key is the address; the value is what gets returned
    • Only the query is compared — against keys, not against words
  4. 04The Dot Product Heatmapslide
    Evidence

    Show a real-looking attention matrix as a heatmap: rows are queries, columns are keys. Highlight the row for 'sat' and let the brightest cell point to 'cat' — surprising, because 'cat' is a noun, not a verb. The evidence is that the match is not syntactic.

    • Rows are queries, columns are keys, cells are dot products
    • Bright cells reveal where the model 'attends'
    • The match can be semantic, positional, or syntactic — not always what grammar would predict
  5. 05Why Vectors, Not Wordsslide
    Explanation

    Step through the pipeline: token → embedding → linear projection into Q, K, V. The comparison happens in the projected space, not on the string. Show that two very different words can have nearby vectors, and two identical words can have different vectors in different positions.

    • Tokens are mapped into a high-dimensional space by learned matrices
    • Q and K live in that space; similarity is geometric, not lexical
    • Same word, different position → different Q, different K, different score
  6. 06Test It on a New Sentenceinteractive
    Transfer

    A manipulable scene: the learner can change the sentence and watch the attention row for the new verb shift. Predict where the brightest cell will land, then verify. The principle should hold across a new example.

    • Apply the same Q-vs-K comparison to a fresh sentence
    • Predict first, then observe
    • The attention pattern is not about matching words — it is about matching learned vectors
  7. 07What Attention Is Not Doingslide
    Boundary

    A short, sharp boundary scene: attention does not compare words to words, does not store facts, does not 'understand' meaning. It is a differentiable, learned similarity lookup — and saying so precisely prevents overclaiming.

    • Attention is a soft key-value retrieval, not a database
    • Heads do not 'know' facts; they pattern-match in projection space
    • The comparison is purely geometric: how aligned two vectors are
  8. 08The Comparison, Restatedslide
    Resolution

    Resolve the driving question directly: attention compares a query vector to a bank of key vectors via dot product; the scores softmax into weights; the weights mix the value vectors. Close by naming the original intuition that was wrong.

    • Compared: Q vs K (both are learned projections)
    • Produced: a scalar similarity score per key
    • Used: to weight the values that are summed into the output
    • The first guess — comparing words to words — was the layer of illusion
Discussion

Discussion threads for a Stage aren't available yet.

Where this leads
Explore more

More in Technology & Computing

See all