Randomized Positional Encodings Boost Length Generalization of Transformers
Anian Ruoss, Gr\'egoire Del\'etang, Tim Genewein, Jordi Grau-Moya,, R\'obert Csord\'as, Mehdi Bennani, Shane Legg, Joel Veness

TL;DR
This paper introduces a novel randomized positional encoding scheme that enables Transformers to generalize to longer sequences, addressing the out-of-distribution issue of traditional encodings and improving performance on various reasoning tasks.
Contribution
The authors propose a new randomized positional encoding method that enhances length generalization in Transformers, overcoming limitations of existing encodings.
Findings
Improved test accuracy by 12.0% on average for longer sequences.
Demonstrated effectiveness across 15 algorithmic reasoning tasks.
Validated with a large-scale evaluation of 6000 models.
Abstract
Transformers have impressive generalization capabilities on tasks with a fixed context length. However, they fail to generalize to sequences of arbitrary length, even for seemingly simple tasks such as duplicating a string. Moreover, simply training on longer sequences is inefficient due to the quadratic computation complexity of the global attention mechanism. In this work, we demonstrate that this failure mode is linked to positional encodings being out-of-distribution for longer sequences (even for relative encodings) and introduce a novel family of positional encodings that can overcome this problem. Concretely, our randomized positional encoding scheme simulates the positions of longer sequences and randomly selects an ordered subset to fit the sequence's length. Our large-scale empirical evaluation of 6000 models across 15 algorithmic reasoning tasks shows that our method allows…
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
TopicsMultimodal Machine Learning Applications · Topic Modeling · Natural Language Processing Techniques
Methodsfail · Test
