Transformer的条件无毛定理:语言模型如何遗忘其提示
研究论文 · 2026/10/20
本文研究自回归Transformer在生成t个token后对提示的保留程度。通过比较两个不同提示后接相同续写文本的隐藏状态距离,发现该距离近似按幂律t^{-α}衰减,其中α=1对应固定提示在均匀注意力中份额的收缩速率,α越小表示记忆越长。训练模型遗忘快(α≈0.55–0.7),未训练模型遗忘慢(α≈0.2–0.5)。作者证明该距离上界为O(P(log t)^{L-1}/t),其中P为提示长度,L为深度,适用于有限深度pre-LN softmax Transformer且注意力logits有界,并需满足pre-norm激活远离零的条件。机制是几何的:提示直接影响随上下文增长而稀释,续写token传递的接力只能增加对数因子。这被称为条件无毛定理:给定已生成文本,提示对下一token的影响随t增长而消失,因此提示的任何幸存属性(如语言)必须由文本本身携带。一个可精确求解的线性接力模型表明该上界不可改进,并重现了未训练网络中局部指数趋近1的现象。用logit偏置抵消稀释可在训练早期停止衰减并在后期逆转,说明稀释是所测遗忘的必要条件;未训练网络和可解模型表明它也是充分的。
该文为Transformer的提示遗忘现象提供了首个理论刻画,提出了条件无毛定理和幂律衰减上界,并揭示了稀释机制的必要性与充分性,对理解语言模型的上下文利用和记忆限制具有重要价值。
We ask how much an autoregressive transformer retains of its prompt after generating t tokens. Consider two different prompts followed by the same continuation text, so that any difference in their hidden states comes from the prompt alone, and we find that the distance between their hidden states decays approximately as a power law t^{-α}, where α=1 is the rate at which a fixed prompt's share of uniform attention shrinks and smaller values mean longer memory. Trained models forget fast (αapprox0.55--0.7), untrained ones slowly (αapprox0.2--0.5). We prove that this offset is Obig(P(log t)^{L-1}/tbig) for a prompt of length P and depth L. The bound holds for finite-depth pre-LN softmax transformers with bounded attention logits, under one additional condition: the pre-norm activations stay away from zero. The mechanism is geometric: the prompt's direct influence is diluted as the context grows, and relay --- continuation tokens passing on what earlier tokens read from the prompt --- can only add logarithmic factors. This is what we call the conditional no-hair theorem: given the text generated so far, the prompt's influence on the next token vanishes as t grows, so any property of the prompt that survives, such as its language, must be carried by the text itself. An exactly solvable linear relay model shows that the bound cannot be improved and reproduces the rise of the local exponent towards 1 seen in untrained networks. Cancelling the dilution with a logit bias stops the decay early in training and reverses it after, so dilution is necessary for the forgetting we measure; untrained networks and the solvable model show it is also sufficient.