Click a word, watch it interview the sentence
Each word below carries a hand-crafted query vector (what it needs) and a key vector (what it offers). Click any token: we compute its query · key dot product against every other token, softmax the scores, and draw the resulting attention weights as arcs and bars — live, no fakery. Adjectives hunt for nouns, the verb hunts for its participants, articles hunt for the thing they introduce.
Query/key vectors here are hand-set for clarity; real transformers learn them from data. The math — dot products, softmax — is the real thing.
The atom of attention — drag two arrows, read one number
Everything in attention reduces to Q·K: multiply matching dimensions, add them up. Geometrically that's alignment × size. Drag the white query and the two keys below. The dashed line shows each key's projection onto the query — that projection times the query's length is the dot product. The bars show which key wins after softmax.
Drag any arrowhead. Green and red are two competing keys; white is the query.
The sharpness knob — from mush to tunnel vision
Raw scores aren't weights yet — softmax turns them into a probability-like mix, and a single scale factor decides how peaky it is. The query here is "it" in “the cat saw the mouse in the kitchen and suddenly it pounced”; each candidate token carries a color as its value. The output swatch is the actual weighted blend of those values — what "it" becomes after attention. Slide the sharpness and watch both the weights and the blend change.
The famous "it" — one pronoun, two possible bosses
“The animal didn't cross the street because it was too ___.” Who is "it"? If the sentence ends in tired, "it" means the animal; if wide, it means the street. Here the final adjective reshapes the pronoun's query vector, and the attention weights — computed live from Q·K — flip accordingly. This is the exact example the original transformer paper used to show off.
Pick an ending above.
Death by dilution — drown the signal in a long sentence
Softmax has a quiet weakness: every extra token takes a bite of the probability mass, even if its score is small. The pronoun "she" below is trying to attend back to "the architect" — but a distracting "the lawyer" sits in the middle, and you control how many filler words pad the gap. Watch the architect's attention share, computed live, melt as the sentence grows.