arXiv:2506.07956cs.CLcs.FL2025-06ICML被引 11

让语言模型只生成合法的分词序列,避免错误分配概率。

Language Models over Canonical Byte-Pair Encodings

  • 通过测试时条件约束或训练时结构设计,强制输出合法分词
  • 修复非规范分词后,多个模型在验证集上似然得分提升
  • 适合关注分词准确性和生成质量的研究者

现代语言模型将字符串的概率分布表示为经确定性分词器(如字节对编码)生成的较短分词串的概率分布。尽管该方法在大规模语料上表现高效,但现有实现存在严重问题:模型为每个字符串分配了指数级数量的非规范分词编码的非零概率——这些分词串虽能解码为有效字符串,但在确定性分词器下不可能出现(即永远不会出现在任何训练语料中)。这种误分配既错误又浪费,因非规范分词从未在训练数据中出现,却占用了本应属于合理输出的概率。本文提出两种方法消除此类错误:(1) 通过测试时推理策略实现分词规范性,无需额外训练;(2) 通过模型参数化保证输出始终规范,但需重新训练。实验证明,修复分词规范性错误可显著提升多个模型和语料上的保留数据似然。

原文摘要 · Abstract (English)

Modern language models represent probability distributions over character strings as distributions over (shorter) token strings derived via a deterministic tokenizer, such as byte-pair encoding. While this approach is highly effective at scaling up language models to large corpora, its current incarnations have a concerning property: the model assigns nonzero probability mass to an exponential number of $\it{noncanonical}$ token encodings of each character string -- these are token strings that decode to valid character strings but are impossible under the deterministic tokenizer (i.e., they will never be seen in any training corpus, no matter how large). This misallocation is both erroneous, as noncanonical strings never appear in training data, and wasteful, diverting probability mass away from plausible outputs. These are avoidable mistakes! In this work, we propose methods to enforce canonicality in token-level language models, ensuring that only canonical token strings are assigned positive probability. We present two approaches: (1) canonicality by conditioning, leveraging test-time inference strategies without additional training, and (2) canonicality by construction, a model parameterization that guarantees canonical outputs but requires training. We demonstrate that fixing canonicality mistakes improves the likelihood of held-out data for several models and corpora.

语言模型分词概率建模

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