Attention
You will learn
How attention scores every query against every key, what a softmax over each row gives, and what the causal mask removes.
Attention lets each position decide which other positions to read. Every query is scored against every key, q . k / sqrt(d), and a softmax turns each row of scores into weights that sum to 1; the output is the values averaged by those weights. Two heads do it on the two halves of the vector. With a causal mask a position cannot read the future: in head 0, position 0 reads only itself, position 1 splits 0.452 and 0.548, and position 2 spreads 0.230, 0.321 and 0.449. Without the mask every row spreads over all three keys, from 0.21 to 0.47. The spec attention_mechanism.t27 computes every weight on its own fixture.