Training-Free Tokenizer Transplantation via Orthogonal Matching Pursuit
作者: Charles Goddard, Fernando Fernandes Neto
分类: cs.CL, cs.AI, cs.LG
发布日期: 2025-06-07
💡 一句话要点
提出基于正交匹配追踪的免训练Tokenizer迁移方法,实现LLM词表快速适配
🎯 匹配领域: 支柱二:RL算法与架构 (RL & Architecture) 支柱九:具身大模型 (Embodied Foundation Models)
关键词: Tokenizer迁移 正交匹配追踪 免训练学习 大型语言模型 词嵌入 稀疏表示 知识蒸馏
📋 核心要点
- 现有tokenizer迁移方法通常需要训练或微调,计算成本高昂且可能导致模型性能下降。
- 论文提出基于正交匹配追踪(OMP)的免训练tokenizer迁移方法,通过稀疏表示重建新token嵌入。
- 实验表明,该方法在跨tokenizer任务中显著优于现有零样本方法,有效保留了模型性能。
📝 摘要(中文)
本文提出了一种免训练的方法,通过正交匹配追踪(OMP)重建未见过的token嵌入,从而在预训练的大型语言模型(LLM)中迁移tokenizer。具体来说,我们将每个词汇表外的token近似为共享token的稀疏线性组合,分两个阶段进行:首先,使用少量共享锚定token的字典计算每个新token在donor嵌入空间中的表示;然后,将相同的稀疏系数转移回基础模型的嵌入空间。在两个具有挑战性的跨tokenizer任务(Llama→Mistral NeMo (12B) 和 Qwen→Llama (1B))上,我们表明OMP在多个基准测试中实现了基础模型性能的最佳零样本保留,而其他零样本方法则显著降低。与基线(zero-init、mean-init以及WECHSEL、FOCUS、ZETT等现有方法)相比,OMP始终实现最佳整体性能,有效弥合了tokenizer的巨大差异,而无需梯度更新。我们的分析进一步表明,不匹配的数值token化方案是保持数学推理能力的关键挑战。该技术能够直接重用具有新tokenizer的预训练模型权重,从而促进跨tokenizer知识蒸馏、推测解码、集成、合并和特定领域词汇适应。我们将我们的方法集成到开源mergekit-tokensurgeon工具中,用于事后词汇重新对齐。
🔬 方法详解
问题定义:论文旨在解决大型语言模型(LLM)在更换tokenizer时,如何有效利用已有的预训练权重,避免从头开始训练或进行昂贵的微调。现有方法,如随机初始化、均值初始化以及WECHSEL、FOCUS、ZETT等方法,在跨tokenizer迁移时,往往会导致模型性能显著下降,尤其是在处理具有较大词表差异的模型时。
核心思路:论文的核心思路是将词汇表外的(out-of-vocabulary,OOV)token嵌入表示为词汇表内的(in-vocabulary)token嵌入的稀疏线性组合。通过在donor模型的嵌入空间中找到OOV token的稀疏表示,然后将相同的稀疏系数转移到base模型的嵌入空间,从而实现tokenizer的迁移。这种方法避免了梯度更新,实现了免训练的tokenizer移植。
技术框架:该方法包含两个主要阶段: 1. 稀疏表示构建:对于每个OOV token,在donor模型的嵌入空间中,使用少量共享的锚定token(anchor tokens)构建其稀疏表示。正交匹配追踪(OMP)算法用于找到最佳的稀疏系数。 2. 嵌入空间迁移:将第一阶段获得的稀疏系数应用到base模型的嵌入空间中,从而得到OOV token在base模型中的嵌入表示。
关键创新:该方法最重要的创新在于其免训练的特性,以及利用正交匹配追踪算法进行稀疏表示。与现有方法相比,该方法无需梯度更新,能够更有效地保留预训练模型的知识,尤其是在处理具有较大词表差异的模型时。
关键设计: * 锚定token选择:选择在donor和base模型中都存在的token作为锚定token,用于构建OOV token的稀疏表示。 * 正交匹配追踪(OMP):使用OMP算法找到最佳的稀疏系数,该算法能够有效地选择最具代表性的锚定token。 * 稀疏度控制:通过控制稀疏度,可以平衡表示的准确性和计算效率。论文中可能存在对稀疏度参数的具体设置,但摘要中未明确提及。
🖼️ 关键图片
📊 实验亮点
实验结果表明,OMP方法在Llama→Mistral NeMo (12B) 和 Qwen→Llama (1B)两个跨tokenizer任务上,显著优于zero-init、mean-init、WECHSEL、FOCUS和ZETT等基线方法,实现了最佳的零样本性能保留。该方法能够有效弥合tokenizer的巨大差异,无需梯度更新。
🎯 应用场景
该研究成果可广泛应用于LLM的tokenizer适配、知识蒸馏、推测解码、模型集成与合并,以及领域特定词汇的快速扩展。例如,可以将一个在通用语料上预训练的模型快速迁移到特定领域,只需调整tokenizer而无需重新训练整个模型,从而大大降低了开发成本和时间。
📄 摘要(原文)
We present a training-free method to transplant tokenizers in pretrained large language models (LLMs) by reconstructing unseen token embeddings via Orthogonal Matching Pursuit (OMP). Specifically, we approximate each out-of-vocabulary token as a sparse linear combination of shared tokens, in two phases: first, compute each new token's representation in the donor embedding space with a small dictionary of shared anchor tokens, then transfer these same sparse coefficients back into the base model's embedding space. On two challenging cross-tokenizer tasks--Llama$\to$Mistral NeMo (12B) and Qwen$\to$Llama (1B)--we show that OMP achieves best zero-shot preservation of the base model's performance across multiple benchmarks, while other zero-shot approaches degrade significantly. Compared to baselines (zero-init, mean-init, and existing approaches like WECHSEL, FOCUS, ZETT), OMP consistently achieves the best overall performance, effectively bridging large tokenizer discrepancies without gradient updates. Our analysis further identifies mismatched numerical tokenization schemes as a critical challenge for preserving mathematical reasoning capabilities. This technique enables direct reuse of pretrained model weights with new tokenizers, facilitating cross-tokenizer knowledge distillation, speculative decoding, ensembling, merging, and domain-specific vocabulary adaptations. We integrate our method into the open-source mergekit-tokensurgeon tool for post hoc vocabulary realignment.