Sampling from Your Language Model One Byte at a Time

Jonathan Hayase, Alisa Liu, Noah A. Smith, Sewoong Oh

Introduction

Tokenization is a foundational component of modern Large Language Models (LLMs), enabling efficient text representation through multi-byte or multi-character tokens via Byte-Pair Encoding (BPE). However, this efficiency comes at a cost: the Prompt Boundary Problem (PBP).

Because LLMs process text as discrete tokens rather than individual characters, arbitrary prompt cutoffs can distort the model's probability distribution. For example, if a user prompts a model with "Hello wor", a human naturally expects the completion "ld". But if the model's tokenizer has a single, distinct token for " world" (including the leading space), the prompt ending at "wor" forces an unnatural token boundary. The model is now forced to predict a sequence it rarely saw during training (" wor" + "ld"), making the most logical completion artificially less likely.

This issue extends far beyond English quirks—it poses significant hurdles for code generation (where prompts often end mid-identifier) and languages like Chinese or Japanese, where tokens frequently span multiple words. To address this, researchers have introduced ByteSampler, a novel inference-time algorithm that allows standard BPE-based language models to sample text one byte at a time without losing exactness.

The ByteSampler Method

ByteSampler converts a token-based LM into a byte-level LM at inference time. It achieves this without retraining, relying on a core data structure called the Valid Covering Tree (VCT).

  • The Valid Covering Tree (VCT): This structure represents all possible token sequences that could "cover" a specific byte string.
  • Pairwise Validation: To prevent the tree from growing infinitely, the authors mathematically prove that for BPE, one only needs to check if adjacent tokens are valid together (i.e., whether the BPE algorithm would actually produce this specific pair). This insight allows for massive pruning of the tree.
  • Exact Distribution: Unlike heuristic approaches like "token healing" (which simply backs up a few characters and regenerates), ByteSampler is mathematically exact. It perfectly recovers the true probability distribution the model would have assigned if the prompt had not forced an artificial token boundary.
  • The "Trunk" Property: BPE tokenization is "locally forced." Once a few bytes away from the end of a string, tokenization becomes deterministic. ByteSampler leverages this "trunk-and-branches" structure: most of the prompt forms a deterministic trunk, with only a small branching factor at the boundary, making it highly efficient.

Key Applications: Ensembling and Proxy-Tuning

By operating at the byte level, ByteSampler effectively abstracts away the underlying tokenizer. This unlocks powerful new capabilities for model interoperability:

  • Vocabulary Unification for Ensembling: Because the tokenizer no longer dictates the output space, users can ensemble models with completely different vocabularies. For instance, one can take a Llama model, a Qwen model, and an OLMo model, and average their byte-level probabilities directly at inference time.
  • Cross-Tokenizer Proxy-Tuning: ByteSampler allows the "knowledge" or stylistic alignment from a small, fine-tuned expert model (e.g., OLMo-Instruct) to be applied as a delta to a much larger base model (e.g., Llama-3.1-8B) at inference time, even if the two models use entirely different tokenizers.

Experimental Results

The researchers evaluated ByteSampler across a wide range of domains, including English (OLMo2) and Chinese (MADLAD-400) language modeling, code completion (HumanEval), and various downstream tasks (SQuAD, GSM8k, MMLU, etc.).

  • Efficiency: ByteSampler incurs 65% less overhead than the next best exact method. On average, it requires only 0.72 extra tokens of inference per prompt compared to standard BPE sampling.
  • Accuracy: In English next-character prediction, ByteSampler achieved 81.5% accuracy, drastically outperforming standard BPE (29.5%) and surpassing the best backtracking heuristics (76.3%).
  • Ensembling Success: A byte-level ensemble of Qwen3, OLMo2, and Llama3.2 consistently outperformed the average of the individual models across seven downstream tasks.
  • Proxy-Tuning Success: The team successfully transferred the instruction-following capabilities of OLMo2-Instruct to Llama-3.1-8B, creating a combined model that surpassed the performance of the individual expert.

Limitations and Future Directions

While highly effective, ByteSampler has a few current limitations. Its efficiency guarantees rely specifically on BPE (like those used by HuggingFace and SentencePiece) and do not yet support Unigram or Wordpiece tokenizers, as the pairwise validation logic does not apply to them. Additionally, while efficient in terms of token overhead, sampling byte-by-byte inherently requires more forward passes through the model than token-by-token sampling, making it slower in wall-clock time.

Future work aims to extend this method to automatically support arbitrary pretokenizers and to investigate why byte-level sampling transformations (like Top-P) often yield slightly better performance than their token-level counterparts.

Summary updated

BibTeX
@inproceedings{hayase2026sampling,
  author = {Jonathan Hayase and Alisa Liu and Noah A. Smith and Sewoong Oh},
  title = {{Sampling from Your Language Model One Byte at a Time}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=COQV7D1dAW},
}
Figure