Transformers need glasses! Information over-squashing in language tasks

Federico Barbero, Andrea Banino, Steven Kapturowski, Dharshan Kumaran, João Guilherme Madeira Araújo, Alex Vitvitskyi, Razvan Pascanu, Petar Veličković

Introduction

Large Language Models (LLMs) have demonstrated remarkable reasoning capabilities, yet they often stumble on trivial tasks like counting words or accurately copying long strings. This research identifies two fundamental architectural flaws in decoder-only Transformers—representational collapse and over-squashing—that create a "blindness" to details in long contexts. The study demonstrates that as input sequences grow, the final token’s representation becomes unable to distinguish between different inputs, a problem exacerbated by the low-precision floating-point math (e.g., bf16) used in modern AI.

The Architectural Bottleneck

In a decoder-only Transformer, the prediction of the next token depends entirely on the representation of the last token in the final layer. This creates a massive information bottleneck: the entire preceding sequence must be "squashed" into a single vector. This topological constraint forces information to flow through a computation graph that naturally attenuates signals from earlier tokens.

Theoretical Insights: Collapse and Squashing

The researchers combine mathematical proofs with empirical analysis to define two primary failure modes:

  1. Representational Collapse: For certain distinct sequences (e.g., 500 vs. 501 "1"s), the representations of the last token converge as sequence length increases. In finite precision environments like bf16, these vectors eventually become identical, making the model unable to perceive the difference between the inputs.
  2. Over-squashing: Borrowing from Graph Neural Network (GNN) theory, the authors analyze the "sensitivity" of the output to any given input token. The unidirectional causal mask forces a "sink" at the final token, where information from distant tokens is lost or diluted.
Conceptual overview of Representational Collapse and Over-squashing.

Empirical Evaluation

The study utilized synthetic benchmarks to isolate these failure modes across frontier models, including Gemini 1.5 and Gemma 7B.

Copying and Counting Tasks

  • Copying: Models were prompted to recall the first or last token of long sequences of repeated characters (e.g., "111...10").
  • Counting: Tasks included summing strings of "1"s, counting "1"s in random binary sequences, or counting specific word occurrences in sentences.

Key Results

The experiments revealed significant performance degradation as sequence length increased:

  • Gemini 1.5 Failures: Even state-of-the-art models began failing to copy the last digit of a sequence after only 300 tokens when the sequence consisted of repeated characters.
  • The "100" Heuristic: In long counting tasks, Gemini 1.5 showed a bias toward the number 100, suggesting the model stops mechanical counting and starts "subitizing"—guessing a common large number when the signal becomes too blurry.
  • Precision Impact: In Gemma 7B, representational collapse occurred significantly faster than idealized theory suggests, sometimes within just 50 tokens, due to machine precision limitations.
Performance on copying tasks across varying sequence lengths.

Mitigation and Future Directions

The research suggests that simple "anchoring" techniques can help. Adding delimiters (like commas) or explicit "hints" in the prompt significantly delayed the onset of collapse by helping the attention mechanism preserve signal.

Future architectural improvements, such as local sliding window attention (recently implemented in Gemma 2), may naturally mitigate these issues by preventing the softmax mechanism from spreading too thin over massive contexts. Understanding and measuring over-squashing in real-time during inference remains a critical area for future work.

Summary updated

BibTeX
@inproceedings{barbero2024transformers,
  author = {Federico Barbero and Andrea Banino and Steven Kapturowski and Dharshan Kumaran and João Guilherme Madeira Araújo and Alex Vitvitskyi and Razvan Pascanu and Petar Veličković},
  title = {{Transformers need glasses! Information over-squashing in language tasks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=93HCE8vTye},
}
Figure