揭示大模型注意力在长序列下的收敛速度,解释为何超长文本性能会下降。
Token Sample Complexity of Attention
- 提出'令牌采样复杂度'概念,量化注意力随序列长度的收敛速率。
- 发现注意力输出的统计矩收敛速度为1/n^β(β<0.5),支持范围越大越慢。
- 实验验证理论预测,长文本下准确率下降与收敛变慢一致,适合研究模型极限。
随着大语言模型上下文窗口不断扩展,理解注意力在极端序列长度下的行为至关重要。本文引入‘令牌采样复杂度’:关注在n个令牌上计算的注意力收敛到无限令牌极限的速度。我们从两个层面估计有限n的收敛界:注意力图的逐点均匀收敛,以及变换后令牌分布各阶矩的收敛。对于紧支撑(更一般地亚高斯)分布,第一结果表明注意力图在半径R的球上以速率C(R)/√n均匀收敛,其中C(R)随R指数增长;当R较大时该估计失去实际意义。第二结果通过分析变换后分布的矩,建立收敛速率C'(R)/n^β(β<1/2),其中C'(R)关于分布支撑大小多项式依赖。指数β由注意力几何和令牌分布谱特性决定。此外,在注意力参数趋于无穷、softmax趋近hardmax的场景中,我们建立了对数级收敛速率。合成与真实数据的实验支持预测,并显示预期的缓慢收敛反映在下游准确率下降上。
原文摘要 · Abstract (English)
As context windows in large language models continue to expand, it is essential to characterize how attention behaves at extreme sequence lengths. We introduce token sample complexity: the rate at which attention computed on $n$ tokens converges to its infinite-token limit. We estimate finite-$n$ convergence bounds at two levels: pointwise uniform convergence of the attention map, and convergence of moments for the transformed token distribution. For compactly supported (and more generally sub-Gaussian) distributions, our first result shows that the attention map converges uniformly on a ball of radius $R$ at rate $C(R)/\sqrt{n}$, where $C(R)$ grows exponentially with $R$. For large $R$, this estimate loses practical value, and our second result addresses this issue by establishing convergence rates for the moments of the transformed distribution (the token output of the attention layer). In this case, the rate is $C'(R)/n^β$ with $β<\tfrac{1}{2}$, and $C'(R)$ depends polynomially on the size of the support of the distribution. The exponent $β$ depends on the attention geometry and the spectral properties of the token distribution. We also examine the regime in which the attention parameter tends to infinity and the softmax approaches a hardmax, and in this setting, we establish a logarithmic rate of convergence. Experiments on synthetic and real data support our predictions and show that the predicted slowdown is reflected in downstream accuracy.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。