Stanford Paper Maps the Circuit Behind In-Context Learning: Gated Key-Value Memory in Small Transformers
teortaxesTex · x · 2026-11-05
Researchers at Stanford (Andrew Gao and William Gao) causally reverse-engineered in-context learning in few-shot sentence classification on 3-4B-parameter transformers using activation patching.
Key findings:
- ICL is implemented as a gated key-value memory: label tokens encode identity in the residual stream, middle-layer heads write them as keys, and upper-layer Reader/Query/Copyer heads match the query's class and copy out the mapped label.
- An early-signal head gates this readout based on token repetition; without it, heads attend to the prompt's beginning instead. A separate head set suppresses the most recently seen label, removing recency bias.
- Ablations against random-head baselines show 60% of class flips pass through the readers, with a few amplified heads irreplaceable. A soft model with two identifiable constants fit on one prompt distribution predicts another; the computation is conserved across all three models.
- The circuit transfers to semantic concepts: the same reader reads words of the same semantic type.
Related event: Stanford Paper Dissects the Circuit Behind In-Context Learning(2 posts)→
More from Research
- Berkeley project uses pretrained base policy's support to guide exploration for fast online adaptation — abhishekunique7 · 2026-11-05
- Researchers explore deep Transformers as neural ODEs with spectral analysis via DMD — PTenigma · 2026-11-05
- Researchers Undo SFT Behavior by Subtracting Weight Updates from Final Checkpoints — burny_tech · 2026-11-05
- Agent benchmark scores hinge on container configs: 6-point swing from resource limits alone — krishnan · 2026-11-05
- USC-led $3.2M NIH project to analyze 94,000 brain scans across 8 mental illnesses — PTenigma · 2026-11-05
- USC's Zeta Law paper uses Riemann zeta function to predict when data is enough for discovery — PTenigma · 2026-11-05