Language Models over Canonical Byte-Pair Encodings

Tim Vieira, Tianyu Liu, Clemente Pasti, Yahya Emara, Brian DuSell +5 more
6/9/2025
cs.CLcs.FLcs.LG

No confident code implementation found for this paper. 9 possible matches can be shown below.

Abstract

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.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 9 weaker matches are hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{vieira2025language,
  title  = {Language Models over Canonical Byte-Pair Encodings},
  author = {Tim Vieira and Tianyu Liu and Clemente Pasti and Yahya Emara and Brian DuSell and Benjamin LeBrun and Mario Giulianelli and Juan Luis Gastaldi and Timothy J. O'Donnell and Ryan Cotterell},
  year   = {2025},
  eprint = {2506.07956},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2506.07956v1},
  journal = {ICML 2025 2025}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2506.07956.svg)](https://codeofpaper.com/paper/2506.07956)

Discussion