Attend or Perish: Benchmarking Attention in Algorithmic Reasoning

Michal Spiegel, Michal Štefánik, Marek Kadlčík, Josef Kuchař
2/28/2025
cs.LGcs.AI

Official code: michalspiegel/AttentionSpan (5 stars, last commit 2026-01-29).

Abstract

Can transformers learn to perform algorithmic tasks reliably across previously unseen input/output domains? While pre-trained language models show solid accuracy on benchmarks incorporating algorithmic reasoning, assessing the reliability of these results necessitates an ability to distinguish genuine algorithmic understanding from memorization. In this paper, we propose AttentionSpan, an algorithmic benchmark comprising five tasks of infinite input domains where we can disentangle and trace the correct, robust algorithm necessary for the task. This allows us to assess (i) models' ability to extrapolate to unseen types of inputs, including new lengths, value ranges or input domains, but also (ii)to assess the robustness of their learned mechanisms. By analyzing attention maps and performing targeted interventions, we show that attention mechanism directly causes failures in extrapolation. We make the implementation of all our tasks and interpretability methods publicly available at https://github.com/michalspiegel/AttentionSpan .

View on arXivView PDF

Code Implementations(1)

This is the official code for the paper Attend or Perish: Benchmarking Attention in Algorithmic Reasoning

50Shell, PythonFeb 12, 20258 months ago

Similar Papers

Cite this paper

@article{spiegel2025attend,
  title  = {Attend or Perish: Benchmarking Attention in Algorithmic Reasoning},
  author = {Michal Spiegel and Michal Štefánik and Marek Kadlčík and Josef Kuchař},
  year   = {2025},
  eprint = {2503.01909},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2503.01909v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2503.01909.svg)](https://codeofpaper.com/paper/2503.01909)

Discussion