Jacky LightBlock Island
AI Notes

What does one row of attention tell us?

Pick a position in a sentence and see how it draws information from earlier tokens.

Take “I like black coffee” as four illustrative tokens. At “coffee,” the model needs a way to mix information from positions in its context. Self-attention constructs a query, a key, and a value for each position.

Follow one query

The query is compared with the keys at visible positions. Scaling the scores and applying softmax gives a row of weights that add up to one. Suppose the row is [0.08, 0.14, 0.55, 0.23]. The value vector at “black” then gets a coefficient of 0.55.

Multiply each value vector by its coefficient and add the results. That sum is the representation this head gathers at the current position. The weights here were chosen for illustration. A single row describes one head at one step and cannot, by itself, explain a model’s final answer.

The blank triangle

A causal mask lets each position look at itself and earlier positions. At “I,” the next three positions are hidden. At “coffee,” all four are visible. Stack those rows and the triangular pattern appears. Vaswani et al., Attention Is All You Need