Autoencoding-Free Context Compression for LLMs via Contextual Semantic Anchors

Xin Liu, Runsong Zhao, Pengcheng Huang, Junyi Xiao, Chunyang Xiao, Tong Xiao, Shengxiang Gao, Zhengtao Yu, JingBo Zhu

TL;DR

Semantic-Anchor Compression (SAC) is a novel approach to context compression that eliminates the computationally expensive autoencoding pretraining phase. By selecting existing tokens from the input text as "anchors" and enabling them to aggregate information via bidirectional attention, SAC achieves superior performance on downstream tasks like question-answering and summarization while significantly accelerating training.

The Problem with Current Compression Methods

Large Language Models (LLMs) are increasingly deployed for long-document processing and retrieval-augmented generation (RAG). However, processing massive contexts incurs high computational costs, increases latency, and exacerbates the "lost-in-the-middle" phenomenon.

To mitigate this, researchers employ context compression, which condenses long inputs into a smaller set of "summary" tokens. Most current "soft compression" methods rely on autoencoding (AE): they train special, randomly initialized tokens to reconstruct the original text. The authors argue this approach is fundamentally flawed for two main reasons:

  1. Task Misalignment: The primary goal of compression for an LLM is not to perfectly reconstruct every word (the AE objective), but to preserve the critical information required for a specific downstream task, such as answering a question.
  2. Optimization Conflict: The gradients for the AE task and the standard Language Modeling (LM) task are often orthogonal. This means the two objectives effectively "fight" each other during training, preventing the model from learning features most beneficial for real-world usage.

The Semantic-Anchor Compression (SAC) Method

SAC shifts away from "learning to compress" from scratch using special tokens. Instead, it introduces an architecture inherently equipped with compression capabilities a priori.

Overview comparing previous methods that append special tokens with SAC, which utilizes existing context tokens as anchors.
  • Semantic Anchors: Rather than appending new, randomly initialized special tokens, SAC selects existing tokens directly from the context (e.g., the middle token of every $N$ tokens) to serve as "anchors." Because these are real words, they already possess a "semantic prior" that grounds the model's representations.
  • Anchor Embeddings: To help the model distinguish these designated carriers from regular text, a learnable "anchor embedding" vector is added to the selected anchor tokens.
Illustration of semantic anchor embeddings being added to selected tokens to mark them as compression carriers.
  • Bidirectional Attention Modification: Standard LLMs utilize causal (left-to-right) attention. SAC modifies this mechanism during the compression phase, allowing anchor tokens to look both forward and backward across the entire context. This enables them to effectively aggregate global information into their Key-Value (KV) representations.
  • Autoencoding-Free Training: SAC completely bypasses the AE reconstruction task. It is pretrained solely on a Language Modeling objective and subsequently fine-tuned on downstream tasks using LoRA.

Datasets and Evaluation

The authors rigorously evaluated SAC across a diverse suite of benchmarks:

  • Pretraining: SlimPajama-6B.
  • In-Domain QA: MRQA (including SQuAD, NewsQA, TriviaQA, SearchQA, HotpotQA, and Natural Questions).
  • Out-of-Domain Generalization: BioASQ, DROP, DuoRC, RACE, RE, and TextbookQA.
  • Long-Context Tasks: QMSum and GovReport (summarization), alongside the LongBench suite for 24K-token QA.

Key Insights and Results

  • The "Orthogonality" of AE and LM: Visualizing the gradient cosine similarity between AE and LM losses reveals it quickly approaches zero. This empirical evidence confirms that forcing a model to learn reconstruction hinders its ability to learn useful predictive features.
  • Natural Semantic Priors: By utilizing real tokens as anchors, the compressed representations remain "closer" to the original feature space. Visualizations demonstrate that SAC’s anchor KVs overlap more naturally with original context KVs compared to previous methods.
  • Superior Performance: SAC consistently outperforms strong baselines like ICAE and EPL. At a 15x compression ratio, SAC improved F1 scores by up to 23.5% over ICAE on in-domain tasks.
  • Enhanced Efficiency: Because SAC reuses existing tokens rather than appending extra special tokens during the compression phase, it reduces the total sequence length processed by the transformer. This leads to lower FLOPs and faster empirical compression times. Furthermore, SAC’s training is approximately 31% faster than ICAE and 26% faster than 500xCompressor due to the elimination of the AE task overhead.
  • Scalability and Robustness: The method demonstrates consistent gains across different model sizes (e.g., Llama-3.2-1B, 3B, and Llama-3.1-8B). On 32K-token summarization tasks, SAC maintained a significant lead over EPL, proving its robustness even as input lengths scale far beyond the training window.

Limitations and Future Work

  • Selection Strategy: SAC currently employs a simple uniform selection strategy (picking the middle token of a chunk). Implementing more sophisticated, "importance-based" token selection could further enhance performance.
  • Fine-tuning Requirement: While SAC avoids AE pretraining, it still necessitates task-specific fine-tuning to achieve peak performance. Developing a more "zero-shot" capable compressor remains an open challenge.
  • Fixed Ratios: The current implementation relies on a fixed compression ratio. Exploring dynamic ratios tailored to content complexity represents a promising direction for future research.

Summary updated

BibTeX
@inproceedings{liu2026autoencoding,
  author = {Xin Liu and Runsong Zhao and Pengcheng Huang and Xinyu Liu and Junyi Xiao and Chunyang Xiao and Tong Xiao and Shengxiang Gao and Zhengtao Yu and JingBo Zhu},
  title = {{Autoencoding-Free Context Compression for LLMs via Contextual Semantic Anchors}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=8Pi6Du0n7F},
}
Figure