Transformers Can Achieve Length Generalization But Not Robustly
Yongchao Zhou, Uri Alon, Xinyun Chen, Xuezhi Wang, Rishabh Agarwal,, Denny Zhou

TL;DR
This paper investigates the ability of Transformers to generalize to longer sequences, revealing that while they can extrapolate with the right setup, their robustness is limited and sensitive to training conditions.
Contribution
It demonstrates that standard Transformers can achieve length generalization with proper data and encoding choices, but their robustness remains fragile and inconsistent.
Findings
Transformers can extrapolate to 2.5x input length with correct setup
Length generalization is sensitive to data format and position encoding
Robustness of length generalization varies with training conditions
Abstract
Length generalization, defined as the ability to extrapolate from shorter training sequences to longer test ones, is a significant challenge for language models. This issue persists even with large-scale Transformers handling relatively straightforward tasks. In this paper, we test the Transformer's ability of length generalization using the task of addition of two integers. We show that the success of length generalization is intricately linked to the data format and the type of position encoding. Using the right combination of data format and position encodings, we show for the first time that standard Transformers can extrapolate to a sequence length that is 2.5x the input length. Nevertheless, unlike in-distribution generalization, length generalization remains fragile, significantly influenced by factors like random weight initialization and training data order, leading to large…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsNeural Networks and Applications
