Equipping Transformer with Random-Access Reading for Long-Context Understanding

Chenghao Yang, Zi Yang, Nan HuaarXiv 2024 · DOI

Introduction

As Large Language Models (LLMs) scale to handle context windows of hundreds of thousands of tokens, the traditional "sequential access" paradigm becomes a significant bottleneck. Standard Transformers incur a quadratic computational cost relative to sequence length, and processing every token linearly is both expensive and often redundant. While humans naturally skim or skip irrelevant sections when seeking specific information, LLMs typically treat all tokens with equal importance. This paper introduces a "random-access" reading strategy, enabling models to dynamically skip uninformative text based on local confidence, thereby improving efficiency and performance in long-context tasks.

The Random-Access Framework

The proposed framework shifts away from rigid sequential processing toward a dynamic, request-based system.

Comparison between traditional sequential access and the proposed random-access reading mechanism.

The architecture consists of three core components:

  1. The Skipping Mechanism: The model calculates cross-entropy loss (perplexity) for a read chunk. If the loss is low, the model is confident and triggers a larger skip over subsequent tokens. High loss indicates informative content, prompting more careful reading.
  2. The Data Server: A dedicated server manages non-sequential I/O, fetching specific text chunks requested by the model's skipping logic.
  3. Memory Module: To maintain coherence across large skips, an Attendre-based memory module uses a FIFO cache and Top-K retrieval to store and recall key information from previously processed sections.

Experimental Evaluation

The authors evaluated the framework using two primary datasets:

  • C4 (4k+): A subset of the Colossal Clean Crawled Corpus featuring documents longer than 4,000 tokens for pretraining.
  • TriviaQA (Long-Context): A version where evidence is concatenated into ~23,000-token documents to test "needle-in-a-haystack" retrieval.

Results and Analysis

A key finding is the "Short-Text Degradation" trap: models pretrained on short snippets often perform worse on long-context tasks than randomly initialized models. However, the random-access fine-tuning approach effectively mitigates this.

Finetuning performance across different initialization and training strategies, highlighting the effectiveness of long-context fine-tuning with skipping (K=256).

Key insights include:

  • Efficiency: The skipping mechanism combined with memory achieved a perplexity of 14.15 in 130k steps, a 3.84x efficiency gain over state-of-the-art memory-only models.
  • Learning to Skim: Models naturally increase their skip rate as training progresses, developing an intuition for redundancy.
  • Task-Specific Optimization: While moderate skipping suits general language modeling, aggressive skipping (jumping 10,000+ tokens) proved optimal for goal-oriented tasks like Question Answering.

Conclusion

Random-access reading offers a promising path toward efficient long-context understanding. By using perplexity as a "boredom meter," LLMs can focus computational resources on relevant information. Future work may address current limitations, such as the inability to skip backward or the dependency on specialized data server hardware for non-sequential I/O.

Summary updated

BibTeX
@misc{yang2024equipping,
  author = {Chenghao Yang and Zi Yang and Nan Hua},
  title = {{Equipping Transformer with Random-Access Reading for Long-Context Understanding}},
  year = {2024},
  eprint = {2405.13216},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.13216},
}
Figure