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

Zihao Xu, John Harvill, Ziwei Fan, Yizhou Sun, Hao Ding +1 more
4/16/2026
cs.CLcs.AI

Official code: shsjxzh/K-Token-Merging (6 stars, last commit 2026-04-21).

Abstract

Large Language Models (LLMs) incur significant computational and memory costs when processing long prompts, as full self-attention scales quadratically with input length. Token compression aims to address this challenge by reducing the number of tokens representing inputs. However, existing prompt-compression approaches primarily operate in token space and overlook inefficiencies in the latent embedding space. In this paper, we propose K-Token Merging, a latent-space compression framework that merges each contiguous block of K token embeddings into a single embedding via a lightweight encoder. The compressed sequence is processed by a LoRA-adapted LLM, while generation remains in the original vocabulary. Experiments on structural reasoning (Textualized Tree), sentiment classification (Amazon Reviews), and code editing (CommitPackFT) show that K-Token Merging lies on the Pareto frontier of performance vs. compression, achieving up to 75% input length reduction with minimal performance degradation.

View on arXivView PDF

Code Implementations(1)

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

60PythonApr 19, 20266 months ago

Similar Papers

Cite this paper

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

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2604.15153.svg)](https://codeofpaper.com/paper/2604.15153)

Discussion