发现Transformer能动态选择因果结构,提升上下文推理能力
Selective Induction Heads: How Transformers Select Causal Structures In Context
- 用交错马尔可夫链设计动态因果结构,突破固定依赖限制
- 实验证明模型能正确识别滞后阶数并复制对应历史标记
- 适用于理解大模型上下文推理机制的研究者
Transformer在序列建模中表现出色,其成功关键在于归纳头(induction heads),即通过自注意力机制基于先前出现的词元进行复制。现有研究多基于马尔可夫链分析归纳头形成,揭示了模型如何在上下文中捕捉因果依赖与学习转移概率。然而,这些方法依赖固定的因果结构,难以反映自然语言中随上下文动态变化的复杂关系。为此,本文提出新框架:通过交错的、具有不同滞后阶数的马尔可夫链,在保持转移概率不变的前提下动态改变因果结构。该设定揭示了新型‘选择性归纳头’(Selective Induction Heads)的形成,使Transformer具备在上下文中选择正确因果结构的能力。我们实证表明,模型通过识别正确的滞后阶数并复制相应历史词元,实现下一词元预测。进一步构造了一个三层Transformer实现该机制,并提供理论分析证明该机制渐近收敛至最大似然解。研究成果深化了对Transformer如何选择因果结构的理解,为模型可解释性提供新视角。
原文摘要 · Abstract (English)
Transformers have exhibited exceptional capabilities in sequence modeling tasks, leveraging self-attention and in-context learning. Critical to this success are induction heads, attention circuits that enable copying tokens based on their previous occurrences. In this work, we introduce a novel framework that showcases transformers' ability to dynamically handle causal structures. Existing works rely on Markov Chains to study the formation of induction heads, revealing how transformers capture causal dependencies and learn transition probabilities in-context. However, they rely on a fixed causal structure that fails to capture the complexity of natural languages, where the relationship between tokens dynamically changes with context. To this end, our framework varies the causal structure through interleaved Markov chains with different lags while keeping the transition probabilities fixed. This setting unveils the formation of Selective Induction Heads, a new circuit that endows transformers with the ability to select the correct causal structure in-context. We empirically demonstrate that transformers learn this mechanism to predict the next token by identifying the correct lag and copying the corresponding token from the past. We provide a detailed construction of a 3-layer transformer to implement the selective induction head, and a theoretical analysis proving that this mechanism asymptotically converges to the maximum likelihood solution. Our findings advance the understanding of how transformers select causal structures, providing new insights into their functioning and interpretability.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。