arXiv:2510.27015cs.LGstat.ML2025-10被引 7

首次给出Transformer长度泛化所需训练长度的定量边界。

Quantitative Bounds for Length Generalization in Transformers

  • 通过模拟短序列行为推导长序列性能,建立理论边界。
  • 发现模型需在足够长序列上训练才能实现泛化,且精度影响关键。
  • 适合研究模型外推机制与训练数据设计的学者参考。

我们研究Transformer的长度泛化(LG)问题:模型在较短序列上训练后,能否保持对远超训练长度的未见输入的性能。此前研究(Huang et al., 2025)表明,当训练序列长度超过某一有限阈值时,Transformer最终可实现长度泛化,但未明确该阈值大小。本文首次提供长度泛化的定量边界。基于先前的实证与理论工作,我们在多种场景下分析了LG:$\ ext{ℓ}_ ext{∞}$误差控制与分布平均误差控制、无限精度softmax注意力与有限精度注意力(退化为argmax)、单层与双层Transformer。在所有情形中,我们证明:当模型在长序列上的内部行为可被其在训练中见过的短序列行为“模拟”时,长度泛化即发生。我们的边界给出了训练数据长度的定性估计,并通过实证验证了这些洞见。结果深化了对Transformer外推机制的理论理解,形式化了复杂任务需更丰富训练数据的直觉。

原文摘要 · Abstract (English)

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.

Transformer长度泛化理论分析

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