Compressing Sequences in the Latent Embedding Space: $K$-Token Merging for Large Language Models

Zihao Xu, John Harvill, Ziwei Fan, Yizhou Sun, Hao Ding, Hao WangarXiv 2026

TL;DR

K-Token Merging is a novel prompt compression framework that slashes LLM computational costs by merging blocks of $K$ consecutive token embeddings into a single latent embedding via a lightweight encoder. By exploiting massive redundancies in the latent space rather than just dropping words, it achieves up to a 75% reduction in input length with negligible impact on downstream performance.

What Problem Does This Paper Address?

As we push Large Language Models (LLMs) to handle ever-longer contexts, we run into a massive computational bottleneck: the memory and compute requirements of standard self-attention grow quadratically with the input length.

To mitigate this, researchers have turned to prompt compression. Existing methods usually fall into two buckets:

  1. Hard prompt compression: Dropping or summarizing tokens. This works when information is sparse but fails catastrophically on information-dense tasks like coding or mathematical reasoning, where every token matters.
  2. Soft prompt compression: Learning compact virtual tokens. However, these methods still operate primarily in token space, ignoring a massive source of inefficiency: the latent embedding space itself.

The authors point out a striking statistical gap: in a model like Qwen 2.5, a single token embedding consumes 28,672 bits of memory, whereas the theoretical minimum needed to uniquely identify a token from its vocabulary is only about 18 bits. K-Token Merging targets this exact latent redundancy to pack more information into fewer embedding vectors.

Methods

Instead of filtering out words, K-Token Merging uses an asymmetric approach to compress the input sequence while keeping the model's generation capabilities fully intact. The process is split into two distinct stages:

Figure 2: Model Structure for K-Token Merging Model (Case K = 2). Left: During the prefill stage, the encoder f takes each K consecutive input tokens and produces a single compressed token embedding. Here, Ti denotes the original input tokens and Ci denotes the resulting compressed tokens. Right: During the generation stage, the LLM outputs original (uncompressed) tokens. Each newly generated token is appended to the mixed compressed/uncompressed prefix, after which standard auto-regressive generation continues. Here, Gi denotes the generated uncompressed tokens.
  • Prefill Stage (Compression): A lightweight, three-layer Multi-Layer Perceptron (MLP) encoder $f$ (~50 MB) takes a contiguous block of $K$ token embeddings and merges them into a single compressed embedding vector ($C_i$).
  • Generation Stage (Standard Autoregression): The compressed embeddings are fed into the LLM, which has been adapted using Low-Rank Adaptation (LoRA). Crucially, the model still outputs standard, uncompressed tokens from its original vocabulary.

The "Average-Initialization" Trick

Training an encoder from scratch to compress embeddings often leads to slow convergence. To fix this, the authors designed a residual architecture: the encoder outputs the mathematical mean (average pooling) of the $K$ tokens plus a residual shift from the MLP. By initializing the MLP weights close to zero, the encoder initially acts as a simple average-pooler, providing a stable, semantically grounded starting point that speeds up training significantly.

Datasets

The authors evaluated their approach across three distinct tasks to ensure robustness across structural, natural language, and code domains:

  • Textualized Tree: A synthetic structural reasoning dataset where the model must identify parent-child relationships in an indented text tree.
  • Amazon Reviews (Fashion category): A natural language sentiment classification dataset.
  • CommitPackFT (Python subset): A complex code-editing dataset where the model is given code and a commit instruction, and must output the updated code.

Key Insights and Ideas

  • Input-Only Compression: Expanding a model's vocabulary with multi-token chunks ($K$-grams) usually causes a "tail-token explosion" (too many rare words) and fails to generalize to unseen phrases. By compressing only on the input side via a neural encoder, K-Token Merging avoids this issue entirely.
  • Latent Space is Highly Compressible: The paper proves that neural networks don't need a sequence of distinct vectors to understand a sequence of words; a single well-formed vector in the latent space can successfully retain dense structural and semantic information.
  • Complementary to Hard Compression: Because this method operates purely in the embedding space, it can theoretically be stacked on top of token-dropping methods for even higher compression ratios.

Key Results

Across all datasets, K-Token Merging consistently sat on the Pareto-optimal frontier, offering an exceptional trade-off between speed and accuracy:

Figure 1: Our K-Token Merging method (K = 4) achieves a 75% reduction in input length with only a 1.52% drop in accuracy on the Textualized Tree bench- mark, demonstrating that it exploits redundancy in the latent embedding space while preserving high perfor- mance. See the “Experiments” section for details.
  • Massive Length Reduction: At $K=4$, the method achieved a 75% reduction in input length with only a minor 1.52% drop in accuracy on the Textualized Tree benchmark.
  • Real-World Speedups: When scaled to a larger Qwen Coder 7B model on the code-editing task ($K=2$), it reduced inference latency by 20.9% and boosted throughput by 27.8%, while only incurring a tiny 1.1% relative increase in perplexity.

Limitations and Future Work

While promising, the authors note a few limitations that pave the way for future research:

  1. No Generation-Phase Compression: The framework currently only compresses the initial prompt (prefill). As the model generates new tokens, they are appended uncompressed, meaning efficiency gains diminish during very long generations.
  2. Fixed Compression Ratios: The model uniformly compresses every block of $K$ tokens. An adaptive strategy—compressing common phrases aggressively while leaving rare, information-dense terms uncompressed—could yield even better results.
  3. Model Scale: Most core experiments were conducted on a 0.5B parameter model. Though validated on a 7B model, broader testing across diverse architectures and larger scales is still required.

Summary updated

BibTeX
@misc{xu2026compressing,
  author = {Zihao Xu and John Harvill and Ziwei Fan and Yizhou Sun and Hao Ding and Hao Wang},
  title = {{Compressing Sequences in the Latent Embedding Space: $K$-Token Merging for Large Language Models}},
  year = {2026},
  eprint = {2604.15153},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2604.15153},
}
Figure