EPISODE COMPANION · VISUALIZATION

Transformer Feed-Forward Layers Are Key-Value Memories

Mor Geva, Roei Schuster, Jonathan Berant, Omer Levy · Dec 2020 · EMNLP 2021 · one 16-layer, 247M-parameter model on WikiText-103
arXiv 2012.14913 Interactive page

Where does "two-thirds" come from?

Attention: four d×d projections (Q, K, V, O) ≈ 4d². Feed-forward: d→4d→d ≈ 8d². Share = 8/12. Biases ignored.

FF(x) = f(x·Kᵀ)·V — step by step

Toy numbers, Illustrative (6 slots, 4 dims): not from the paper. Paper's f is ReLU; memory networks use softmax.Illustrative

Keys: how the 160 were examined

Reported design numbers. Bars are on a log-ish visual scale, not proportional.

Shallow vs semantic by layer

10 sampled keys per layer. Hover a column. Column colour shows the dominant type reported (shallow L1–9, semantic L10–16); individual cells are not reported. Schematic

Token-deletion test (no human labels)

Reported direction: deleting the last token hurts most in lower layers, shrinking in upper layers. Curve shape is Illustrative, no values reported here.Illustrative

Values: agreement with the next token

Value × output embedding → softmax → top token, compared with the token following the key's top trigger. Near zero for layers 1–10; max 3.5% in upper layers. Curve between those anchors is Illustrative.Illustrative curve

3.5% vs chance (log scale, reported)

Sparse but real

Composition: cells → layer → residual stream

Reported composition statistics

The evidence chain: what is shown vs missing

References