Randomized Positional Encodings Boost Length Generalization of Transformers
Not on the map. Why?
Abstract (arXiv)
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 Transformers to generalize to sequences of unseen length (increasing test accuracy by 12.0% on average).
Key facts. Cited by 114 papers in the map (data through 7 Oct 2026). Builds on 29 of its 36 references that are in the map. First posted on arXiv 26 May 2023.
Builds on
29 of 36 references.
References · 29
- 2017Attention Is All You Needcited by 59,932
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2014Adam: A Method for Stochastic Optimizationcited by 36,960
- 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 29,915
- 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,581
- 2019Transformer-XL: Attentive Language Models Beyond a Fixed-Length Contextcited by 1,830
- 2021Scaling Language Models: Methods, Analysis & Insights from Training Gophercited by 1,199
- 2021Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationcited by 1,085
- 2022A Generalist Agentcited by 802
- 2020Long Range Arena: A Benchmark for Efficient Transformerscited by 696
- 2018Universal Transformerscited by 613
- 2017Convolutional Sequence to Sequence Learningcited by 550
17 more
- 2019Theoretical Limitations of Self-Attention in Neural Sequence Modelscited by 286
- 2019Measuring Compositional Generalization: A Comprehensive Method on Realistic Datacited by 280
- 2020COGS: A Compositional Generalization Challenge Based on Semantic Interpretationcited by 260
- 2022Neural Networks and the Chomsky Hierarchycited by 214
- 2020Random Features Strengthen Graph Neural Networkscited by 184
- 2021The Devil is in the Detail: Simple Tricks Improve Systematic Generalization of Transformerscited by 117
- 2022Overcoming a Theoretical Limitation of Self-Attentioncited by 110
- 2022Formal Language Recognition by Hard Attention Transformers: Perspectives from Circuit Complexitycited by 92
- 2021Making Transformers Solve Compositional Taskscited by 72
- 2021The Neural Data Router: Adaptive Control Flow in Transformers Improves Systematic Generalizationcited by 62
- 2020Learning to Encode Position for Transformer with Continuous Dynamical Modelcited by 61
- 2022A Generalist Neural Algorithmic Learnercited by 58
- 2019Sequential Neural Networks as Automatacited by 54
- 2020Compositional Generalization by Learning Analytical Expressionscited by 53
- 2020How Can Self-Attention Networks Recognize Dyck-n Languages?cited by 51
- 2022Systematic Generalization and Emergent Structures in Transformers Trained on Structured Taskscited by 19
- 2020A Survey of Neural Networks and Formal Languagescited by 17
Built on by
Citing papers per year: 2023: 13; 2024: 56; 2025: 29; 2026: 16.
114 papers.
Sort:
By area:
- 2023Language Modeling Is Compressioncited by 225
- 2024Repeat After Me: Transformers are Better than State Space Models at Copyingcited by 208
- 2023What Algorithms can Transformers Learn? A Study in Length Generalizationcited by 198
- 2024Round and Round We Go! What makes Rotary Positional Encodings useful?cited by 111
- 2023PoSE: Efficient Context Window Extension of LLMs via Positional Skip-wise Trainingcited by 109
- 2024HiAgent: Hierarchical Working Memory Management for Solving Long-Horizon Agent Tasks with Large Language Modelcited by 101
- 2024FiT: Flexible Vision Transformer for Diffusion Modelcited by 84
- 2024Transformers Can Achieve Length Generalization But Not Robustlycited by 82
- 2024Transformers Can Do Arithmetic with the Right Embeddingscited by 77
- 2024Why are Sensitive Functions Hard for Transformers?cited by 74
- 2023Advancing Transformer Architecture in Long-Context Large Language Models: A Comprehensive Surveycited by 71
- 2023Positional Description Matters for Transformers Arithmeticcited by 56
38 more
- 2024LongEmbed: Extending Embedding Models for Long Context Retrievalcited by 47
- 2023CLEX: Continuous Length Extrapolation for Large Language Modelscited by 43
- 2024How Far Can Transformers Reason? The Globality Barrier and Inductive Scratchpadcited by 35
- 2026DreamX-World 1.0: A General-Purpose Interactive World Modelcited by 33
- 2023Giraffe: Adventures in Expanding Context Lengths in LLMscited by 32
- 2024A phase transition between positional and semantic learning in a solvable model of dot-product attentioncited by 30
- 2024DAPE: Data-Adaptive Positional Encoding for Length Extrapolationcited by 30
- 2025Self-Improving Transformers Overcome Easy-to-Hard and Length Generalization Challengescited by 30
- 2024The CLRS-Text Algorithmic Reasoning Language Benchmarkcited by 28
- 2023The Efficiency Spectrum of Large Language Models: An Algorithmic Surveycited by 25
- 2024Resonance RoPE: Improving Context Length Generalization of Large Language Modelscited by 25
- 2024ViTAR: Vision Transformer with Any Resolutioncited by 25
- 2024Dataset Decomposition: Faster LLM Training with Variable Sequence Length Curriculumcited by 25
- 2024Language Models Need Inductive Biases to Count Inductivelycited by 25
- 2024Universal Length Generalization with Turing Programscited by 25
- 2024DGR-MIL: Exploring Diverse Global Representation in Multiple Instance Learning for Whole Slide Image Classificationcited by 25
- 2024ALR2: A Retrieve-then-Reason Framework for Long-context Question Answeringcited by 25
- 2024Two Stones Hit One Bird: Bilevel Positional Encoding for Better Length Extrapolationcited by 23
- 2024LongRecipe: Recipe for Efficient Long Context Generalization in Large Language Modelscited by 23
- 2024Training Neural Networks as Recognizers of Formal Languagescited by 23
- 2024Long Context Alignment with Short Instructions and Synthesized Positionscited by 22
- 2024Position Coupling: Improving Length Generalization of Arithmetic Transformers Using Task Structurecited by 22
- 2024Transformers Provably Learn Sparse Token Selection While Fully-Connected Nets Cannotcited by 21
- 2024TULIP: Token-length Upgraded CLIPcited by 18
- 2024HoPE: A Novel Positional Encoding Without Long-Term Decay for Enhanced Context Awareness and Extrapolationcited by 17
- 2024An Efficient Recipe for Long Context Extension via Middle-Focused Positional Encodingcited by 16
- 2024AMES: Asymmetric and Memory-Efficient Similarity Estimation for Instance-level Retrievalcited by 16
- 2024Superposition Prompting: Improving and Accelerating Retrieval-Augmented Generationcited by 15
- 2024A Survey on Compositional Learning of AI Models: Theoretical and Experimental Practicescited by 15
- 2024FiTv2: Scalable and Improved Flexible Vision Transformer for Diffusion Modelcited by 15
- 2024When Precision Meets Position: BFloat16 Breaks Down RoPE in Long-Context Trainingcited by 15
- 2024On the Expressiveness and Length Generalization of Selective State-Space Models on Regular Languagescited by 15
- 2025Extrapolation by Association: Length Generalization Transfer in Transformerscited by 13
- 2023When Meta-Learning Meets Online and Continual Learning: A Surveycited by 12
- 2024VSTAR: Generative Temporal Nursing for Longer Dynamic Video Synthesiscited by 11
- 2024A Theory for Length Generalization in Learning to Reasoncited by 11
- 2023From Interpolation to Extrapolation: Complete Length Generalization for Arithmetic Transformerscited by 10
- 2024Explicitly Encoding Structural Symmetry is Key to Length Generalization in Arithmetic Taskscited by 10
50 most cited of 114 All 114 (JSON)
- 2026RoPE is Dead, Long Live RoPE: Towards Scalable Data-aware Positional Encodings28 Sep 2026
- 2026The Geometry of Logic: Stratification Induces Semantic Structure and Robust Reasoning26 Sep 2026
- 2026Doc2FRC: Length-Consistent Document-Level Machine Translation via Fixed-Range Chunking11 Sep 2026
- 2026Content-Based Addressing for Long Context7 Sep 2026
- 2026Universal Transformers for Circuit Computations: Perfect Length Generalization in Tiny Transformers31 Aug 2026
- 2026Labeled Incidence Structures for Native Transformer Modeling of Text, Knowledge Graphs, and Hypergraphs29 Jul 2026
- 2026Relative Positions Generalize, Absolute Positions Memorize: An Implicit-Bias Account of Length Generalization in Attention21 Jul 2026
- 2026Stabilizing Extrapolation in Looped Transformers via Learned Stochastic Stopping29 Jun 2026
- 2026Why Do Accumulated Transformations Extrapolate?23 Jun 2026
- 2026DreamX-World 1.0: A General-Purpose Interactive World Model15 Jun 2026
- 2026Length Generalization with Log-Depth Recurrent Units25 May 2026
- 2026A Measure-Theoretic Analysis of Reasoning: Structural Generalization and Approximation Limits19 May 2026
38 more
- 2026To See the Unseen: on the Generalization Ability of Transformers in Symbolic Reasoning23 Apr 2026
- 2026Shuffle the Context: RoPE-Perturbed Self-Distillation for Long-Context Adaptation15 Apr 2026
- 2026An Evaluation of Context Length Extrapolation in Long Code via Positional Embeddings and Efficient Attention25 Feb 2026
- 2026Position Encoding with Random Float Sampling Enhances Length Generalization of Transformers15 Feb 2026
- 2025Towards Long-window Anchoring in Vision-Language Model Distillation25 Dec 2025
- 2025Group Representational Position Encoding8 Dec 2025
- 2025Extending Audio Context for Long-Form Understanding in Large Audio-Language Models17 Oct 2025
- 2025To Infinity and Beyond: Tool-Use Unlocks Length Generalization in State Space Models16 Oct 2025
- 2025Head-wise Adaptive Rotary Positional Encoding for Fine-Grained Image Generation12 Oct 2025
- 2025HeSRN: Representation Learning On Heterogeneous Graphs via Slot-Aware Retentive Network10 Oct 2025
- 2025Bridging Kolmogorov Complexity and Deep Learning: Asymptotically Optimal Description Length Objectives for Transformers26 Sep 2025
- 2025HoPE: Hyperbolic Rotary Positional Encoding for Stable Long-Range Dependency Modeling in Large Language Models5 Sep 2025
- 2025Learning neuro-symbolic convergent term rewriting systems25 Jul 2025
- 2025The Imitation Game: Turing Machine Imitator is Length Generalizable Reasoner17 Jul 2025
- 2025SAS: Simulated Attention Score10 Jul 2025
- 2025SeqPE: Transformer with Sequential Position Encoding16 Jun 2025
- 2025Long-Short Alignment for Effective Long-Context Modeling in LLMs13 Jun 2025
- 2025Extrapolation by Association: Length Generalization Transfer in Transformers10 Jun 2025
- 2025Position as Probability: Self-Supervised Transformers that Think Past Their Training for Length Extrapolation1 Jun 2025
- 2025LLM as Effective Streaming Processor: Bridging Streaming-Batch Mismatches with Group Position Encoding22 May 2025
- 2025Position: An Empirically Grounded Identifiability Theory Will Accelerate Self-Supervised Learning Research17 Apr 2025
- 2025On Vanishing Variance in Transformer Length Generalization3 Apr 2025
- 2025Spline-based Transformers3 Apr 2025
- 2025TRA: Better Length Generalisation with Threshold Relative Attention29 Mar 2025
- 2025Boosting Resolution Generalization of Diffusion Transformers with Randomized Positional Encodings24 Mar 2025
- 2025Language Models, Graph Searching, and Supervision Adulteration: When More Supervision is Less and How to Make More More13 Mar 2025
- 2025Context-aware Biases for Length Extrapolation11 Mar 2025
- 2025LEDiT: Your Length-Extrapolatable Diffusion Transformer without Positional Encoding6 Mar 2025
- 2025The Role of Sparsity for Length Generalization in Transformers24 Feb 2025
- 2025Learning to Add, Multiply, and Execute Algorithmic Instructions Exactly with Neural Networks24 Feb 2025
- 2025Self-Improving Transformers Overcome Easy-to-Hard and Length Generalization Challenges3 Feb 2025
- 2025ReGLA: Refining Gated Linear Attention3 Feb 2025
- 2025Rethinking Addressing in Language Models via Contexualized Equivariant Positional Encoding1 Jan 2025
- 2024On the Expressiveness and Length Generalization of Selective State-Space Models on Regular Languages26 Dec 2024
- 2024Investigating Length Issues in Document-level Machine Translation23 Dec 2024
- 2024Compositional Generalization Across Distributional Shifts with Sparse Tree Operations18 Dec 2024
- 2024Rethinking Associative Memory Mechanism in Induction Head16 Dec 2024
- 2024When Precision Meets Position: BFloat16 Breaks Down RoPE in Long-Context Training20 Nov 2024
50 newest of 114 All 114 (JSON)
- 2024HiAgent: Hierarchical Working Memory Management for Solving Long-Horizon Agent Tasks with Large Language Modelcited by 101
- 2024The CLRS-Text Algorithmic Reasoning Language Benchmarkcited by 28
- 2024ALR2: A Retrieve-then-Reason Framework for Long-context Question Answeringcited by 25
- 2024Training Neural Networks as Recognizers of Formal Languagescited by 23
- 2024Explicitly Encoding Structural Symmetry is Key to Length Generalization in Arithmetic Taskscited by 10
- 2024Rethinking Tokenization: Crafting Better Tokenizers for Large Language Modelscited by 8
- 2025Rethinking Addressing in Language Models via Contexualized Equivariant Positional Encodingcited by 4
- 2025The Imitation Game: Turing Machine Imitator is Length Generalizable Reasonercited by 3
- 2024Rethinking Associative Memory Mechanism in Induction Headcited by 0
- 2026To See the Unseen: on the Generalization Ability of Transformers in Symbolic Reasoningcited by 0
- 2026A Measure-Theoretic Analysis of Reasoning: Structural Generalization and Approximation Limitscited by 0
- 2026The Geometry of Logic: Stratification Induces Semantic Structure and Robust Reasoningcited by 0
- 2026The Geometry of Logic: Stratification Induces Semantic Structure and Robust Reasoning26 Sep 2026
- 2026A Measure-Theoretic Analysis of Reasoning: Structural Generalization and Approximation Limits19 May 2026
- 2026To See the Unseen: on the Generalization Ability of Transformers in Symbolic Reasoning23 Apr 2026
- 2025The Imitation Game: Turing Machine Imitator is Length Generalizable Reasoner17 Jul 2025
- 2025Rethinking Addressing in Language Models via Contexualized Equivariant Positional Encoding1 Jan 2025
- 2024Rethinking Associative Memory Mechanism in Induction Head16 Dec 2024
- 2024Training Neural Networks as Recognizers of Formal Languages11 Nov 2024
- 2024ALR2: A Retrieve-then-Reason Framework for Long-context Question Answering4 Oct 2024
- 2024HiAgent: Hierarchical Working Memory Management for Solving Long-Horizon Agent Tasks with Large Language Model18 Aug 2024
- 2024The CLRS-Text Algorithmic Reasoning Language Benchmark6 Jun 2024
- 2024Explicitly Encoding Structural Symmetry is Key to Length Generalization in Arithmetic Tasks4 Jun 2024
- 2024Rethinking Tokenization: Crafting Better Tokenizers for Large Language Models1 Mar 2024
- 2024FiT: Flexible Vision Transformer for Diffusion Modelcited by 84
- 2024FiTv2: Scalable and Improved Flexible Vision Transformer for Diffusion Modelcited by 15
- 2024VSTAR: Generative Temporal Nursing for Longer Dynamic Video Synthesiscited by 11
- 2024LayerDAG: A Layerwise Autoregressive Diffusion Model for Directed Acyclic Graph Generationcited by 8
- 2025Boosting Resolution Generalization of Diffusion Transformers with Randomized Positional Encodingscited by 4
- 2025LEDiT: Your Length-Extrapolatable Diffusion Transformer without Positional Encodingcited by 3
- 2025Boosting Resolution Generalization of Diffusion Transformers with Randomized Positional Encodings24 Mar 2025
- 2025LEDiT: Your Length-Extrapolatable Diffusion Transformer without Positional Encoding6 Mar 2025
- 2024LayerDAG: A Layerwise Autoregressive Diffusion Model for Directed Acyclic Graph Generation4 Nov 2024
- 2024FiTv2: Scalable and Improved Flexible Vision Transformer for Diffusion Model17 Oct 2024
- 2024VSTAR: Generative Temporal Nursing for Longer Dynamic Video Synthesis20 Mar 2024
- 2024FiT: Flexible Vision Transformer for Diffusion Model19 Feb 2024
- 2024TULIP: Token-length Upgraded CLIPcited by 18
- 2025Towards Long-window Anchoring in Vision-Language Model Distillationcited by 2
- 2025Towards Long-window Anchoring in Vision-Language Model Distillation25 Dec 2025
- 2024TULIP: Token-length Upgraded CLIP13 Oct 2024
- 2026DreamX-World 1.0: A General-Purpose Interactive World Modelcited by 33
- 2026DreamX-World 1.0: A General-Purpose Interactive World Model15 Jun 2026
- 2023Language Modeling Is Compressioncited by 225
- 2024Repeat After Me: Transformers are Better than State Space Models at Copyingcited by 208
- 2023What Algorithms can Transformers Learn? A Study in Length Generalizationcited by 198
- 2024Round and Round We Go! What makes Rotary Positional Encodings useful?cited by 111
- 2023PoSE: Efficient Context Window Extension of LLMs via Positional Skip-wise Trainingcited by 109
- 2024Transformers Can Achieve Length Generalization But Not Robustlycited by 82
- 2024Transformers Can Do Arithmetic with the Right Embeddingscited by 77
- 2024Why are Sensitive Functions Hard for Transformers?cited by 74
- 2023Advancing Transformer Architecture in Long-Context Large Language Models: A Comprehensive Surveycited by 71
- 2023Positional Description Matters for Transformers Arithmeticcited by 56
- 2024LongEmbed: Extending Embedding Models for Long Context Retrievalcited by 47
- 2023CLEX: Continuous Length Extrapolation for Large Language Modelscited by 43
12 most cited of 87 All 87 (JSON)
- 2026RoPE is Dead, Long Live RoPE: Towards Scalable Data-aware Positional Encodings28 Sep 2026
- 2026Doc2FRC: Length-Consistent Document-Level Machine Translation via Fixed-Range Chunking11 Sep 2026
- 2026Content-Based Addressing for Long Context7 Sep 2026
- 2026Universal Transformers for Circuit Computations: Perfect Length Generalization in Tiny Transformers31 Aug 2026
- 2026Labeled Incidence Structures for Native Transformer Modeling of Text, Knowledge Graphs, and Hypergraphs29 Jul 2026
- 2026Relative Positions Generalize, Absolute Positions Memorize: An Implicit-Bias Account of Length Generalization in Attention21 Jul 2026
- 2026Stabilizing Extrapolation in Looped Transformers via Learned Stochastic Stopping29 Jun 2026
- 2026Why Do Accumulated Transformations Extrapolate?23 Jun 2026
- 2026Length Generalization with Log-Depth Recurrent Units25 May 2026
- 2026An Evaluation of Context Length Extrapolation in Long Code via Positional Embeddings and Efficient Attention25 Feb 2026
- 2026Position Encoding with Random Float Sampling Enhances Length Generalization of Transformers15 Feb 2026
- 2025Group Representational Position Encoding8 Dec 2025
12 newest of 87 All 87 (JSON)