potentialpaper

Attend or Perish: Benchmarking Attention on Algorithmic Reasoning

Michal Spiegel, Michal Štefánik, Marek Kadlčík, Valeria Ruscio, Martin Fajčík, Josef Kuchař

ICLR 2026 submission

Edit this page

Or clone it with git

The page gets its repository with its first edit, so start in the web editor.

Or let your agent set it up

It checks and sets up everything: signing in, git, the clone, credentials and an SSH key.

Abstract. While Transformer models can learn algorithmic tasks and generalize reliably to unseen, in-distribution data, they often fail catastrophically when required to extrapolate to sequence lengths beyond their training regime. This paper investigates the root cause of this critical failure in length generalization. Using AttentionSpan—a benchmark of algorithmic tasks such as addition and multiplication, specifically designed to enable interpretability and facilitate inspection of internal model computations—we analyze the model’s behavior on length extrapolation. Our findings indicate that this failure does not reflect a fundamental limitation in the model’s ability to generalize or to induce general rules for the task. Instead, we attribute the problem to inconsistent attention patterns—information retrieval strategies learned by individual attention heads—which fail to remain stable as sequence length increases. This inconsistency disrupts the execution of the algorithm at novel lengths. We show that fine-tuning just a single column of the Key and Query projection matrices in all attention heads on sequences longer than those seen during initial training is sufficient for the model to perform well on these same longer sequences. While this does not extend extrapolation beyond the fine-tuned lengths, it demonstrates that robust length generalization can be achieved with a minimal adjustment to attention weights, suggesting that such failures could be addressed early in training. We make our benchmark and code publicly available.

Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.

Claim this paper
How does this paper connect to your work? Write how you built on it, compared with it or reproduced it, or add a summary, a critique or errata.
Or make it interactive:
Start writing

add · history

No versions are recorded yet: its preprint, the venues it went to and what they decided, the camera-ready. Missing a version?

We don't know of a submission of this paper to a venue with open reviews. Missing a submission?

Loading the discussion…