What Makes Recurrence Generalize Across Lengths?

Yoonsung Jung, Sunghun Jung, Louise Nayeong Koh, Yongjun ChoiarXiv 2026

Imagine you’re trying to follow a complex recipe. If the recipe has five steps, you can probably keep track of the ingredients in your head. But what if the recipe suddenly scales to fifty steps? A standard Transformer model is like a chef who has a fixed amount of "thinking time" per dish, regardless of how many steps are involved. Once the recipe gets too long, the chef simply runs out of brainpower.

This paper, from researchers at Yonsei University, asks a fundamental question: Can we build models that "think longer" as the problem gets harder? Specifically, they look at Recurrent Transformers—models that reuse the same neural layers over and over—to see if they can generalize to sequences much longer than anything they saw during training.

TL;DR

Recurrence allows Transformers to handle longer problems by reusing the same "mental steps," but it only works if the model isn't "distracted" by where those steps occur in a sequence. By using "atomic" representations and avoiding rigid positional markers, recurrent models can successfully solve problems twice as long as their training data, while standard Transformers fail completely.

What Problem Does This Paper Address?

Standard Transformers have a "fixed depth." If you build a 12-layer model, it performs exactly 12 layers of computation for every input. This is a problem for state tracking—the ability to keep track of how things change over time (like following a shell game or a long chain of logic). If a task requires 20 updates but your model only has 12 layers, it’s mathematically "shallow" relative to the problem.

Recurrent Transformers offer a solution: instead of 12 different layers, use one layer (or a small block) and loop it. If the input is longer, just loop it more times. While this sounds intuitive, it often fails in practice. The authors wanted to find the "secret sauce" that actually makes this recurrent logic generalize to lengths the model has never seen before (extrapolation).

Methods

The researchers used a controlled "state-tracking" task: five colored balls are swapped between five positions. The model sees a starting state and a sequence of swaps (e.g., "Swap position 1 and 3"), then must predict the final positions.

They systematically varied three things:

  1. Architecture: Fixed-depth "Basic" Transformers vs. Recurrent Transformers (where the number of loops $K$ equals the number of swaps $N$).
  2. Input Representation:
    • Template: Natural language-like (e.g., "[Entity_0] swapped with [Entity_3]").
  3. Atomic: A single dedicated token for each operation (e.g., "[SWAP_0_3]").
  4. Positional Encoding (PE): How the model knows the order of operations. They tested NoPE (no encoding), Absolute (standard 1, 2, 3...), and Periodic (reusing patterns, like 1, 2, 1, 2...).

Datasets

The study uses a synthetic benchmark:

  • Training: Sequences of 2–10 swaps.
  • In-Distribution (ID): Held-out sequences of 2–10 swaps.
  • Out-of-Distribution (OOD): Sequences of 11–19, 20–40, and 40–80 swaps.

This setup is designed to see if a model trained on "short" problems can solve "long" ones.

Key Insights and Ideas

  • Recurrence is a "Thinking" Loop: Reusing the same parameters for every step forces the model to learn a general "update rule" rather than a specific "layer 5 does this" rule.
  • Templates are Noisy: Using multi-token templates (like English sentences) makes it harder for the model to see the "atomic" nature of the swap. Atomic tokens act like clean API calls, making the recurrence much more effective.
  • Absolute Position is a Generalization Killer: If a model learns that "the swap at position 5" is special, it won't know what to do when it sees a swap at position 15. NoPE or Periodic PE allows the model to treat a swap the same way regardless of when it happens.
  • Scaling Recurrence vs. Scaling Depth: Simply making a fixed-depth Transformer bigger doesn't help it generalize to longer sequences. However, making the recurrent block larger (more parameters in the loop) dramatically pushes the "extrapolation horizon" further out.

Key Results

The difference between the architectures is stark. As shown in Figure 1, the fixed-depth model's accuracy falls off a cliff as soon as it hits lengths it hasn't seen before.

Figure 1: Length generalization under Atomic + NoPE. Recurrent d128 L1 with K = N is compared with the compute-matched fixed-depth d128 L7 Transformer. Lines show means over three seeds, and shaded regions denote ±1 standard deviation.
  • The 20-40 Swap Challenge: On sequences of 20–40 swaps (at least double the training length), a large Recurrent model (d256 L4) achieved 35.1% exact-match accuracy.
  • The Fixed-Depth Failure: A substantially larger fixed-depth model (d256 L12) stayed at 0% on the same task.
  • The Sweet Spot: The best-performing shallow models used Atomic representations + NoPE. Adding absolute positional encoding to an atomic model dropped its OOD 11–19 accuracy from 90.6% to a measly 18%.

Limitations and Future Work

While the recurrent models are much better, they aren't perfect. Even the best models hit a wall on the 40–80 swap range, approaching 0% accuracy. This suggests that while recurrence helps, there is still a "drift" or accumulation of error that eventually breaks the state tracking.

The authors also note that their success relies heavily on atomic representations. In the real world, we don't always have clean tokens for every operation; we often have messy, multi-token text. Figuring out how to make recurrence work with that "template-style" data remains an open, and very difficult, challenge.

Summary updated

BibTeX
@misc{jung2026what,
  author = {Yoonsung Jung and Sunghun Jung and Louise Nayeong Koh and Yongjun Choi},
  title = {{What Makes Recurrence Generalize Across Lengths?}},
  year = {2026},
  eprint = {2611.29171},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.29171},
}
Figure