arXiv:2610.13605cs.CLOct 2026

Manuscript Offprint

arXiv:2610.13605

zip2zip++: Towards Inference-Time Token Compression with Minimal Quality Loss

Saibo Geng, Andrea Gentilini, Xinxian Ma, Nathan Ranchin, Yunzhen Yao, Robert West

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Dynamic vocabularies built on-the-fly via Lempel–Ziv–Welch (LZW) compression let a language model represent the same text in fewer tokens, but prior work shows that this efficiency comes at a cost to reasoning and perplexity. We show that this quality gap is not a fundamental price of compression but can be substantially closed through targeted improvements to the compression layer and LZW codec, without modifying the underlying pretrained language model. Our analysis reveals four key issues: (1) LZW's compression algorithm creates an implicit conflict between the input embedding and the output embedding — a tension that a single shared embedding cannot resolve; (2) naively applying RoPE to LZW-compressed sequences ignores that merged tokens can span multiple tokens; (3) merging certain tokens (notably digits) disproportionately hurts downstream accuracy; and (4) dynamic vocabularies introduce an inherent segmentation ambiguity that confounds standard evaluation. We address these through decoupled input/output dynamic embedding layer, size-aware RoPE positioning, and a modified LZW codec supporting selective merges and multi-view segmentations. Across four models, our recipe improves perplexity on every corpus we evaluated as well as mathematical reasoning accuracy, closing roughly half the quality gap between zip2zip and the uncompressed baseline at a similar compression ratio on general text. This represents a significant step toward lossless adaptive-vocabulary compression for language models. Code and models are available at https://github.com/epfl-dlab/zip2zip-plus-plus.

1 INTRODUCTION

The vocabulary of a language model determines the granularity at which text is represented, directly governing both computational efficiency and representational capacity. A more compact tokenization—one that represents the same text in fewer tokens—yields immediate practical benefits: lower inference cost (and, by extension, lower end-user billing in API-based services), reduced KV-cache memory footprint, and a larger effective context window within the same fixed token budget. Modern large language models universally adopt fixed vocabularies derived from statistical compression algorithms—most commonly Byte Pair Encoding (BPE) (Sennrich et al., 2016) or its variants (Kudo & Richardson, 2018; Kumar & Thawani, 2022; Liu et al., 2025)—trained once on large web corpora and frozen thereafter. While this approach is simple and effective on average, it is inherently suboptimal for any particular input: domain-specific terminology, low-resource languages, and structured data (e.g., code, mathematical expressions) are often over-segmented, producing unnecessarily long sequences and wasting compute (Rust et al., 2021; Ahia et al., 2023; Foroutan et al., 2026). Every excess token directly translates to unnecessary autoregressive steps, increased latency, and wasted context capacity. Prior attempts to mitigate this using vocabulary expansion (Wang et al., 2019),

∗^{*}Equal contribution. Author order was determined by a dice roll.

†^{\dagger}Work done during an internship at EPFL. Andrea Gentilini is supported by the Konrad Zuse School of Excellence in Learning and Intelligent Systems (ELIZA) through the DAAD programme Konrad Zuse Schools of Excellence in Artificial Intelligence, sponsored by the Federal Ministry of Education and Research.

domain-adaptive retraining (Zhao et al., 2024), or efficient language-specific vocabulary expansion (Kim et al., 2024)—require per-domain intervention and do not generalize to new domains.

Dynamic vocabularies, which adapt tokenization to the input at inference time offer a principled alternative. Rather than committing to a single fixed segmentation, such methods construct input-specific tokens on the fly, achieving shorter sequences without retraining. One line of work removes the fixed vocabulary entirely by operating at the byte level (Yu et al., 2023; Slagle, 2024; Pagnoni et al., 2025; Hwang et al., 2025; Feher et al., 2025), learning to dynamically group bytes into variable-length patches through the model architecture itself. Another line of work (Liu et al., 2024b; Geng et al., 2025) builds on top of the existing BPE token vocabulary, constructing higher-order tokens on the fly from observed token sequences. Geng et al. (2025) recently repurposed the Lempel–Ziv–Welch (LZW) streaming compression codec (Welch, 1984) for language model inference, dynamically building a hypertoken vocabulary on the fly. Unlike BPE, which learns a fixed merge table offline from a static corpus, LZW expands its dictionary online from the input token stream, reducing token usage by up to 40%. However, a language model's vocabulary is tightly coupled with its architecture through the embedding and output projection layers, so any vocabulary change risks degrading model behavior. Geng et al. (2025) mitigate this via lightweight LoRA finetuning (Hu et al., 2022), but at a significant cost: perplexity increases substantially and downstream performance degrades sharply on some tasks.

In this work, we identify the key sources of quality loss in zip2zip and address them with four targeted modifications: (1) Decoupled Residual Hypertoken Embeddings with identity initialization (Sections 3.1 and 3.2); (2) Size-Aware RoPE, which positions a hypertoken by the span of base tokens it covers (Section 3.3); (3) Fault-Tolerant LZW, a codec that stays robust when the compressor is an imperfect neural model and lets fragile tokens be exempted from merging (Section 4); and (4) Multi-View Perplexity, which marginalizes over every segmentation that decodes to the target rather than only the canonical one (Section 4.1). Together, these substantially narrow the gap to uncompressed baselines.

References (64)