arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2510.27015cs.LGstat.ML
收藏

Transformer长度泛化的定量界限

Quantitative Bounds for Length Generalization in Transformers

NEC Labs America(NEC美国实验室);Princeton University(普林斯顿大学);UC Berkeley(加州大学伯克利分校)

Zachary Izzo, Eshaan Nichani, Jason D. Lee

AI总结:

首次为Transformer的长度泛化提供了训练长度的定量界限,证明在多种设置下,当模型在长序列上的内部行为可被短序列行为模拟时即可实现泛化,并经实验验证。

摘要:

我们研究Transformer中的长度泛化(LG)问题:即在较短序列上训练的模型,在评估更长且未见过的输入时保持性能的能力。Huang等人(2025)的先前工作确立了Transformer一旦训练序列长度超过某个有限阈值即可实现长度泛化,但该阈值需要多大仍是一个未解问题。在本研究中,我们首次为发生长度泛化所需的训练长度提供了定量界限。受先前实证和理论工作的启发,我们在几种不同问题设置下分析LG:输入分布上的$\ell_\infty$误差控制与平均误差控制、Transformer中的无限精度softmax注意力与有限精度注意力(简化为argmax),以及单层与双层Transformer。在所有场景中,我们证明当Transformer在更长序列上的内部行为能被其在训练中见过的较短序列上的行为“模拟”时,LG就会发生。我们的界限为Transformer泛化所需的训练数据长度提供了定性估计,并通过实验验证了这些见解。这些结果深化了我们对Transformer外推机制的理论理解,并形式化了在更复杂任务上泛化需要更丰富训练数据的直觉。

英文摘要:

We study the problem of length generalization (LG) in transformers: the ability of a model trained on shorter sequences to maintain performance when evaluated on much longer, previously unseen inputs. Prior work by Huang et al. (2025) established that transformers eventually achieve length generalization once the training sequence length exceeds some finite threshold, but left open the question of how large it must be. In this work, we provide the first quantitative bounds on the required training length for length generalization to occur. Motivated by previous empirical and theoretical work, we analyze LG in several distinct problem settings: $\ell_\infty$ error control vs. average error control over an input distribution, infinite-precision softmax attention vs. finite-precision attention (which reduces to an argmax) in the transformer, and one- vs. two-layer transformers. In all scenarios, we prove that LG occurs when the internal behavior of the transformer on longer sequences can be "simulated" by its behavior on shorter sequences seen during training. Our bounds give qualitative estimates for the length of training data required for a transformer to generalize, and we verify these insights empirically. These results sharpen our theoretical understanding of the mechanisms underlying extrapolation in transformers, and formalize the intuition that richer training data is required for generalization on more complex tasks.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑