The Role of Sparsity for Length Generalization in Transformers

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Golowich, Noah, Jelassi, Samy, Brandfonbrener, David, Kakade, Sham M., Malach, Eran
Natura: Preprint
Pubblicazione: 2025
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866917935061139456
author Golowich, Noah
Jelassi, Samy
Brandfonbrener, David
Kakade, Sham M.
Malach, Eran
author_facet Golowich, Noah
Jelassi, Samy
Brandfonbrener, David
Kakade, Sham M.
Malach, Eran
contents Training large language models to predict beyond their training context lengths has drawn much attention in recent years, yet the principles driving such behavior of length generalization remain underexplored. We propose a new theoretical framework to study length generalization for the next-token prediction task, as performed by decoder-only transformers. Conceptually, we show that length generalization occurs as long as each predicted token depends on a small (fixed) number of previous tokens. We formalize such tasks via a notion we call $k$-sparse planted correlation distributions, and show that an idealized model of transformers which generalize attention heads successfully length-generalize on such tasks. As a bonus, our theoretical model justifies certain techniques to modify positional embeddings which have been introduced to improve length generalization, such as position coupling. We support our theoretical results with experiments on synthetic tasks and natural language, which confirm that a key factor driving length generalization is a ``sparse'' dependency structure of each token on the previous ones. Inspired by our theory, we introduce Predictive Position Coupling, which trains the transformer to predict the position IDs used in a positional coupling approach. Predictive Position Coupling thereby allows us to broaden the array of tasks to which position coupling can successfully be applied to achieve length generalization.
format Preprint
id arxiv_https___arxiv_org_abs_2502_16792
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle The Role of Sparsity for Length Generalization in Transformers
Golowich, Noah
Jelassi, Samy
Brandfonbrener, David
Kakade, Sham M.
Malach, Eran
Machine Learning
Artificial Intelligence
Computation and Language
Training large language models to predict beyond their training context lengths has drawn much attention in recent years, yet the principles driving such behavior of length generalization remain underexplored. We propose a new theoretical framework to study length generalization for the next-token prediction task, as performed by decoder-only transformers. Conceptually, we show that length generalization occurs as long as each predicted token depends on a small (fixed) number of previous tokens. We formalize such tasks via a notion we call $k$-sparse planted correlation distributions, and show that an idealized model of transformers which generalize attention heads successfully length-generalize on such tasks. As a bonus, our theoretical model justifies certain techniques to modify positional embeddings which have been introduced to improve length generalization, such as position coupling. We support our theoretical results with experiments on synthetic tasks and natural language, which confirm that a key factor driving length generalization is a ``sparse'' dependency structure of each token on the previous ones. Inspired by our theory, we introduce Predictive Position Coupling, which trains the transformer to predict the position IDs used in a positional coupling approach. Predictive Position Coupling thereby allows us to broaden the array of tasks to which position coupling can successfully be applied to achieve length generalization.
title The Role of Sparsity for Length Generalization in Transformers
topic Machine Learning
Artificial Intelligence
Computation and Language
url https://arxiv.org/abs/2502.16792