In this article
BPE uses ranked merges, while a unigram model scores segmentations using learned piece probabilities; SentencePiece can provide implementations of different models.
Two tokenizers can share many visible vocabulary pieces while assigning a different segmentation to the same text. BPE and unigram tokenization explain why vocabulary contents are not the whole algorithm. Their training procedures and rules for choosing among possible segmentations differ, and a toolkit name does not remove that distinction.
BPE records a merge history
A BPE model learns and applies ranked adjacent-symbol merges under its preprocessing rules. The merge ordering guides how initial pieces combine. Frequency during training influences the learned sequence of merges, but ordinary encoding is not a fresh corpus-frequency estimation for each request. Once the tokenizer is fixed, the saved rules define its behavior. This distinction matters when explaining an unfamiliar word: its segmentation follows learned operations and available pieces rather than a semantic judgment performed by the downstream language model.
Unigram scores possible piece sequences
A unigram model associates probabilities with vocabulary pieces and can score a segmentation using the pieces it contains under the model’s assumptions. Different paths through the same text may therefore receive different scores. Training can begin with a candidate inventory and remove pieces according to an objective. The resulting model offers a different way to choose a segmentation than replaying BPE merge ranks. This is a tokenizer probability model over representations, not the complete contextual probability that an autoregressive language model assigns to the text.
Competing segmentations illustrate the difference
Imagine a string that can be represented by a long piece plus a short suffix, or by several shorter pieces. BPE follows its ranked merge availability, while a unigram decision compares the relevant path scores. A particular toolkit may also support sampling alternative segmentations during training under declared settings. That intentional variation is not a decoding error. Do not assume every production encode call samples, or that identical vocabulary strings establish identical identifiers, probabilities, normalization and boundary handling across two saved tokenizers.
A toolkit name is not a segmentation specification
SentencePiece is associated with tokenizer implementations and text processing, including support for more than one segmentation model. Record the actual model type and saved artifacts when reproducing token counts. Compare representative encodings, special tokens and round-trip behavior, not only vocabulary size. If a model checkpoint was trained with one tokenizer, replacing it with another algorithm changes the input contract even when many words look similar. The useful comparison explains representation tradeoffs under a declared training recipe rather than ranking algorithms from their names alone.
Primary research and implementation references
-
Neural Machine Translation of Rare Words with Subword Units.
-
SentencePiece: A Simple and Language Independent Subword Tokenizer.
Related engineering context
Reproducible inference stacks: preserving a GPU pilot’s result; A GPU inference benchmark you can trust.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.