Transformers Can Achieve Length Generalization but Not Robustly

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.5\times$ 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 variances across different random seeds.

Cite

Text

Zhou et al. "Transformers Can Achieve Length Generalization but Not Robustly." ICLR 2024 Workshops: ME-FoMo, 2024.

Markdown

[Zhou et al. "Transformers Can Achieve Length Generalization but Not Robustly." ICLR 2024 Workshops: ME-FoMo, 2024.](https://mlanthology.org/iclrw/2024/zhou2024iclrw-transformers/)

BibTeX

@inproceedings{zhou2024iclrw-transformers,
  title     = {{Transformers Can Achieve Length Generalization but Not Robustly}},
  author    = {Zhou, Yongchao and Alon, Uri and Chen, Xinyun and Wang, Xuezhi and Agarwal, Rishabh and Zhou, Denny},
  booktitle = {ICLR 2024 Workshops: ME-FoMo},
  year      = {2024},
  url       = {https://mlanthology.org/iclrw/2024/zhou2024iclrw-transformers/}
}