TensorX
返回文献探索

Paper · arXiv 2402.09371

Transformers Can Achieve Length Generalization But Not Robustly

Yongchao Zhou, Uri Alon, Xinyun Chen, Xuezhi Wang, Rishabh Agarwal, Denny Zhou

14 upvotesFebruary 14, 2024arXiv 预印本
AI 摘要

Transformers can extrapolate to longer test sequences with the right data format and position encodings, but length generalization is sensitive to initialization and data order.

Transformerslength generalizationaddition taskposition encodingsin-distribution generalization

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 variances across different random seeds.

北京市昌平区探索星信息技术及软件开发工作室

京ICP备2026059466号
Transformers Can Achieve Length Generalization But Not Robustly | TensorX