arXiv:2506.01084cs.CLcs.LG2025-06NeurIPS被引 5

让大模型在推理时动态压缩分词,减少冗余 token

zip2zip: Inference-Time Adaptive Tokenization via Online Compression

  • 用 LZW 算法实时合并高频词组为超词元,动态扩展词汇表
  • 在未见语境中减少输入输出 token 15%-40%,提升效率
  • 仅需 10 GPU 小时微调,适配现有模型,适合高效部署场景

分词效率对大语言模型的性能与成本至关重要,但多数模型依赖通用语料库优化的静态分词器。固定词汇表难以适应特定领域或语言输入,导致序列变长、计算开销上升。本文提出 zip2zip,一种在推理时实现上下文自适应分词的新方法。基于在线数据压缩算法 Lempel-Ziv-Welch(LZW),zip2zip 在推理过程中动态扩展活跃词汇表,持续将碎片化词元序列替换为更紧凑的超词元,并即时输出。该过程使模型内部分词方案匹配当前上下文的词分布,降低冗余,提升表示效率。zip2zip 包含三个核心组件:(1) 基于 LZW 的分词器,实时合并共现词元生成可复用超词元;(2) 动态嵌入(及反嵌入)层,在运行时计算新生成超词元的嵌入;(3) 一种预训练变体的自回归语言建模,使模型能处理压缩后的超词元序列。我们证明,现有 LLM 可通过参数高效微调在 10 GPU 小时内完成 zip2zip 上游训练。结果模型具备测试时适应能力,能在未见上下文中使用超词元,使输入和输出 token 减少 15%-40%。

原文摘要 · Abstract (English)

Tokenization efficiency plays a critical role in the performance and cost of large language models (LLMs), yet most models rely on static tokenizers optimized on general-purpose corpora. These tokenizers' fixed vocabularies often fail to adapt to domain- or language-specific inputs, leading to longer token sequences and higher computational costs. We introduce zip2zip, a novel method for achieving context-adaptive tokenization in LLMs at inference time. Leveraging an online data compression algorithm (Lempel-Ziv-Welch), zip2zip dynamically expands its active vocabulary at inference time by continuously replacing fragmented token sequences with more compact hypertokens, which it can immediately output during generation. In doing so, the model refines its internal tokenization scheme to match the token distribution of the current context, reducing redundancy and improving representational efficiency. zip2zip consists of three key components: (1) a tokenizer based on Lempel-Ziv-Welch compression that incrementally merges co-occurring tokens into reusable hypertokens on the fly; (2) a dynamic embedding (and unembedding) layer that computes embeddings for newly formed hypertokens at runtime; and (3) a variant of autoregressive language modeling that pretrains the model to handle hypertokenized, compressed text sequences as inputs and outputs. We show that an existing LLM can be uptrained for zip2zip in 10 GPU-hours via parameter-efficient finetuning. The resulting LLM performs test-time adaptation, learning to use hypertokens in unseen contexts and reducing input and output tokens by 15-40%.

分词优化推理加速自适应LZW

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。