Large Language Model as Token Compressor and Decompressor

Wenbing Li, Yiran Wang, Zikai Song, Jielei Zhang, Tianhao Zhao, Junkai Lin, Wei YangarXiv 2026

TL;DR

This paper introduces a novel framework that adapts a pretrained Large Language Model (LLM) into its own discrete, variable-length token compressor and decompressor using lightweight LoRA adapters. By mapping long texts into a compact, content-adaptive "semantic language" of discrete latent codes (Z-tokens), the method significantly reduces effective context length, memory usage, and inference latency while preserving downstream reasoning performance.

What Problem Does This Paper Address?

Processing long contexts in LLMs is fundamentally bottlenecked by the quadratic computational and memory complexity ($O(N^2)$) of the standard attention mechanism. As sequence lengths scale to tens or hundreds of thousands of tokens, large-scale inference becomes prohibitively expensive.

Existing token compression techniques generally fall into two buckets: heuristic pruning (which drops tokens based on local similarity or attention scores, risking the loss of crucial pragmatic meaning) and learned continuous embedding methods (like ICAE or AutoCompressor). However, continuous embedding methods treat compression as an external task decoupled from the LLM's primary generative reasoning process. Furthermore, their reliance on fixed compression ratios prevents them from adapting to varying information density across a document.

Methods

The authors propose a self-expressive autoencoding framework that leverages the LLM's own internal semantic knowledge to act as both a token compressor and decompressor.

  • Vocabulary Extension & Z-Tokens: The authors expand the LLM's native vocabulary with a learned codebook of discrete tokens called Z-tokens.
  • Autoregressive Variable-Length Compression: A LoRA-adapted LLM acts as the compressor, generating a sequence of Z-tokens autoregressively. Instead of forcing a fixed compression ratio, the model dynamically decides when to stop compressing by emitting a special [EOS-Z] token.
  • Budget-Aware Length Regularization: To control the compression rate, a soft length regularizer ($L_{len}$) penalizes global budget violations. This allows information-dense text segments to naturally receive more Z-tokens, while redundant regions are represented more compactly.
  • End-to-End Training: To backpropagate through discrete token selections, the framework utilizes a Gumbel-Softmax estimator combined with a straight-through estimator.
  • Two Inference Paradigms: The framework supports two distinct operational modes:
  • Direct Decompression: The compressed Z-tokens are fed straight to the decompressor to generate the final natural language task output.
  • Z-Space Inference: A separate LLM inferencer performs autoregressive generation entirely within the abstract Z-token space before the decompressor projects the final response back into surface text.
Figure 1: Our framework consists of three components: a compressor, an inference module, and a decompressor. It supports two usage paradigms. In the first, we directly feed the compressed representation to the decompressor to perform the downstream task. In the second, we first run the inference module in the Z-token space and then invoke the decompressor to recover task outputs at the token level.

Datasets

The framework was evaluated across a diverse suite of long-context benchmarks:

  • Wikipedia: Used for pre-training, text reconstruction, and text continuation tasks.
  • CNN/DailyMail: Evaluated on abstract text summarization.
  • HotpotQA: Multi-hop question answering.
  • NarrativeQA: Long-form narrative comprehension.
  • QASPER: Scientific document question answering.
  • QuALITY: Long-context multiple-choice reading comprehension.
  • HumanEval: Used to test the generalization capability of the compressed representations on unstructured code-generation prompts.

Key Insights and Ideas

  • Natural Language is Inherently Compressive: The core philosophy is that LLMs are already powerful engines for conceptual distillation. Instead of inventing an external vector space, the model can translate text into its own private, highly optimized symbolic language.
  • Context-Dependent, Non-Deterministic Codes: Unlike traditional subword tokenizers where a token maps to a fixed string, Z-tokens function as underspecified semantic units. The same Z-token can yield completely different surface text depending on the surrounding context, and distinct sentences sharing the same core concept will map to overlapping Z-tokens.
Examples of Z-token flexibility, demonstrating semantic synonymy and context-dependent decoding.
  • Dynamic Information Allocation: Controlled analysis proved that the compressor naturally allocates more Z-tokens to segments with higher surprisal (low predictability) and higher rare-entity density, validating the theoretical rate-distortion trade-off design.

Key Results

  • Superior Reconstruction Quality: On Wikipedia text reconstruction, the method achieved a BLEU-4 score of 99.31 at 4× nominal compression and 96.28 at 8× compression, significantly outperforming baselines like ICAE and AutoCompressor.
Figure 3: BLEU-4 at different input lengths and compression ratios. The solid line represents our method, and the dashed line represents ICAE.
  • Downstream Task Preservation: On long-context QA benchmarks (QuALITY, NarrativeQA, QASPER), the method outperformed prior compression baselines and closely matched the performance of the uncompressed base model under a 4× compression budget.
  • Substantial Efficiency Gains: For a 30k token input on Qwen3-4B, the method slashed end-to-end latency from 22.67 seconds to 17.21 seconds, boosted generation throughput, and dramatically reduced peak GPU memory usage from 56.48 GB down to 25.40 GB.

Limitations and Future Work

  • Global Coordination Across Windows: For excessively long sequences, the framework relies on a sliding window approach that compresses segments independently. The authors note that a global coordination mechanism across windows could improve long-range coherence.
  • Task-Agnostic Compression: The current compression strategy is largely task-agnostic. Developing a task-aware compression strategy could help the model better preserve specific structural or relational nuances required for specialized downstream objectives.

Summary updated

BibTeX
@misc{li2026large,
  author = {Wenbing Li and Yiran Wang and Zikai Song and Jielei Zhang and Tianhao Zhao and Junkai Lin and Wei Yang},
  title = {{Large Language Model as Token Compressor and Decompressor}},
  year = {2026},
  eprint = {2603.25340},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.25340},
}
Figure