NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Context Compression for Auto-regressive Transformers with Sentinel Tokens

Siyu Ren, Qi Jia, Kenny Q. Zhu

Introduction

As Large Language Models (LLMs) scale to handle increasingly complex tasks, they encounter a significant "memory tax" inherent to the Transformer architecture. Modern models like GPT-4 and Llama suffer from two primary bottlenecks: quadratic computational complexity and the linear growth of the Key-Value (KV) cache. This cache stores a snapshot of every previous token to facilitate the generation of the next, but for long-context documents, the cache size can exceed GPU memory limits, leading to slower inference and restricted context windows.

To address this, researchers have developed a "plug-and-play" method that compresses long spans of text into single "sentinel tokens." By training models to summarize their own internal states, this approach achieves significant memory reduction and up to a 1.5x boost in generation speed without sacrificing the coherence of long-form text.

Methodology: The Sentinel Token Approach

The core of the proposed technique is a KV Compression mechanism utilizing two specialized sentinel tokens: <CL> (Compression Left) and <CR> (Compression Right). This "bookend" approach allows the model to identify and distill specific segments of text within the context window.

The Bookend Mechanism

To compress a specific span of text, the model places the <CL> token at the start and the <CR> token at the end of the target span. During the processing phase, the model's attention masking is modified to force the architecture to ignore the original tokens located between these bookends. Instead, the model is directed to attend only to the final <CR> token, which serves as a summary of the hidden span.

Learning to Summarize via LoRA

The model learns to "distill" relevant information into the <CR> token through fine-tuning. Using Low-Rank Adaptation (LoRA) on a standard next-token prediction task, the model is incentivized to preserve the semantic essence of the compressed span. Once the information is successfully distilled into the KV cache of the <CR> token, the memory occupied by the original tokens in that span can be evicted from the GPU, effectively freeing up space for subsequent text generation.

Experimental Setup

The researchers evaluated the efficacy of sentinel token compression across several model architectures, including OPT-1.3B, OPT-2.7B, and RedPajama-3B. Performance was measured using three primary benchmarks:

  • WikiText-2: To evaluate general language modeling and perplexity.
  • C4 (Colossal Clean Crawled Corpus): To assess zero-shot open-ended document generation.
  • WritingPrompts: To test the model's ability to maintain long-term coherence in creative storytelling.

Key Insights and Results

Active vs. Passive Compression

Unlike "Local Attention" strategies, which simply discard older tokens (passive forgetting), this method employs active compression. The model learns to identify and retain the most salient information from the history. This distinction is critical for maintaining performance at high compression ratios. At a 70% compression ratio, the KV Compression method maintained significantly lower perplexity than local attention baselines.

Performance and Throughput

The implementation demonstrated substantial efficiency gains. On a 12GB GPU, the system achieved a 1.5x improvement in throughput (tokens generated per second) at extreme compression ratios. Furthermore, the method proved to be position-independent, functioning effectively with both absolute position embeddings and modern Rotary Position Embeddings (RoPE).

The Impact of Training Ratios

A notable finding was that training the model with higher compression ratios—forcing it to summarize larger chunks of text—actually improved generalization. Models trained to handle aggressive compression became more adept at preserving semantic meaning even when performing lighter compression during inference. This was reflected in higher BERTScore and ROUGE scores during zero-shot generation tasks, indicating that the generated text remained more topical compared to models that lacked active compression.

Limitations and Future Directions

While promising, the current approach has several areas for refinement:

  1. Heuristic Span Selection: Currently, spans for compression are chosen based on fixed lengths or random selection. Moving toward "grammatically aware" selection—such as compressing complete sentences or noun phrases—could further improve performance.
  2. Fine-tuning Requirements: Although the method is architecturally "plug-and-play," it requires a lightweight LoRA fine-tuning step to teach the model how to utilize the sentinel tokens effectively.
  3. Fixed Summary Capacity: A single <CR> token has a finite information capacity. For extremely dense or complex spans, a single token may be insufficient, suggesting a need for future research into variable-length summary tokens.

Conclusion

Context compression via sentinel tokens offers a viable path toward scaling LLM context windows without the prohibitive memory costs of a full KV cache. By transforming the model from a passive storer of data into an active summarizer of its own history, this method enhances both the speed and the functional memory of modern auto-regressive Transformers.

Summary updated

BibTeX
@inproceedings{ren2023context,
  author = {Siyu Ren and Qi Jia and Kenny Q. Zhu},
  title = {{Context Compression for Auto-regressive Transformers with Sentinel Tokens}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.emnlp-main.794},
}
Figure