arXiv:2410.09303cs.CLcs.LG2024-10ICLR被引 17

提出消除分词偏差的字节级概率计算方法,让语言模型更准确。

Exact Byte-Level Probabilities from Tokenized Language Models for FIM-Tasks and Model Ensembles

  • 基于分词与字节映射关系,推导出字节级概率公式
  • 在填空任务中提升18%性能,集成多模型时最高增3.7%
  • 无需重新训练,适用于分词不一致或跨模型融合场景

分词虽是长序列扩展的关键,但其带来的模型行为偏差尚不明确。本文通过对比分词模型与其无分词字节级版本的随机行为,发现两者在下一字节预测分布上存在显著差异,称为‘分词偏差’。为此提出字词表示引理,建立分词分布与等效字节分布间的映射关系,并据此开发一种无需额外训练的下一字节采样算法,实现零样本将分词模型转化为统计等价的无分词模型。该方法在填空中间(FIM)任务中有效缓解因输入中断于词内导致的分布外问题,使代码基准性能提升18%,优于传统分词修复方案;在多模型集成中,克服不同词汇表限制,跨标准基线在推理、知识与编码任务上整体提升达3.7%。代码已开源。

原文摘要 · Abstract (English)

Tokenization is associated with many poorly understood shortcomings in language models (LMs), yet remains an important component for long sequence scaling purposes. This work studies how tokenization impacts model performance by analyzing and comparing the stochastic behavior of tokenized models with their byte-level, or token-free, counterparts. We discover that, even when the two models are statistically equivalent, their predictive distributions over the next byte can be substantially different, a phenomenon we term as ``tokenization bias''. To fully characterize this phenomenon, we introduce the Byte-Token Representation Lemma, a framework that establishes a mapping between the learned token distribution and its equivalent byte-level distribution. From this result, we develop a next-byte sampling algorithm that eliminates tokenization bias without requiring further training or optimization. In other words, this enables zero-shot conversion of tokenized LMs into statistically equivalent token-free ones. We demonstrate its broad applicability with two use cases: fill-in-the-middle (FIM) tasks and model ensembles. In FIM tasks where input prompts may terminate mid-token, leading to out-of-distribution tokenization, our method mitigates performance degradation and achieves 18% improvement in FIM coding benchmarks, while consistently outperforming the standard token healing fix. For model ensembles where each model employs a distinct vocabulary, our approach enables seamless integration, resulting in improved performance up to 3.7% over individual models across various standard baselines in reasoning, knowledge, and coding. Code is available at: https://github.com/facebookresearch/Exact-Byte-Level-Probabilities-from-Tokenized-LMs

语言模型分词偏差字节级模型集成

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