揭示Transformer中归纳头如何通过平滑机制实现上下文估计
Induction Heads Interpolate N-Grams

- 归纳头通过重叠度加权整合完整与部分上下文匹配
- 在有限注意力尺度下实现类似Jelinek-Mercer的插值平滑
- 适合研究模型内学习机制与统计建模的读者
归纳头被认为是Transformer中上下文学习的注意力机制,但其具体实现的估计器尚不明确。我们研究了在order-k马尔可夫链上训练的Transformer,发现两种互补的平滑机制:首先,在有限注意力权重尺度下,该电路实现软上下文匹配估计器,根据上下文重叠程度指数加权聚合精确和部分匹配贡献,诱导出数据依赖的上下文阶数插值,类似于Jelinek-Mercer平滑;其次,序列起始符(BOS)引入加性伪计数,恢复类狄利克雷平滑。我们构建了一个解耦的Transformer,实现这两种机制,并验证训练后的Transformer能复现预测的注意力模式。在伪计数平滑最优或低阶上下文提供结构化证据的场景中,训练后的Transformer表现优于或媲美经典基于计数的基线。结果将归纳头的可解释性与经典统计平滑相连接,表明Transformer学习的是正则化的上下文估计,而非简单计数。
原文摘要 · Abstract (English)
Induction heads are attention circuits believed to underlie in-context learning in transformers, yet a precise characterization of the estimators they implement remains elusive. We study transformers trained on order-$k$ Markov chains and identify two complementary smoothing mechanisms. First, at finite attention-weight scale, the circuit implements a soft context-matching estimator: it aggregates contributions from exact and partial context matches, weighted exponentially by their overlap, and induces a data-dependent interpolation across context orders analogous to Jelinek-Mercer smoothing. Second, a beginning-of-sequence (BOS) token induces additive pseudo-counts, recovering Dirichlet-style smoothing. We construct a disentangled transformer implementing both mechanisms and show that trained transformers recover the predicted attention patterns. Across settings where pseudo-count smoothing is optimal or lower-order contexts provide structured evidence, trained transformers match or outperform classical count-based baselines. Our results bridge mechanistic interpretability of induction heads with classical statistical smoothing, revealing that transformers learn to regularize in-context estimation rather than simply count.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。