Position Encoding with Random Float Sampling Enhances Length Generalization of Transformers
Not on the map. Why?
Abstract (arXiv)
Length generalization is the ability of language models to maintain performance on inputs longer than those seen during pretraining. In this work, we introduce a simple yet powerful position encoding (PE) strategy, Random Float Sampling (RFS), that generalizes well to lengths unseen during pretraining or fine-tuning. In particular, instead of selecting position indices from a predefined discrete set, RFS uses randomly sampled continuous values, thereby avoiding out-of-distribution (OOD) issues on unseen lengths by exposing the model to diverse indices during training. Since assigning indices to tokens is a common and fundamental procedure in widely used PEs, the advantage of RFS can easily be incorporated into, for instance, the absolute sinusoidal encoding, RoPE, and ALiBi. Experiments corroborate its effectiveness by showing that RFS results in superior performance in length generalization tasks as well as zero-shot commonsense reasoning benchmarks.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 33 of its 42 references that are in the map. First posted on arXiv 15 Feb 2026.
Builds on
33 of 42 references.
References · 33
- 2017Attention Is All You Needcited by 59,932
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,491
- 2022ReAct: Synergizing Reasoning and Acting in Language Modelscited by 8,355
- 2018Think you have Solved Question Answering? Try ARC, the AI2 Reasoning Challengecited by 4,710
- 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,581
- 2022Large Language Models are Zero-Shot Reasonerscited by 4,323
- 2019HellaSwag: Can a Machine Really Finish Your Sentence?cited by 4,018
- 2022Robust Speech Recognition via Large-Scale Weak Supervisioncited by 3,972
- 2018Can a Suit of Armor Conduct Electricity? A New Dataset for Open Book Question Answeringcited by 2,114
- 2019Transformer-XL: Attentive Language Models Beyond a Fixed-Length Contextcited by 1,830
- 2019SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systemscited by 1,718
- 2021Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationcited by 1,085
21 more
- 2021Show Your Work: Scratchpads for Intermediate Computation with Language Modelscited by 871
- 2017RACE: Large-scale ReAding Comprehension Dataset From Examinationscited by 851
- 2023Extending Context Window of Large Language Models via Positional Interpolationcited by 721
- 2024TinyLlama: An Open-Source Small Language Modelcited by 604
- 2023Textbooks Are All You Need II: phi-1.5 technical reportcited by 559
- 2019Analysing Mathematical Reasoning Abilities of Neural Modelscited by 331
- 2023The Impact of Positional Encoding on Length Generalization in Transformerscited by 319
- 2024LongRoPE: Extending LLM Context Window Beyond 2 Million Tokenscited by 302
- 2025Small Language Models are the Future of Agentic AIcited by 254
- 2023MEGABYTE: Predicting Million-byte Sequences with Multiscale Transformerscited by 164
- 2022Transformer Language Models without Positional Encodings Still Learn Positional Informationcited by 148
- 2023Randomized Positional Encodings Boost Length Generalization of Transformerscited by 114
- 2022KERPLE: Kernelized Relative Positional Embedding for Length Extrapolationcited by 84
- 2020Shortformer: Better Language Modeling using Shorter Inputscited by 76
- 2021CAPE: Encoding Relative Positions with Continuous Augmented Positional Embeddingscited by 47
- 2025Rope to Nope and Back Again: A New Hybrid Attention Strategycited by 46
- 2025Scalable-Softmax Is Superior for Attentioncited by 38
- 2021SHAPE: Shifted Absolute Position Embedding for Transformerscited by 37
- 2024DAPE: Data-Adaptive Positional Encoding for Length Extrapolationcited by 30
- 2024Why Are Positional Encodings Nonessential for Deep Autoregressive Transformers? Revisiting a Petroglyphcited by 6
- 2025Wavelet-based Positional Representation for Long Contextcited by 6
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2025Beyond Single-Task: Robust Multi-Task Length Generalization for LLMs
- 2024Universal Length Generalization with Turing Programs
- 2025Long-Short Alignment for Effective Long-Context Modeling in LLMs
- 2026Randomized YaRN Improves Length Generalization for Long-Context Reasoning
- 2024Explicitly Encoding Structural Symmetry is Key to Length Generalization in Arithmetic Tasks
- 2024DeciMamba: Exploring the Length Extrapolation Potential of Mamba
- 2025Self-Improving Transformers Overcome Easy-to-Hard and Length Generalization Challenges
- 2024On Provable Length and Compositional Generalization