COMPLETE READING EDITION

Attention and Transformers,
One Token at a Time.

All six chapters, static lab comparisons and worked answers. This edition loads no JavaScript.

Glossary

Token state, X
A row of features supplied to this layer. In the lab these are invented constants.
Parameter versus activation
A parameter such as W is stored and ordinarily learned. An activation such as Q, K, V, A or O is computed for the current input. Sliders here directly intervene on activations.
Query / key width, dk
The shared number of coordinates used in a dot product. Values can have a different width dv.
Score and attention weight
A score is a compatibility scalar. Row-wise softmax converts allowed scores into mixing weights summing to one.
Causal mask
At query i, permit keys j ≤ i. Include the current input; exclude future input positions.
Attention output, O
A weighted sum of values per query. It is a state vector, not a vocabulary distribution.
Residual path
An additive route around a sublayer. In the illustrated original encoder block, addition precedes layer normalization.
Projection and head
A head uses its own learned Q/K/V projections. Multi-head outputs are concatenated and projected back to model width.
Notation convention
Rows are tokens; vectors multiply parameter matrices on the right. Mask and worked-example position labels start at 1. Sinusoidal position p may start at zero; source-code row indices are 0, 1, 2. All toy coordinates are dimensionless.

Sources

  1. Vaswani et al. — Attention Is All You Need

    Original architecture: §§3.1–3.5, equations (1) and (2), Figure 1; residual dropout in §5.4. 2017 paper, inspected arXiv v7.

  2. Jain & Wallace — Attention is not Explanation

    NAACL 2019. §4.2, pp. 3548–3550: attention interventions in the tested NLP models. This is evidence about those settings, not every Transformer.

  3. Wiegreffe & Pinter — Attention is not not Explanation

    EMNLP 2019. §§3.4–6, pp. 15–19: methodological critique, explanatory definitions, and task-dependent evidence.

  4. Xiong et al. — On Layer Normalization in the Transformer Architecture

    ICML 2020. Abstract identifies the Post-LN / Pre-LN placement distinction. No optimization-performance claim is made here.

  5. Ba, Kiros & Hinton — Layer Normalization

    §3, equation (3), and §5, equation (5): within-example feature statistics and learned gain and bias.