Salvato in:
Dettagli Bibliografici
Autori principali: Shimizu, Atsushi, Taniguchi, Shohei, Matsuo, Yutaka
Natura: Preprint
Pubblicazione: 2026
Soggetti:
Accesso online:https://arxiv.org/abs/2602.14050
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866910023110623232
author Shimizu, Atsushi
Taniguchi, Shohei
Matsuo, Yutaka
author_facet Shimizu, Atsushi
Taniguchi, Shohei
Matsuo, Yutaka
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2602_14050
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Position Encoding with Random Float Sampling Enhances Length Generalization of Transformers
Shimizu, Atsushi
Taniguchi, Shohei
Matsuo, Yutaka
Machine Learning
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.
title Position Encoding with Random Float Sampling Enhances Length Generalization of Transformers
topic Machine Learning
url https://arxiv.org/abs/2602.14050