A Circuit for In-Context Learning
- 原文链接: https://arxiv.org/abs/2611.05344
- PDF: https://arxiv.org/pdf/2611.05344
- 作者: Andrew Gao, William Gao
- 日期: 2026-11-03
- 更新: 2026-11-03
- 分类: models
- 来源类型: paper
- 标签: interpretability, in-context-learning, circuits, transformers
- 质量评分: 4/5
- 抓取时间: 2026-11-05T00:01:20Z
中文导读
arXiv 2611.05344(11-03,cs.CL/cs.LG)在三个 3–4B 参数 transformer 上给出 few-shot 句子分类(任意标签)的完整 ICL 电路组合:模型在标签 token 位置实现键值记忆——标签身份编码在残差流里,中层注意力头把前一条演示的类别作为键写入;查询时据此检索并输出标签。此前工作只找到候选部件而未给出组装方式,该文补全了单次前向传播内完成映射构建的机制链条,代码与交互式演示已开源。
为什么值得关注
ICL 机制拼图补全:标签位键值记忆 + 中层注意力头写入演示类别,任意标签 few-shot 分类首次有完整电路组合
in-context learning 常被称作不做梯度更新的学习,这篇给出单次前向内映射如何被构建的电路级证据,可检验、可复现。
关键信息
- 原文链接: https://arxiv.org/abs/2611.05344
- arXiv 2026-11-03 | cs.CL, cs.LG
- PDF: https://arxiv.org/pdf/2611.05344
- 作者: Andrew Gao, William Gao
English Abstract
In-context learning (ICL) lets a pretrained language model perform a task specified by demonstrations in its prompt, with no parameter updates. With arbitrary labels the model must acquire a mapping it cannot have memorized, so the learning happens within a single forward pass. Prior work found candidate parts but not how they compose. We give the composition for few-shot sentence classification with arbitrary labels in three 3-4B-parameter transformers. The model implements a key-value memory over label-token positions: each label token's residual stream encodes the label's identity, and middle-layer attention heads write into it the class of the preceding demonstration as its key. At the query, upper-layer heads match the query's class against the stored keys and copy out the matching labels. An early-layer signal encoding whether any label has repeated gates this readout; in its absence the readers attend to the start of the prompt and no label is favored. A separate set of heads suppresses the most recently seen label. Each step is established causally by activation patching, head ablations against random-head baselines, and steering with the model's own signals. A softmax model of the readout with two constants per head, fit on one prompt distribution, predicts another. The computation is conserved across the three models, the named heads alone reproduce the behaviour, and a transformer trained from scratch grows the same parts. The circuit transfers to semantic concepts and to labels with meaning, and the same parts, with a causal gate, appear from 0.6B to 8B in one family and survive instruction tuning. ICL in this setting is a gated associative lookup built from a few identifiable component types, traced causally from demonstrations to prediction.
English Summary
A Circuit for In-Context Learning (arXiv 2611.05344, Nov 3, cs.CL/cs.LG; Andrew Gao and William Gao) gives the full circuit composition for few-shot sentence classification with arbitrary labels in three 3-4B-parameter transformers. The model implements a key-value memory over label-token positions: each label token's residual stream encodes the label's identity, and middle-layer attention heads write into it the class of the preceding demonstration as its key. Prior work found candidate parts but not how they compose; this paper supplies the composition, showing learning happens within a single forward pass. 38 pages, code and interactive walkthrough released.
Obsidian Notes
- 内容由
opencli arxiv paper拉取的 arXiv 元数据与摘要生成;中文导读与价值判断锚定在摘要、作者、日期与分类信息上,未补充摘要之外的事实。