Compressive Transformers for Long-Range Sequence Modelling

Jack W. Rae, Anna Potapenko, Siddhant M. Jayakumar, Chloe Hillier, Timothy P. Lillicrap

Introduction

The Compressive Transformer is a novel architecture that extends the "memory" of standard Transformer models. Instead of discarding old activations as they fall out of a recent context window, the model compresses them into a secondary, long-term storage. This approach allows the model to capture dependencies over much longer sequences, achieving state-of-the-art results in language modelling and demonstrating strong performance in speech processing and reinforcement learning.

The "Memory Wall" Problem

Standard Transformers face a computational "memory wall." To process a sequence, they attend to every previous time-step, leading to computational and storage costs that grow quadratically with sequence length.

The previous state-of-the-art, Transformer-XL, mitigated this by using a sliding window of "granular" memory. However, once a memory falls out of that window, it is discarded forever. This hard cutoff limits the model's ability to remember information from thousands of words ago—a feat humans perform easily by building compressed mental representations of a narrative. The Compressive Transformer bridges this gap by creating a model that "summarizes" its past rather than forgetting it.

Methodology: The Compressive Architecture

The Compressive Transformer introduces a two-tier memory system to manage long-range context:

  1. Granular Memory: A fixed-size FIFO (First-In-First-Out) buffer of recent hidden activations, identical to the mechanism in Transformer-XL.
  2. Compressed Memory: When activations are evicted from the granular memory, they are not deleted. Instead, a compression function ($f_c$) maps them to a smaller number of "compressed" slots in a secondary buffer.
The Compressive Transformer architecture, showing the flow from Sequence to Memory, and finally to Compressed Memory via compression functions.

Key Innovations

  • Compression Functions: The authors tested several methods for $f_c$, including max/mean pooling, 1D convolutions, and "most-used" (keeping only the most-attended-to activations). They found that 1D convolutions generally performed best.
  • Attention-Reconstruction Loss: To train the compression network, the authors introduced a specialized loss. Instead of auto-encoding the original pixels or words, the model is trained to ensure that attention information is preserved. It optimizes the compressed block to yield the same attention results as the original uncompressed block.
  • Multi-tier Attention: The model uses the standard attention mechanism to query both its short-term granular memory and its long-term compressed memory simultaneously.

Experimental Setup & The PG-19 Benchmark

The model was evaluated across three domains: language modelling (WikiText-103 and Enwik8), speech (24kHz raw audio), and reinforcement learning (a vision-based object matching task in DeepMind Lab).

Notably, the authors introduced PG-19, a new open-vocabulary benchmark derived from over 28,000 books in the Project Gutenberg archive. Averaging 69,000 words per text, PG-19 is over double the size of previous benchmarks and is specifically designed to stress-test long-range reasoning.

Results and Key Insights

The "Attention Bump"

One of the most striking findings is that the model often attends more to the compressed memory than it does to the oldest parts of its granular memory.

Average attention weight across different memory tiers, illustrating the "attention bump" where the model attends heavily to compressed memory.

This "attention bump" suggests the compression function successfully distills salient information that remains highly relevant even as the specific "raw" activations fade from recent memory.

Rare Word Mastery and SOTA Performance

  • Rare Words: The Compressive Transformer shows a massive improvement (up to 20%) in predicting infrequent words compared to Transformer-XL. Rare words require much broader context to predict correctly, which the compressed memory preserves.
  • Language Modelling: The model achieved a new state-of-the-art perplexity of 17.1 on WikiText-103 (a 1.2 point improvement) and 0.97 bits-per-character (bpc) on Enwik8, becoming the first standard Transformer setup to break the 1.0 bpc barrier on that benchmark.
  • PG-19: It established a strong baseline perplexity of 33.6, significantly outperforming Transformer-XL (36.3).
  • Speech & RL: The model outperformed WaveNet on raw audio modelling and reached human-level performance on the RL memory task, where models with shorter memories failed completely.

Limitations and Future Work

While powerful, the Compressive Transformer adds unnecessary complexity if a task does not actually require long-range reasoning. Currently, the compression rate is a fixed hyperparameter. Future work could explore adaptive compression, allowing the model to dynamically decide which layers or time-steps need more or less compression based on input complexity. Additionally, while convolutions worked well, utilizing small Recurrent Neural Networks (RNNs) as the compression function remains a promising direction to further condense sequential information.

Summary updated

BibTeX
@inproceedings{rae2020compressive,
  author = {Jack W. Rae and Anna Potapenko and Siddhant M. Jayakumar and Chloe Hillier and Timothy P. Lillicrap},
  title = {{Compressive Transformers for Long-Range Sequence Modelling}},
  booktitle = {International Conference on Learning Representations},
  year = {2020},
}
Figure