arXiv:2605.10466cs.LG2026-05

注意力机制本质是统计读取,统一解释上下文学习与重复生成。

Self-Attention as a Covariance Readout: A Unified View of In-Context Learning and Repetition

论文配图:Self-Attention as a Covariance Readout: A Unified View of In-Context Learning and Repetition
图 1 · 摘自论文原文
  • 将注意力视为输入协方差的线性读出,揭示其内在统计机制。
  • 单层注意力可实现一次梯度下降,堆叠后可迭代优化参数。
  • 解释重复生成源于马尔可夫链吸引子,适合研究模型行为的学者。

大型语言模型表现出两种看似无关的现象:上下文学习(ICL)和重复生成。在这两种情况下,模型的行为如同已将上下文总结为总体统计量并舍弃了逐标记细节。我们探究这种‘总结与遗忘’是否可从注意力机制本身推导,并给出了肯定回答。在平稳、遍历且椭球分布的输入条件下,softmax注意力输出几乎必然收敛至 $Θ_VΣΘ_K^{ op}Θ_Q x_t$,其中 $Σ$ 为输入协方差;长上下文极限下,该过程等价于对输入二阶统计量的线性读出。由此产生两个结论:(i) 对于上下文线性回归,单一 softmax 头可实现一步群体梯度下降;通过残差连接堆叠多层,可迭代执行多次梯度下降步骤。(ii) 经过 $L$ 层 Transformer 传播后,终端隐藏状态以 $1/t$ 的参数速率收敛至仅依赖当前标记的确定性函数,使得自回归生成渐近退化为仅依赖前一状态的一阶马尔可夫链,其吸引轨道提供了重复与模式坍缩的结构性解释。因此,这两类现象皆为同一协方差读出原理的不同表现。

原文摘要 · Abstract (English)

Large language models (LLMs) exhibit two striking and ostensibly unrelated behaviours: in-context learning (ICL) and repetitive generation. In both, the model behaves as though it had summarised the context into a population-level statistic and discarded token-level detail. We ask whether this ``summarisation and forgetting'' can be derived from the attention mechanism itself, and answer in the affirmative. Under stationary, ergodic and elliptical inputs, the softmax attention output converges almost surely to $Θ_VΣΘ_K^{\top}Θ_Q x_t$, where $Σ$ is the input covariance; the long-context limit is therefore a linear readout of the input's second-order statistics. Two consequences follow. (i) For in-context linear regression, a single softmax head can implement one step of population gradient descent. Stacking such heads with residual connections iterates this update and implements multiple gradient descent steps. (ii) Propagated across an $L$-layer transformer, this readout drives the terminal hidden state at the parametric $1/t$ rate to a deterministic function of the current token alone, so that autoregressive generation collapses asymptotically to a first-order Markov chain whose attracting orbits furnish a structural account of repetition and mode collapse. The two phenomena thus emerge as facets of a single covariance-readout principle.

注意力机制上下文学习重复生成统计建模

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。