Attention Visualiser: The Mask, the Scaling and the Softmax
A real causal mask and a real softmax over a score pattern you choose, on your own sentence, with the row entropy that says how many tokens each query is really attending to.
Rows are queries, columns are keys. Darker means more weight. Flat grey cells are masked: the query is not allowed to look there at all.
2^2.73 = 6.7 tokens' worth of attention. A row that spread itself evenly over all 11 visible tokens would score 3.32 bits; a row that picked exactly one would score 0.
- Tokens (T)
- 11
- Cells in the score matrix (T²)
- 121
- Cells removed by the causal mask
- 55
- Keys this query may attend to
- 10
- Logit range in this row (max − min)
- 2.000
- Largest weight in this row
- 45.1% on “was”
- Row sums to
- 1.000000
- Entropy
- 2.734 bits
- Effective tokens attended to (2^H)
- 6.65
What the picture is telling you
Attention is usually drawn as arrows between words, which hides the two properties that actually matter. The first is that every row is a probability distribution. It sums to one, so attention is always a competition — a token cannot attend more to one thing without attending less to something else. Drag the contrast down to zero and every row flattens to 1/T; there is no setting at which a head attends strongly to everything.
The second is the scaling factor, which looks like a footnote in the paper and is not. Turn the √d_head switch off and raise the head dimension to 512. Every row collapses onto its single best key and the entropy falls to zero. That is not a quirk of this page: it is what happens to a softmax when its inputs grow, and with a head dimension in the hundreds the unscaled dot products grow exactly that fast. A saturated softmax has near-zero gradients almost everywhere, which is another way of saying the model would stop learning. One division by a constant is what stands between the architecture and that.
What this page cannot show you is which pattern a real head has learned, because that takes a trained model and a forward pass, and there is neither here. It is worth knowing that published attention maps are also less interpretable than they look: a head that appears to track syntax on one sentence often does something else on the next, weights are not explanations of the output, and a large share of the mass in real models sits on the first token doing nothing in particular — the "attention sink" you can select above. Treat any attention picture, including this one, as a diagram of the mechanism rather than evidence about a model.