zip2zip++: Towards Inference-Time Token Compression with Minimal Quality Loss
Organizations: EPFL · Technical University of Munich · Zuse School ELIZA · ETH Zürich
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.
Figures & tables
| Model | Method | ARC-c | ARC-e | HS | OBQA | PIQA | WG | Wiki | Pile | mC4 | dC4 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Phi-3.5-4B | Uncompressed | 0.59 | 0.84 | 0.74 | 0.48 | 0.82 | 0.75 | 1.58 | 1.67 | 1.77 | 1.82 |
| zip2zip | 0.54 | 0.81 | 0.71 | 0.46 | 0.80 | 0.75 | 1.70 | 1.82 | 1.86 | 1.92 | |
| zip2zip++ | 0.57 | 0.83 | 0.72 | 0.47 | 0.80 | 0.74 | 1.66 | 1.78 | 1.83 | 1.89 | |
| Phi-3-14B | Uncompressed | 0.65 | 0.88 | 0.81 | 0.51 | 0.83 | 0.79 | 1.43 | 1.61 | 1.71 | 1.76 |
| zip2zip | 0.61 | 0.85 | 0.78 | 0.51 | 0.81 | 0.77 | 1.58 | 1.76 | 1.80 | 1.85 | |
| zip2zip++ | 0.62 | 0.86 | 0.79 | 0.50 | 0.82 | 0.78 | 1.53 | 1.72 | 1.77 | 1.82 |
| Wiki | Pile | mC4 | dC4 | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Model | Training | PPL | PPL ⋆ | BPB | BPB ⋆ | PPL | PPL ⋆ | BPB | BPB ⋆ | PPL | PPL ⋆ | BPB | BPB ⋆ | PPL | PPL ⋆ | BPB | BPB ⋆ |
| Phi-3.5-4B | Uncompressed | 11.5 | 11.5 | 0.66 | 0.66 | 31.5 | 31.5 | 0.74 | 0.74 | 30.4 | 30.4 | 0.82 | 0.82 | 35.2 | 35.2 | 0.87 | 0.87 |
| zip2zip | 16.8 | 14.8 | 0.76 | 0.73 | 57.9 | 49.5 | 0.87 | 0.83 | 41.0 | 37.3 | 0.89 | 0.87 | 47.5 | 43.0 | 0.94 | 0.91 | |
| zip2zip++ | 14.9 | 13.6 | 0.73 | 0.70 | 49.3 | 43.4 | 0.83 | 0.81 | 37.8 | 35.0 | 0.87 | 0.85 | 44.0 | 40.7 | 0.92 | 0.90 | |
| Phi-3-14B | Uncompressed | 6.8 | 6.8 | 0.52 | 0.52 | 25.0 | 25.0 | 0.69 | 0.69 | 24.9 | 24.9 | 0.77 | 0.77 | 28.6 | 28.6 | 0.81 | 0.81 |
| zip2zip | 11.6 | 9.9 | 0.66 | 0.62 | 45.4 | 38.7 | 0.82 | 0.78 | 33.6 | 30.5 | 0.84 | 0.82 | 38.5 | 34.9 | 0.89 | 0.86 | |
| GSM8K | MATH-500 | HumanEval | IFEval | RULER | |||||
|---|---|---|---|---|---|---|---|---|---|
| Scale | Model | acc | acc | pass@1 | prompt acc | 4K | 8K | 16K | 32K |
| Phi-3.5-4B | Uncompressed | 0.75 | 0.36 | 0.58 | 0.38 | 86.4 | 81.5 | 78.1 | 73.7 |
| zip2zip | 0.36 | 0.15 | 0.26 | 0.32 | 46.6 | 28.1 | 21.0 | 15.2 | |
| zip2zip++ | 0.68 | 0.24 | 0.32 | 0.32 | 70.7 | 60.6 | 53.2 | 52.8 | |
| Phi-3-14B | Uncompressed | 0.70 | 0.39 | 0.57 | 0.49 | 81.6 | 47.9 | 40.6 | 32.2 |
| zip2zip | 0.51 | 0.22 | 0.36 | 0.43 | 52.5 | 23.2 | 14.0 | 11.6 | |
| Configuration | ARC-c | ARC-e | HS | OBQA | PIQA | WG | GSM8K | Wiki | Pile | mC4 | dC4 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| zip2zip | 0.54 | 0.81 | 0.71 | 0.46 | 0.80 | 0.75 | 0.36 | 1.70 | 1.82 | 1.86 | 1.92 |
| + Digit protection | 0.54 | 0.81 | 0.70 | 0.47 | 0.79 | 0.71 | 0.61 | 1.71 | 1.83 | 1.87 | 1.93 |
| + Untied hyper-encoders | 0.56 | 0.82 | 0.72 | 0.47 | 0.79 | 0.74 | 0.62 | 1.69 | 1.81 | 1.85 | 1.91 |
| + Size-aware RoPE | 0.55 | 0.82 | 0.71 | 0.46 | 0.80 | 0.74 | 0.65 | 1.69 | 1.81 | 1.85 | 1.91 |
| + Identity-init residual | 0.57 | 0.83 | 0.72 | 0.47 | 0.80 | 0.74 | 0.68 | 1.66 | 1.78 | 1.83 | 1.89 |
| + Continued Pretraining | 0.55 | 0.82 | 0.72 | 0.46 | 0.80 | 0.75 | 0.64 | 1.63 | 1.74 | 1.82 | 1.88 |
Appendix figures & tables15 assets
Supplementary material from the paper’s appendix.
Appendix
| Base models | Phi-3.5-mini-instruct (3.8B), Phi-3-medium-4k-instruct (14B), |
|---|---|
| Llama-3.2-1B-Instruct, Llama-3.2-3B-Instruct | |
| Adapter | LoRA rank 32, , all attention and MLP projections; |
| decoder otherwise frozen | |
| Optimizer | AdamW, , weight decay 0.01 |
| Learning rate | cosine , 800 warm-up steps |
| Steps | 8,000, at decoder positions per step |
| Recipe | GSM8K flexible | GSM8K strict |
|---|---|---|
| Protected digits, untied encoders | .6232 | .066 |
| end-indexed positions | .6497 | .210 |
| identity init. | .6778 | .215 |
| Uncompressed reference | .7468 | .372 |
| Model | Method | ARC-c | ARC-e | HS | OBQA | PIQA | WG | Wiki | Pile | mC4 | dC4 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Phi-3.5-4B | Original | 0.56 | 0.79 | 0.71 | 0.48 | 0.78 | 0.73 | 1.58 | 1.68 | 1.79 | 1.84 |
| Uncompressed | 0.59 | 0.84 | 0.74 | 0.48 | 0.82 | 0.75 | 1.58 | 1.67 | 1.77 | 1.82 | |
| zip2zip | 0.54 | 0.81 | 0.71 | 0.46 | 0.80 | 0.75 | 1.70 | 1.82 | 1.86 | 1.92 | |
| zip2zip++ | 0.57 | 0.83 | 0.72 | 0.47 | 0.80 | 0.74 | 1.66 | 1.78 | 1.83 | 1.89 | |
| Phi-3-14B | Original | 0.64 | 0.86 | 0.82 | 0.57 | 0.83 | 0.79 | 1.43 | 1.62 | 1.72 | 1.77 |
| Uncompressed | 0.65 | 0.88 | 0.81 | 0.51 | 0.83 | 0.79 | 1.43 | 1.61 | 1.71 | 1.76 |
| GSM8K accuracy | ||||||
|---|---|---|---|---|---|---|
| Original | Uncompressed | zip2zip | zip2zip++ | zip2zip | zip2zip++ | |
| Phi-3.5-mini | .78 | .75 | .36 | .68 | 1.53 | 1.25 |
| Phi-3-medium | .84 | .70 | .51 | .69 | 1.52 | 1.27 |
| Llama-3.2-1B-Inst | .42 | .34 | .20 | .24 | 1.37 | 1.26 |
| Llama-3.2-3B-Inst | .76 | .64 | .41 | .53 | 1.37 | 1.29 |
| GSM8K | Compression | |||
|---|---|---|---|---|
| Protection strategy | flexible | WikiText | MC input | Math decode |
| No protection | .356 | |||
| same weights, digits protected at eval | .458 | |||
| same weights, uncompressed eval | .483 | |||
| Digits protected (train eval) | .610 | |||
| same weights, uncompressed eval | .679 | |||
| Corpus | Control | Strict | Exact multi-view | First-token bound |
|---|---|---|---|---|
| WikiText | 1.5777 | 1.6573 | 1.6290 | 1.5882 |
| Pile | 1.6678 | 1.7819 | 1.7488 | 1.6972 |
| mC4 | 1.7660 | 1.8311 | 1.8084 | 1.7696 |
| dC4 | 1.8221 | 1.8913 | 1.8668 | 1.8240 |
| Length-4 | Strict byte-PPL | Penalty of | |||||
|---|---|---|---|---|---|---|---|
| Corpus | coverage | Strict | Exact MV | First-token | |||
| Repeat-4 | 6.54% | 1.1890 | 1.2050 | 1.1922 | 1.07% | .94% | .25% |
| Repeat-8 | 29.90% | 1.1057 | 1.1535 | 1.1122 | 3.71% | 3.54% | .33% |
| Training path | GSM8K | Wiki byte-PPL |
|---|---|---|
| zip2zip++, direct SFT, 8k steps | .6778 | 1.6574 |
| 20B raw SFT, 8k | .6088 | 1.6377 |
| 20B raw SFT, 16k | .6255 | 1.6390 |
| 20B raw SFT, 48k | .6391 | 1.6554 |
| 200B raw SFT, 8k | .6414 | 1.6331 |
| Intervention | Parent | Training / LM proxy | GSM | Takeaway |
|---|---|---|---|---|
| Reformat math SFT as chat | zip2zip | Wiki PPL | Narrow style gain, broad MC/PPL trade-off | |
| Freeze decoder LoRA for 200 steps | + untied | Final loss flat | Co-adaptation is preferable here | |
| Hyper-encoder 2 4 layers | + untied | Loss ; PPL flat | Capacity fits training, does not transfer | |
| Exact online codebook mask | final | Loss | Better proxies, worse downstream | |
| 25% uncompressed microsteps | final | PPL flat | No measurable transfer | |
| Two-axis RoPE (fixed 50/50 split) | final | Wiki PPL flat | Mixed coordinates do not help |