Lab · c21.s03.L1

Attention heatmap

Attention gives each word one unit to divide across the sentence, and a row shows where that word spends it.

Question: How does a model choose which words matter?

Attention heatmapA seven-by-seven grid of attention weights for the sentence The cat sat because it was tired. Rows are the word doing the looking, columns the word being looked at: a darker cell holds a larger share, every cell prints its share, and every row splits one unit. The chosen row is outlined, its hottest column is boxed, and a bar chart repeats that row. The sharpness control moves the row from almost even to nearly one-hot.Attention heatmapHow does a model choose which words matter?rows: the word looking · columns: the word looked atthe chosen row, as barsdarker cell = larger sharedashed cell = below an even shareThecatsatbecauseitwastiredThecatsatbecauseitwastiredThecatsatbecauseitwastireddashed line: even share 0.143The cat sat because it was tired0.1480.2250.1400.1030.1570.1170.1100.0980.1500.2280.0820.1590.1330.1500.1130.2460.1520.0740.1610.1200.1350.0860.1030.0720.1390.2680.1560.1760.1010.3160.1450.0660.1360.1070.1280.0890.1280.1200.0950.1620.1440.2620.0920.1320.1040.0820.2710.1780.140it at sharpness 0.60: hot cell cat 0.316, cold cell because 0.066.Every row spends the same unit of attention; an even split would give each of the seven words 0.143.
Synthetic Synthetic: the seven relevance scores behind this heatmap are set by hand, not learned from data, and the sharpness knob is an illustration, not a parameter of a trained model. The weights are computed exactly from those scores by data/scripts/c21.s03.L1.py. The rule they follow is the textbook one: attention weights are positive and sum to one in every row [S:74:224-225].
Lab controls
it

Arrow keys move one word; Home selects the first word, End the last. Enter or Space opens the list.

0.60

Arrow keys step 0.10 from 0.30 to 3.00; Home selects 0.30, End 3.00. Enter or Space opens the list.

Frame 1 of 1: it · sharpness 0.60At the default setting the row is already lopsided. The row for it divides one unit of attention over all seven words at sharpness 0.60. The hot cell is cat at 0.316; the cold cell is because at 0.066. An even split would give every word 0.143.

it · sharpness 0.60. At the default setting the row is already lopsided. The row for it divides one unit of attention over all seven words at sharpness 0.60. The hot cell is cat at 0.316; the cold cell is because at 0.066. An even split would give every word 0.143.

Keyboard: Space plays or pauses, Left and Right step, Home goes to the first frame, End goes to the last frame.

Text description of this lab

A seven-by-seven grid of attention weights for the sentence The cat sat because it was tired. Rows are the word doing the looking, columns the word being looked at: a darker cell holds a larger share, every cell prints its share, and every row splits one unit. The chosen row is outlined, its hottest column is boxed, and a bar chart repeats that row. The sharpness control moves the row from almost even to nearly one-hot.

Return to the section that hosts this lab

Caption status: synthetic. Every lab declares one of published, re-simulated, schematic, synthetic or interpolated.