Skip to main content
Back

Northeastern's SAC Compresses LLM Contexts 15x Faster Without Autoencoding

Semantic-Anchor Compression skips the autoencoding pretraining step entirely and reuses actual context tokens as compression carriers, beating strong baselines across compression ratios.

Pro

  • SAC compresses LLM context by reusing original tokens as anchors, skipping the standard autoencoding pretraining stage.
  • Two designs make it work: a learnable anchor embedding and bidirectional attention in the encoder only.
  • Beats EPL, 500xCompressor, and ICAE across 5x, 15x, and 51x compression ratios on MRQA question answering.
  • Training is roughly 26 to 31 percent faster than prior methods, with lower language modeling perplexity.
  • Autoencoding and language modeling gradients are near-orthogonal, explaining why removing AE improves downstream performance.
  • Code, data, and models are open source at github.com/lx-Meteors/SAC.

A team from Northeastern University and NiuTrans has proposed a context compression method for large language models that throws out the standard autoencoding pretraining recipe and instead reuses tokens from the original prompt as compression carriers. The technique, called Semantic-Anchor Compression (SAC), consistently beats existing soft-compression methods on question answering and long-context summarization, and it trains faster too.

Context compression accelerates LLM inference by converting long inputs into compact representations, which cuts both latency and GPU memory. The dominant approach appends dedicated compression tokens to the end of a context and trains them, through an autoencoding task, to reconstruct the original text. Once trained, the LLM can answer questions or summarize based only on the compressed representation instead of the full prompt.

The autoencoding tax

The authors argue the standard recipe has a hidden cost. Compression tokens are randomly initialized and lack inherent semantic information, so they need an expensive pretraining phase where the model learns to reconstruct entire contexts. That objective is not the same as what downstream users actually want.

The AE objective requires the compressed representations to reconstruct the complete context, forcing the model to encode a large number of tokens within its limited capacity; some tokens might require significant model memories while not useful for downstream tasks, thereby weakening the model's ability to retain task-critical information. The team measured the gradient cosine similarity between autoencoding loss and language modeling loss during training and found that while the two gradients largely align at the very beginning, the cosine similarity quickly approaches zero, suggesting that the two tasks are largely orthogonal in parameter space. Optimizing one interferes with the other.

Anchors instead of new tokens

SAC sidesteps the problem by never introducing fresh compression tokens in the first place. It picks a subset of tokens directly from the input and turns them into carriers for the surrounding context. Following EPL, the default strategy divides the entire context into chunks and selects the middle token from each chunk, which maximizes coverage.

Architecture comparison of SAC versus previous compression methods

Two design choices make this work:

  • Anchor embedding. A learnable vector is added to the embedding of each selected token so the model can tell anchors from regular tokens. Without this signal the model has no way to know which tokens carry the compressed payload.
  • Bidirectional attention in the encoder. Because the encoder uses causal attention, the anchor tokens do not have visibility to the full sentence, limiting their representation power. SAC replaces causal attention with bidirectional attention in the encoder only, so anchors can pull information from tokens on both sides. The decoder still runs causal attention as usual.

The compressed representation itself is the key-value pairs of the anchor tokens across all transformer layers, following the same idea as 500xCompressor. The encoder is a copy of the target LLM with LoRA adapters (rank=128), and only the LoRA weights and the anchor embedding are trained. Crucially, SAC drops the autoencoding loss entirely and trains only with language modeling during pretraining plus QA supervision during fine-tuning.

Numbers on MRQA

Experiments use Llama-3.2-1B as both encoder and decoder, with continued pretraining on SlimPajama-6B and fine-tuning on the MRQA reading-comprehension benchmark. Baselines include ICAE, 500xCompressor, Activation Beacon, DAST, and EPL (the previous state of the art). At a 15x compression ratio on in-domain MRQA tasks:

MethodAvg F1Avg EM
Full fine-tune (no compression)71.5156.85
ICAE44.5031.28
500xCompressor49.3534.98
EPL51.5236.65
SAC54.9539.67

The gap widens on out-of-domain data and holds at extreme compression ratios. At the highest compression ratio of 51x, SAC consistently achieves the best average performance across all compression ratios, demonstrating strong robustness and stability. On long-context summarization with 32K-token inputs, SAC beats EPL on both QMSum and GovReport. Scaling up to Llama-3.2-3B and Llama-3.1-8B, SAC outperforms EPL across all model sizes and evaluation settings, consistently achieving higher F1 and EM scores, and the gain does not shrink with model size.

Faster training, cheaper inference

Removing autoencoding also pays a compute dividend. Since SAC avoids the additional computational overhead from independent compression tokens and the AE task, its training is approximately 31% faster than ICAE and 26% faster than 500xCompressor and EPL. It also achieves the lowest language modeling perplexity of the four (10.79 vs 10.88 for EPL).

At inference, SAC does not append extra compression tokens to the sequence, so the encoder processes a shorter input. In an empirical test with batch size 10 over 1000 sequences, SAC took 243.87 ms per batch versus 257.43 ms for 500xCompressor. The bidirectional attention overhead is more than offset by the shorter sequence.

What it is good for, and what it is not

SAC targets scenarios where you feed the same long context to an LLM repeatedly, or where prompt length is the bottleneck: retrieval-augmented generation with large passages, long-document QA, multi-turn dialogue with long histories, and long-context summarization. The compressed KV cache can be stored and reused, avoiding the quadratic cost of re-attending to the full text.

The method has real limits. Performance degrades sharply as the compression ratio climbs from 5x to 51x, and even at 15x it trails the uncompressed baseline by a noticeable margin (54.95 F1 vs 71.51 F1 in-domain). It also depends on a good token selection strategy: random selection significantly degrades performance because the selected tokens lack semantic importance, and their random positions result in poor global coverage of the context. And the encoder must share the same base LLM as the decoder to avoid semantic gaps.

Availability

Code, data, and trained models are released on GitHub. The repository includes setup instructions, training scripts, and evaluation harnesses to reproduce the MRQA and long-context summarization results.