Abstract
Standard Large Language Models (LLMs) are often limited by quadratic computational scaling and fixed context windows. We present LCIRC (Long-form Context Injection with Recurrent Compression), a framework that enables LLMs to process contexts up to 815K tokens without full-model retraining. By utilizing recurrent Perceiver-based compression and query-dependent gated cross-attention, LCIRC achieves significant performance improvements on long-context benchmarks while drastically reducing computational overhead.
Introduction
The utility of Large Language Models (LLMs) is frequently constrained by their inability to process extremely long sequences efficiently. Transformer-based models face a "quadratic wall" where attention costs grow $O(n^2)$ with sequence length. Furthermore, fixed position embeddings often lead to performance degradation or information loss beyond the initial training window. While sparse attention and prompt compression offer some relief, they often sacrifice information density or require expensive retraining.
Methods: The LCIRC Architecture
LCIRC introduces a modular approach to long-context processing through two main stages: Recurrent Context Compression and Compressed Context Injection.
Recurrent Context Compression
To handle massive documents, LCIRC segments input sequences and processes them recurrently. A Perceiver-based architecture compresses these segments into a fixed set of compact feature vectors ($h$). By incorporating the summary from previous steps into the current compression cycle, the model maintains a continuous information flow across long distances.
Compressed Context Injection
The compressed features are integrated into a frozen base LLM via Gated Cross-Attention (GCA) blocks. This "sidecar" architecture allows the LLM to "peek" at the compressed history without attending to every original token, preserving the model's native reasoning capabilities while extending its effective memory.
Query-Dependent Modeling (QD-LCIRC)
A significant bottleneck in traditional compression is its query-agnostic nature. LCIRC addresses this with QD-LCIRC, which adds a gated cross-attention layer to the compression step. This allows the compressor to prioritize information relevant to the user's specific query, effectively filtering out irrelevant data in documents exceeding 100K tokens.
Efficient Training via Selective State BPTT
Training on long sequences typically risks memory exhaustion. LCIRC employs Selective State BPTT, a specialized version of Backpropagation Through Time that randomly selects timesteps for gradient computation. This strategy prevents memory explosions while ensuring the model learns to propagate information effectively across the recurrent states.
Experimental Results
LCIRC was evaluated on benchmarks including InfiniteBench (100k+ tokens) and LongBench. Training utilized the FineWeb-Edu dataset and a specialized long-form QA dataset, FineWeb-LQA, generated via Llama-3.1-70B.
Key Findings
- Accuracy Gains: QD-LCIRC demonstrated relative improvements of 308% on InfiniteBench and 90% on LongBench over the base Llama-2 model.
- Computational Efficiency: Compared to full-attention baselines (ExtendedFA), LCIRC reduced TeraFLOPs by over 98% at 128K tokens.
- Perplexity and Scaling: The model maintained stable perplexity as context increased from 4K to 128K tokens and successfully scaled to 815K tokens, far beyond the base model's native limits.
- Benchmarking: LCIRC consistently outperformed other state-of-the-art compression methods like AutoCompressor, particularly on tasks requiring precise query relevance.
Conclusion and Future Work
LCIRC represents a significant step toward infinite context windows for LLMs. By decoupling context memory from the core model through recurrent compression and query-dependent injection, it achieves high performance with minimal computational cost. Future research will explore the framework's generalizability to non-QA tasks and its performance in multilingual contexts.
Summary updated