Cognitive Psychology
The word "attention" appears in two literatures that have almost nothing in common. In one it names a set of experimental findings about selection, capacity and awareness. In the other it names an arithmetic operation: a normalised similarity between one position in a sequence and every other position. This page has you do both, on the same sentence, so the difference is something you have produced rather than been told.
The numbers here are chosen by hand to be legible — no model was run, and nothing was learned
By the end you should be able to say precisely what a transformer attention weight is, and why a weight map is not an explanation of a model's output.
About 15 minutes. Nothing is timed. Nothing you do here is saved or sent anywhere.
A weight is a number, not a noticing. Throughout this page, the computational side is described in arithmetic terms only. A high weight on a position does not mean the system "focused on" or "cared about" or "was drawn to" that word. It means a dot product came out large and the softmax normalised it upwards. The habit of saying otherwise is the single commonest error in writing about these models, and it is easier to avoid here than anywhere else because you can see the arithmetic.
Nothing on the machine side is aware of anything. There is no experience, no report, no effort and no cost of the kind the human literature measures. The absence is the finding.
You are about to do two quite different things with the same sentence. Before you do either, commit to a view about what the relationship between them will turn out to be.
Two sentences. They differ in their last three words and in nothing else. Read each one and say what "it" refers to. There is no time limit, and no trick beyond the one you can see.
The same sentence, cut into ten tokens. Each token has a vector of three numbers attached to it — arbitrary numbers, written by hand for this page. Pick a position to compute from, pick a head, and the arithmetic below runs in front of you.
Every number on this page was chosen by the author to make the pattern legible. Nothing was learned, no model was run, and the apparent meaningfulness of what you are about to see is manufactured. That is itself one of the points.
The computation
| Position | Token | Key vector | Score | Weight |
|---|
Eight statements. For each, decide whether it describes the human experimental literature on attention, the transformer operation you have just run, both, or neither. Two of them are true of both, and two are true of neither — those four are the ones worth arguing about.
A transformer attention weight is a softmax over query–key similarities: a set of positive numbers summing to one, deciding how much each position contributes to the next representation. It rhymes with selective attention in that both allocate limited influence, and diverges in almost every other way — there is no capacity limit, no serial bottleneck, no cost of switching, and nothing it feels like. The shared word is a useful metaphor and a poor argument.