Simple Context Compression: Mean-Pooling and Multi-Ratio Training

Yair Feldman, Yoav Artzi · OpenReview

Abstract

A common strategy to reduce the computational costs of using long contexts in retrieval-augmented generation (RAG) with large language models (LLMs) is soft context compression, where the input sequence is transformed into a shorter continuous representation. We develop a lightweight and simple mean-pooling approach that consistently outperforms the widely used compression-tokens architecture, and study training the same compressor to output multiple compression ratios. We conduct extensive experiments across in-domain and out-of-domain QA datasets, as well as across model families, scales, and compression ratios. Overall, our simple mean-pooling approach achieves the strongest performance, with a relatively small drop when training for multiple compression ratios. More broadly though, across architectures and training regimes the trade-offs are more nuanced, illustrating the complex landscape of compression methods.

Introduction

In Retrieval-Augmented Generation (RAG), Large Language Models (LLMs) must balance context richness with computational efficiency. As context length grows, the Key-Value (KV) cache becomes a significant memory bottleneck, slowing generation. While "hard" compression (token deletion) is common, "soft" compression—transforming text into a smaller set of continuous vectors—offers a more nuanced path to efficiency. This paper explores a simplified architecture for soft compression, arguing that complex "compression token" methods can be replaced by a more effective mean-pooling strategy.

Methods: From Compression Tokens to Mean-Pooling

Traditional soft compression often relies on "compression tokens"—special learned tokens that attend to the input sequence to distill its information. The researchers propose a simpler alternative: Mean-Pooling.

Comparison of context compression architectures: Original uncompressed (left), Compression Tokens (middle), and the proposed Mean-Pooling (right).

In the mean-pooling architecture, a standard LLM acts as an encoder. The final hidden states of the original tokens are processed using non-overlapping mean-pooling. For example, a 4x compression ratio averages every four adjacent vectors into one. A critical component of this method is the use of a full self-attention mask during encoding, allowing every token to contextualize itself against the entire document before pooling occurs.

Additionally, the authors introduce Multi-Ratio Training. Instead of training separate models for different compression levels, they use Knowledge Distillation to train a single compressor to support a range of ratios (from 4x to 128x) simultaneously. This allows for dynamic adjustment of compression based on available compute resources.

Datasets and Evaluation

The approach was tested on a diverse suite of datasets:

  • Training: A mixture of SQuAD, NarrativeQA, HotpotQA, and various summarization datasets (CNN/DM, XSum, etc.).
  • Evaluation: Both in-domain (SQuAD, NarrativeQA) and out-of-domain (AdversarialQA, TriviaQA) benchmarks were used to test generalization.
  • Models: Experiments spanned several model families, including Qwen3 (0.6B to 8B), Llama 3.2 (1B), and Gemma 2 (2B).

Key Results and Insights

The primary finding is that mean-pooling consistently outperforms more complex architectures. The performance gap is particularly evident when comparing relative F1 scores (performance relative to an uncompressed teacher model).

Performance comparison at 4x compression, showing Mean-Pooling achieving significantly higher relative F1 scores compared to Causal and Bidirectional compression token methods.

Key insights from the experimental results include:

  • Attention Patterns Matter: The researchers found that the standard "compression tokens" method was largely limited by causal (left-to-right) masking. When bidirectional attention was enabled, the performance of token-based methods improved, but mean-pooling still maintained the lead.
  • Scaling Benefits: Larger models are more effective compressors. Moving from a 0.6B to an 8B model showed a marked increase in relative F1, suggesting that soft compression becomes increasingly viable as LLMs scale.
  • Robustness of Multi-Ratio Training: Training on multiple ratios simultaneously creates a more robust compressor with only a minor performance penalty compared to ratio-specific models, offering significant practical advantages for deployment.

Conclusion and Future Work

This work demonstrates that a simple mean-pooling approach, when combined with bidirectional attention and multi-ratio training, provides a highly effective and flexible solution for context compression. While the study was limited to contexts of 1,024 tokens, it sets a new baseline for efficiency in RAG pipelines. Future research may explore semantic-aware pooling or the performance of these methods on extremely long contexts (100k+ tokens) and in the presence of retrieval noise.

Summary updated

BibTeX
@misc{feldman2025simple,
  author = {Yair Feldman and Yoav Artzi},
  title = {{Simple Context Compression: Mean-Pooling and Multi-Ratio Training}},
  year = {2025},
  eprint = {2510.20797},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.20797},
}
Figure