两层变压器可精准模拟任意阶马尔可夫链的归纳头,揭示深度与上下文学习能力的关系。
What One Cannot, Two Can: Two-Layer Transformers Provably Represent Induction Heads on Any-Order Markov Chains
- 用双层单头变压器构建可表示任意阶条件k元语法的归纳机制
- 证明两层结构在任意阶马尔可夫源上均有效,而单层需指数规模
- 为浅层模型实现强上下文学习提供理论支持,适合关注模型机制的研究者
上下文学习(ICL)是变压器模型的核心能力,使其能通过输入上下文适应新任务。已有研究指出,ICL源于一种称为归纳头的特殊电路。由于归纳头等价于条件k-gram,近期工作将序列输入建模为马尔可夫过程,揭示了模型深度对ICL能力的根本影响:两层变压器可高效表示条件1-gram,而单层模型除非指数级庞大,否则无法完成该任务。然而,对于更高阶马尔可夫源,现有最优构造需至少三层(每层一个注意力头),因此存在疑问:两层单头变压器能否表示任意k阶马尔可夫过程?本文从理论上证明,仅需两层、每层一个注意力头的变压器即可表示任意条件k-gram。该结果给出了当前最紧致的变压器深度与马尔可夫阶数间关系刻画。基于此,我们进一步分析简化变体在一阶马尔可夫链上的学习动态,展示训练中有效上下文表示如何逐步形成。这些结果深化了对变压器型上下文学习的理解,表明即使浅层架构也能在结构化序列建模任务中表现出强大的上下文学习能力。
原文摘要 · Abstract (English)
In-context learning (ICL) is a hallmark capability of transformers, through which trained models learn to adapt to new tasks by leveraging information from the input context. Prior work has shown that ICL emerges in transformers due to the presence of special circuits called induction heads. Given the equivalence between induction heads and conditional k-grams, a recent line of work modeling sequential inputs as Markov processes has revealed the fundamental impact of model depth on its ICL capabilities: while a two-layer transformer can efficiently represent a conditional 1-gram model, its single-layer counterpart cannot solve the task unless it is exponentially large. However, for higher order Markov sources, the best known constructions require at least three layers (each with a single attention head) - leaving open the question: can a two-layer single-head transformer represent any kth-order Markov process? In this paper, we precisely address this and theoretically show that a two-layer transformer with one head per layer can indeed represent any conditional k-gram. Thus, our result provides the tightest known characterization of the interplay between transformer depth and Markov order for ICL. Building on this, we further analyze the learning dynamics of our two-layer construction, focusing on a simplified variant for first-order Markov chains, illustrating how effective in-context representations emerge during training. Together, these results deepen our current understanding of transformer-based ICL and illustrate how even shallow architectures can surprisingly exhibit strong ICL capabilities on structured sequence modeling tasks.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。