Prompt Compression via Activation Aggregation

Thibaud Ardoin, Semira Einsele, Evis Bregu, Gerhard WunderarXiv 2026

TL;DR

Can you compress an entire instruction prompt into a single activation vector? This paper demonstrates that it is entirely possible by using a lightweight multilayer perceptron to compute a learned weighted sum of mid-layer activations and injecting it into an early layer of an LLM. This method retains task performance within 2% of the full prompt baseline, bypassing the need to re-evaluate long prompt token sequences during inference.

What Problem Does This Paper Address?

Large Language Models (LLMs) are frequently deployed in applications where a fixed prefix—such as a system prompt, a set of instructions, or few-shot examples—is prepended to varying user queries. In standard inference, these prefix tokens are re-evaluated or pulled from a KV-cache. While KV-caching avoids redundant computation, it still requires memory that scales with prompt length and keeps the full sequence length inside the attention blocks.

The authors tackle a more radical question: Can we compress the semantic influence of an entire prompt into a single prompt-dependent activation vector (a "patch vector")? If so, we could inject this single vector directly into the model's latent space via a placeholder token, completely eliminating the original prompt tokens from the context window during the query pass.

Methods

The authors propose a simple three-step framework: Extraction, Compression, and Injection.

Overview of the proposed three-step framework
  1. Extraction: The instruction prompt is passed through a frozen target LLM, and the sequence of hidden states $H^{(m)}(p)$ is extracted from an intermediate layer $m$ (e.g., layer 12 in Llama-3.1-8B).
  2. Compression: A compression function $f$ maps the sequence of hidden states into a single patch vector $v \in \mathbb{R}^d$. The paper compares two compression architectures:
  3. Weighting MLP (W-MLP): A small feed-forward network that scores each token activation independently to predict a scalar weight $w_i$. The final patch vector is a simple linear combination: $v = \sum w_i h_i$.
  4. Transformer Compressor (TC): A heavier, end-to-end trained transformer encoder that processes the full sequence and uses a [CLS] token to output $v$.
  5. Injection: In a subsequent forward pass containing only the user query, the hidden state of a neutral placeholder token (the UTF-8 replacement character ¿) is overwritten by the patch vector $v$ at an early layer $e$ (e.g., layer 2).
Comparison of the W-MLP and Transformer Compressor architectures

Datasets

The framework is evaluated on two types of data:

  • Toy Task Dataset: A custom synthetic dataset consisting of 11 knowledge-retrieval tasks (e.g., country-to-capital, antonyms, ISO codes). Each task includes 10 distinct natural language prompt templates for training and 10 for evaluation to test template generalization.
  • ARC-Easy: A standard multiple-choice science question-answering benchmark. This dataset provides a stricter test of generalization because each question represents a unique, one-shot prompt rather than a repeating task instruction.

Key Insights and Ideas

  • Linearity and Simplicity Win: Surprisingly, the simple W-MLP consistently outperforms the heavier Transformer Compressor (TC). While TC has more capacity, it overfits heavily to specific training tasks. W-MLP's success strongly reinforces the linearity hypothesis—the idea that semantic concepts in LLMs are structurally organized such that they can be effectively superimposed via basic vector addition.
  • The "Middle-to-Early" Pattern: Through layer-wise ablations, the authors discovered that the best results occur when extracting activations from a middle layer (where abstract semantic information is richest) and injecting them into an early layer (giving the model enough subsequent transformer blocks to process and integrate the patch vector before generation).
  • Automatic Salience Detection: Without explicit supervision, the W-MLP naturally learns to assign high weights to information-dense keywords (e.g., "capital", "authored", "translation") and terminal punctuation marks (which act as attention sinks), while suppressing low-information words like determiners.

Key Results

  • Toy Tasks: On in-distribution tasks, the W-MLP achieves 85.35% test accuracy, falling less than 2% short of the uncompressed full prompt baseline (86.92%), while the masked baseline (no prompt info) drops to 34.03%.
Figure 3: Comparison of test performance for a sub-sample of the in-distribution Tasks and out-of- distribution Tasks.
  • ARC-Easy Benchmark: The W-MLP successfully generalizes to unique questions across multiple model families (Llama-3, Ministral, Qwen). On Llama-3.1-8B, W-MLP recovers 77% accuracy (compared to 92% full prompt and 38% masked prompt). Performance scales positively with the model's hidden dimension size.
Figure 4: ARC-Easy test accuracy across LLMs, comparing the Transformer Compressor (TC), the Weighting MLP (W-MLP), and the full- and masked-prompt baselines
  • High Information Capacity: In a complementary capacity experiment, the authors found that a single optimized patch vector can encode up to 9 different tasks simultaneously without any measurable degradation in performance, indicating that the latent space has ample unutilized capacity.

Limitations and Future Work

  • Task Complexity Constraints: The evaluation focuses primarily on short prompts and knowledge-retrieval tasks. It remains an open question whether complex reasoning or long-context dependencies can be compressed into a single vector.
  • White-Box Access Required: This method requires direct access to modify intermediate hidden states, making it incompatible with closed-source, API-only models like GPT-4.
  • Upfront Computational Cost: Generating the patch vector requires a partial forward pass through the model. Therefore, the computational savings are only realized when the compressed representation can be amortized over many repeated queries.
  • Future Extensions: The authors suggest extending this work by segmenting long prompts into multiple semantic blocks (multi-token patches) or enforcing sparsity constraints to filter out activation noise.

Summary updated

BibTeX
@misc{ardoin2026prompt,
  author = {Thibaud Ardoin and Semira Einsele and Evis Bregu and Gerhard Wunder},
  title = {{Prompt Compression via Activation Aggregation}},
  year = {2026},
  eprint = {2607.08399},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2607.08399},
}
Figure