TL;DR
This paper introduces a lightweight way to add "memory" to existing pretrained Transformers like GPT-2 by attaching a small recurrence module. This allows models to process much longer sequences more efficiently, breaking the fixed context-size limit and achieving better performance (lower perplexity) for the same computational budget.
What Problem Does This Paper Address?
Standard Transformer models, while powerful, suffer from two major bottlenecks:
- Quadratic Complexity: The memory and time required to process a sequence grow quadratically with its length. This makes long-context processing prohibitively expensive.
- Fixed Context Windows: Models like GPT-2 or BERT are trained with a hard limit on sequence length (e.g., 1024 tokens). Once you hit that limit, the model "forgets" everything that came before unless you use computationally wasteful tricks like "overlapping windows."
While newer architectures like Transformer-XL solve some of these issues, they require training from scratch—a feat beyond the resources of most researchers. The authors sought a way to "upgrade" the massive library of existing, domain-specific pretrained models to handle long contexts efficiently.
Methods
The authors propose adding a small recurrence module to a pretrained Transformer during the fine-tuning stage.
Here is how it works:
- Windowed Processing: Instead of processing one massive block of text, the input is split into smaller windows (e.g., 300 tokens).
- Summary Embedding: After a window is processed, its hidden states across all layers are mean-pooled and passed through a small Multi-Layer Perceptron (MLP) to create a single "summary" embedding, $h_{prev}$.
- Recurrent Injection: For the next window, this $h_{prev}$ is injected into one of the Transformer's self-attention layers as an additional key and value. This allows the model to attend to a summary of the previous window without increasing the sequence length significantly.
To keep memory usage low during training, they use gradient checkpointing. By only storing the small recurrent bottlenecks ($h_{prev}$) in memory, they can train on very long sequences even on consumer-grade GPUs.
Datasets
The researchers evaluated their method using the GPT-2 small model on two primary corpora:
- WikiText-103: A standard benchmark consisting of English Wikipedia articles.
- PG-19: A newer, more challenging dataset derived from Project Gutenberg books. PG-19 is particularly useful here because books have much longer-range dependencies than Wikipedia articles, making the benefits of recurrence more apparent.
Key Insights and Ideas
- The Efficiency-Perplexity Trade-off: The authors highlight that standard Transformer evaluation is often "dishonest" about efficiency. To get the best results, researchers often use "maximum overlap" (sliding the window by just one token), which is incredibly slow. The recurrent approach allows for "disjoint execution" (no overlap) while maintaining high accuracy.
- Pareto Frontier Improvement: The recurrent model consistently sits on a better Pareto frontier than the baseline. This means that for any given amount of compute (FLOPs), the recurrent model achieves better perplexity.
- Information Persistence: Qualitative analysis showed that the recurrence module successfully passes high-level topical information (e.g., "this text is about rivers") and character pronouns across windows, even when the specific names might be lost in the bottleneck.
Key Results
- Better Performance at Lower Cost: On the PG-19 dataset, the recurrent model with zero overlap achieved better perplexity than a standard GPT-2 model using a 30-token overlap.
- Robustness to Small Windows: As the window size decreases, the performance of standard Transformers drops sharply. The recurrent model's performance degrades much more gracefully because it still has access to the past via the recurrence module.
- Computational Savings: Adding the recurrence module and using a 50-token overlap was found to be less than half as computationally expensive as using a non-recurrent model with a 200-token overlap, while achieving similar or better results.
Limitations and Future Work
- Bottleneck Capacity: The current recurrence module uses a fixed-size representation. The authors noted that it sometimes struggles to pass fine-grained details, like specific new character names, through the bottleneck.
- Single Layer Injection: In this study, the summary was only injected into one layer. Future work could explore injecting information into multiple layers or using more complex recurrence mechanisms.
- Beyond Language Modeling: While this paper focused on GPT-2, the authors suggest this method could be highly effective for BERT-family models on tasks involving very long documents, such as the RACE reading comprehension dataset.
Summary updated