GMSA: Enhancing Context Compression via Group Merging and Layer Semantic Alignment

Jiwei Tang, Zhicheng Zhang, Shunlong Wu, Jingheng Ye, Lichen Bai, Zitai Wang, Tingwei Lu, Lin Hai, Yiming Zhao, Hai-Tao Zheng, Hong-Gee Kim

TL;DR

GMSA (Group Merging and Layer Semantic Alignment) is a novel context compression framework that transforms long text into a compact sequence of "soft tokens." By using uniform group merging to prevent information loss and a specialized alignment layer to bridge the gap between abstract summaries and model inputs, it achieves superior accuracy in long-context tasks while delivering up to an 8x speedup in end-to-end inference.

What Problem Does This Paper Address?

As Large Language Models (LLMs) take on increasingly massive contexts—from entire books to sprawling codebases—they hit two major walls: computational cost and information redundancy. The quadratic complexity of standard attention mechanisms makes processing long prompts prohibitively slow and expensive.

Existing solutions generally fall into two camps:

  1. Hard Prompt Compression: Deleting "unimportant" words or sentences. This often breaks the semantic flow and loses nuanced information.
  2. Soft Prompt Compression: Using an encoder to "summarize" the text into a few learned vectors (soft tokens).

However, the authors identify two critical flaws in current soft compression methods. First, LLMs tend to exhibit semantic dominance, where a few "anchor" tokens (like the word "The" or punctuation) hog all the attention, causing the rest of the context to be "diluted" or lost during compression. Second, there is a massive semantic gap when high-level abstract vectors from an encoder are plugged directly into the low-level input space of a decoder.

Methods

GMSA introduces an encoder-decoder architecture with two clever architectural tweaks to solve the issues mentioned above:

  • Group Merging: Instead of relying on a few learnable "summary tokens" to attend to the whole text, GMSA partitions the encoder's hidden states into equal-sized groups based on the desired compression ratio. It then applies average pooling to each group. This forces a uniform aggregation of information, ensuring that no part of the input text is ignored in favor of "anchor" tokens.
  • Layer Semantic Alignment (LSA): To bridge the semantic gap, the authors insert a small stack of Transformer blocks (often just a single layer) between the encoder and decoder. Crucially, this LSA module is initialized with the weights of the decoder’s own lower layers. This "re-projects" the high-level summary vectors back into a representation space that the decoder naturally understands as input.

The framework uses a two-stage training process:

  1. Autoencoder Pretraining: The model is first trained to reconstruct the original text from the compressed soft tokens, ensuring maximum information retention.
  2. Task-Specific Fine-Tuning: The model is then tuned on downstream tasks (like Question Answering) to learn how to extract specific answers from those compressed representations.

Datasets

The authors evaluated GMSA across a diverse set of benchmarks:

  • Context Reconstruction: The PwC (Papers with Code) dataset was used to measure how well the model could "decompress" soft tokens back into the original text.
  • Downstream QA: NaturalQuestions, 2WikiMQA, HotpotQA, and NarrativeQA were used to test long-context reasoning and retrieval.
  • Summarization: MultiNews was used to evaluate the model's ability to synthesize information from multiple documents.
  • Backbone Models: Experiments were conducted using LLaMA-3.2-3B and Qwen3-4B to demonstrate the framework's versatility.

Key Insights and Ideas

  • Uniformity is a Feature, Not a Bug: While attention mechanisms are usually praised for being selective, GMSA shows that for compression, selective attention can be a liability. By forcing uniform group merging, the model is prevented from "cheating" by only looking at easy-to-process anchor tokens.
  • The "Language" of Layers: The paper highlights that an LLM's internal representations change drastically from the first layer to the last. Treating the output of a deep encoder as a direct substitute for a raw input token is a category error. The LSA module acts as a "translator" that maps abstract concepts back into the "vocabulary" of the decoder's entry point.
  • Efficiency Gains: Because the soft tokens are much shorter than the original text (e.g., 8x shorter), the KV cache—a major memory bottleneck in LLMs—is significantly reduced, leading to much faster generation.

Key Results

  • Superior Reconstruction: In the PwC reconstruction task, GMSA-AE outperformed the previous state-of-the-art (ICAE) by 20–30% in BLEU scores at a sequence length of 512.
  • Winning at QA: On the NaturalQuestions benchmark (4x compression), GMSA achieved an Exact Match (EM) score of 60.38, vastly outperforming hard compression methods like LongLLMLingua (40.11) and other soft methods like ICAE (18.64).
  • Speed and Latency: GMSA consistently showed the lowest end-to-end latency. At an 8x compression rate on NaturalQuestions, it was roughly 5x faster than processing the original uncompressed prompt.
  • Robustness: Unlike many "query-aware" compressors that need to know the question before they can compress the text, GMSA is query-independent, meaning the context can be compressed once and reused for many different questions without losing accuracy.

Limitations and Future Work

  • Training Overhead: Unlike "hard" compression methods that work out-of-the-box, GMSA requires a two-stage training pipeline (pretraining + fine-tuning). This incurs an upfront computational cost, though the authors argue this is offset by inference-time savings.
  • Fixed Ratios: The current implementation uses fixed compression ratios (e.g., 4x or 8x). Future research could explore dynamic compression, where the model decides how much to compress based on the complexity of the input text.
  • Scaling: While tested on 3B and 4B models, seeing how these architectural choices scale to 70B+ parameter models remains an open question.

Summary updated

BibTeX
@inproceedings{tang2026gmsa,
  author = {Jiwei Tang and Zhicheng Zhang and Shunlong Wu and Jingheng Ye and Lichen Bai and Zitai Wang and Tingwei Lu and Lin Hai and Yiming Zhao and Hai-Tao Zheng and Hong-Gee Kim},
  title = {{GMSA: Enhancing Context Compression via Group Merging and Layer Semantic Alignment}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2026},
  doi = {10.18653/v1/2026.acl-long.1324},
}
Figure