PreprintCited by 106semigroups and automata theoryComputability, Logic, AI AlgorithmsNeural Networks and Applications

The DOI matches its DataCite record; 34 of the 34 references it cites were found in a registry or an index; 7 of the 28 sources its claims cite were checked for support.

Looped Transformers for Length Generalization

Open access
Fan, Ying, Du, Yilun, Ramchandran, Kannan, Lee, Kangwook·2024·arXiv

Abstract

Recent work has shown that Transformers trained from scratch can successfully solve various arithmetic and algorithmic tasks, such as adding numbers and computing parity. While these Transformers generalize well on unseen inputs of the same length, they struggle with length generalization, i.e., handling inputs of unseen lengths. In this work, we demonstrate that looped Transformers with an adaptive number of steps significantly improve length generalization. We focus on tasks with a known iterative solution, involving multiple iterations of a RASP-L operation - a length-generalizable operation that can be expressed by a finite-sized Transformer. We train looped Transformers using our proposed learning algorithm and observe that they learn highly length-generalizable solutions for various tasks.

Overview

AI snapshot

Written from the paper’s full text.

TL;DR

Looped Transformers with an adaptive number of looped steps and step-dependent supervision improve length generalization on algorithmic tasks with known iterative n-RASP-L solutions. Trained only on end-to-end input-output pairs plus the number of steps, they outperform NTP baselines on Parity, Copy, Addition, and related tasks.

Key findings

  • Looped Transformers significantly improve length generalization: for Parity, the model generalizes to more than 40 digits near perfectly when trained with lengths up to 20 digits.
  • For Addition and Copy, where next-token prediction failed when tested at maximum training length +10, the looped model still performs almost perfectly.
  • Variants of NTP can improve generalization—NTP-Loop helps on Addition, Copy, and Multiplication; NTP-Pause helps slightly on Binary Sum and Unique Set—but all fall behind the adaptive-depth looped method.
  • The maximum-confidence stopping criterion reaches lowest cross-entropy when generalization is near perfect; per-sample stopping works almost as well for converging tasks (Addition, Copy, Multiplication, Unique Set) but worse for non-converging tasks (Parity, Binary Sum).

Methods

  • The paper defines n-RASP-L problems: tasks solvable by T(n) sequential applications of a RASP-L operation P′, with pre- and post-processing, and gives n-RASP-L solutions for Parity, Copy, and Addition.
  • It trains looped decoder-only GPT-2 models with NoPE, input injection, and step-dependent supervision on final answers only, without intermediate-step supervision; training data include (x, y) pairs and the pre-defined number of steps T(n).
  • Experiments cover Parity, Copy, Binary Addition, Binary Sum, Binary Multiplication, and Unique Set, with curriculum learning, AdamW, batch size 64, 100k gradient steps, evaluation on 6400 random samples, and mean exact match accuracy from five seeds; baselines include vanilla NTP, NTP with pause tokens, and NTP with weight-tied layers.

Limitations

  • The paper states that n-RASP-L does not support tasks requiring multiple loops followed by each other, and extending to multiple loops is future work.
  • Direct looped training can be computationally demanding when the number of looped steps is large; stopping gradient tracking for earlier steps may help but could trade off performance.
  • The authors state they train for a limited number of steps and lengths due to limited computing resources, use NoPE for simplicity, and require the ground-truth number of steps in training data, an additional requirement compared with normal end-to-end training.

Model-written summary. Check it against the paper before relying on it.

Integrity signals

Registry

DataCite · 10.48550/arxiv.2409.15647

Cites

0 citation errors · 0 not checkable

Statistics

Nothing to recompute.

Verification

Claims the paper makes

20 Own interpretation · 16 Own result · 12 Sources not found · 9 No basis given · 5 Partly supported · 4 Not checked yet · 1 Supported · 1 Own method · accuracy not yet measured

Show all 30 claims

  • It may state two separate claims as one. 18
  • Probably not a substantial claim. 27
  • The quote only partly states this claim. 1
38 of 38
  • The paper relies on this without support.

    Intermediate supervision and CoT training data can be difficult to collect.

    “However, such intermediate supervision can be difficult to get, just like collecting helping CoT steps could be difficult.”
    “First, CoT training data could be hard to collect.”
  • The paper relies on this without support.

    CoT steps that could convert the next token prediction task to RASP-L programs might not always exist.

    “Moreover, CoT steps that could convert the next token prediction task to RASP-L programs might not always exist.”
  • The authors state this as an assumption.

    The maximum length of the training set is n, the number of steps needed is T(n), and the number of layers in each step is k.

    “Assume that the maximum length of the training set is n, the number of steps needed is T (n), and the number of layers in each step is k.”
  • The authors state this as an assumption.

    NTP and FOP use a fixed number of layers C.

    “Assume that NTP and FOP are using a fixed number of layers C.”
  • The authors state this as an assumption.

    The test length is n'.

    “And we test on length n ′ .”
5 of 5

Self-check

Percentages, sums and reported differences re-computed from the paper’s own numbers.

Each contradiction between two passages listed here was confirmed by an independent check.

3 of 3

Citations

Cites

The publisher hasn’t deposited this paper’s reference list.

Research works printed but not linked: 4

  1. Yilun Du, Shuang Li, Joshua Tenenbaum, and Igor Mordatch. Learning iterative reasoning through energy minimization. In International Conference on Machine Learning, pp. 5570-5582. PMLR, 2022.
  2. Yilun Du, Jiayuan Mao, and Joshua B Tenenbaum. Learning iterative reasoning through energy diffusion. In Forty-first International Conference on Machine Learning, 2024.
  3. Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019.
  4. Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.

Cited by

Sorted by citations

See all 106

Metadata

Authors
Fan, Y., Du, Y., Ramchandran, K., & Lee, K.
Affiliations
  • University of Wisconsin–Madison (US)
  • Massachusetts Institute of Technology (US)
  • University of California, Berkeley (US)
Venue
arXiv
Publisher
arXiv
Published
2024
ISSN
2331-8422 (ISSN-L)
OpenAlex
W4403788968
Cited by
0
References
0
Type
posted content
Language
en
Open access
Locations
  • arXiv (Cornell University) (submittedVersion)
  • arXiv (Cornell University)
Funders
National Science Foundation (2339978, 2023239, CAREER)
Topics
  • Physical Sciences › Computer Science › Computational Theory and Mathematics › semigroups and automata theory
  • Physical Sciences › Computer Science › Computational Theory and Mathematics › Computability, Logic, AI Algorithms
  • Physical Sciences › Computer Science › Artificial Intelligence › Neural Networks and Applications
Keywords
length generalization, iterative computation, arithmetic exercises, algorithmic tasks

About these checks

Registry, retraction, Cites and statistics results are computed, not judged, with one exception: a printed reference that no index lists is read once by a model before it counts as a citation error. Claims are extracted by a model and kept only when their quote appears verbatim in the text; each cited source is then checked, with a model’s help, for whether it says what the claim relies on. Those verdicts can be wrong — read the claim’s quote and the cited source before relying on one.

A language model drew the claims from the paper on 2026-10-23, under version 3 of the claim definition (model deepseek-v4.1-flash, prompt extract-v3).

A second model labelled each claim on 2026-10-23 (model jev-1.13-20260917, definition revision gold-guideline-v0.2).

Cited sources are checked with a language model’s help (gpt-6-sol).

Statistics and arithmetic are recomputed, not judged.

Confidence bands are shown only for fields calibrated on our annotated test set. None is calibrated yet, so no band is shown.

What counts as a claim ›How we measure confidence ›How we check this ›

Are you an author, or do you see a problem with this page? Request a review