← All entries
Paper2026#1512

A Circuit for In-Context Learning

Summary

A complete, causally traced circuit for in-context learning in its cleanest setting: few-shot sentence classification with ARBITRARY labels, where the label mapping cannot have been memorized, so the learning must happen inside a single forward pass. Studied in three 3-4B-parameter transformers. The composition: the model builds a key-value memory over the label-token positions. Each label token's residual stream encodes the label's identity (the value), and middle-layer attention heads write into that position the class of the preceding demonstration (the key) - induction-head-style binding, but storing class rather than token identity. At the query, upper-layer reader heads match the query's class representation against the stored keys and copy out the label attached to the matching key. Two control components complete the circuit: an early-layer signal encoding whether any label has REPEATED anywhere in the prompt gates the readout - without it, the reader heads attend to the start of the prompt and no label is favored, so the lookup only fires once the prompt actually contains a repeated-label structure to look up - and a separate set of heads suppresses the most recently seen label, countering a pure recency/copy bias. Every step is established causally, not correlationally: activation patching, head ablations benchmarked against random-head baselines, and steering with the model's own signals; and a softmax model of the readout with just two fitted constants per head, fit on one prompt distribution, predicts behavior on a different distribution. Generality claims: the computation is conserved across all three models; the named heads alone reproduce the behavior; a transformer trained from scratch grows the same parts (the circuit is an attractor of training, not an artifact of one checkpoint); it transfers from arbitrary labels to semantic concepts and labels with meaning; and within one model family the same parts with the causal gate appear from 0.6B to 8B parameters and survive instruction tuning. Caveats: abstract-level evidence; the setting is few-shot classification - the most lookup-like form of ICL - and says nothing directly about many-shot, regression-style, or open-ended generative ICL; the three main models are not named in the abstract. Catalog placement: the mechanism counterpart to ID 1765 (LIDAS), which argued grown/looped models share a context-over-weights inductive bias rooted in induction heads - this paper shows what a mature version of that bias looks like as an explicit circuit: bind demonstrations into a key-value store in the residual stream, gate the lookup on prompt structure, and read by class match. The gating signal is also the architecturally interesting part: the model checks a global prompt property (has any label repeated?) before trusting its own associative memory.

Venue
arXiv preprint
Source
arxiv
Access
free
Language
en
Added
Nov 4, 2026
Verified
Nov 4, 2026

Research notes

  • arXiv 2611.05344 (cs.CL/cs.LG), submitted 3 Nov 2026, CC BY 4.0 (license icon on the arXiv page). Shared 2026-11-04 via a bare t.co link resolving to the paper's arXivBangers page ('Certified Banger', editorial score 88/100). Abstract-level research; no code link on the arXiv page at catalog time. The author pair (Andrew Gao, William Gao) shares its names with the Gao & Gao of ID 1797 (Fair Cast).

Similar entries