Unigram tokenisation treats segmentation as a probabilistic modelling problem. Instead of committing to one history of pair merges, it learns a vocabulary whose pieces each carry probability and then chooses—or samples—segmentations that explain the input well.
This makes Unigram conceptually different from deterministic merge-rule approaches. A string can have several valid decompositions under the same vocabulary, and the tokenizer can compare those possibilities rather than assuming one boundary path is inevitable.
This article continues the eduKateSingapore Representation and Tokenisation series.
The Unigram Route
RAW / NORMALISED TEXT → LARGE CANDIDATE SUBWORD INVENTORY → ASSIGN PIECE PROBABILITIES → SCORE POSSIBLE SEGMENTATIONS → REMOVE LOW-VALUE PIECES → RE-ESTIMATE → FINAL VOCABULARY → BEST OR SAMPLED SEGMENTATION → TOKEN IDS
1. Unigram Starts With Many Candidate Pieces
A typical Unigram training process begins with a vocabulary larger than the final target. The candidate inventory can contain characters and many substrings observed in the training corpus.
The system then asks which subset of these pieces is most useful for explaining the corpus probabilistically.
2. Every Piece Receives a Probability
Each candidate token is associated with a probability or score. A segmentation of a string can then be scored from the probabilities of the pieces that compose it.
This transforms boundary selection into a model-selection problem.
3. A String Can Have Several Valid Segmentations
Suppose a vocabulary contains pieces corresponding to international, inter, nation and smaller units. More than one complete segmentation may cover the same source string.
Unigram can compare those alternatives according to the learned model instead of defining one irreversible merge history.
4. The Best Segmentation Maximises Model Fit
At inference, a deterministic Unigram tokenizer can choose the segmentation with the highest probability under the learned vocabulary model. Dynamic-programming methods such as Viterbi-style search can find the best path efficiently.
The chosen tokens form one high-scoring route through a lattice of possible pieces.
5. The Vocabulary Is Pruned Rather Than Only Built Up
A central contrast with BPE is direction. BPE is usually described as starting small and merging upward. Unigram commonly begins with many candidate pieces and removes those whose absence harms corpus likelihood least.
The final vocabulary emerges through controlled pruning.
6. Pruning Asks Which Pieces Earn Their Place
Removing a token forces the corpus to be represented through alternative pieces. If that substitution barely reduces model quality, the token is expendable. If its removal causes a large loss, the piece is valuable.
Vocabulary selection is therefore an economic decision under probabilistic fit.
7. Re-Estimation Follows Pruning
As candidates disappear, the remaining token probabilities are re-estimated because the possible segmentations and usage counts have changed.
Training alternates between modelling the corpus and simplifying the vocabulary until the target size is reached.
8. Characters Provide a Coverage Floor
To avoid losing coverage, the vocabulary typically retains sufficiently small units so uncommon strings can still be composed even when larger candidates have been pruned.
The exact primitive units depend on the implementation and character coverage policy.
9. SentencePiece Made Unigram Widely Practical
Taku Kudo and John Richardson’s SentencePiece provides language-independent tokenisation directly from raw sentences and supports Unigram as well as BPE.
This avoids requiring a universal whitespace word-segmentation stage before subword learning.
10. Spaces Can Become Part of the Modelled Representation
SentencePiece makes whitespace visible through a dedicated representation, commonly rendered as a special underline-like symbol in token displays. This lets the tokenizer learn word-start patterns without assuming that spaces should be discarded before tokenisation.
The boundary becomes data rather than invisible preprocessing.
11. Multiple Segmentations Enable Subword Regularisation
Because Unigram naturally assigns probabilities to multiple possible segmentations, training can sample alternative tokenisations instead of always choosing the single best one.
Taku Kudo’s 2018 paper Subword Regularization: Improving Neural Network Translation Models with Multiple Subword Candidates developed this idea explicitly.
12. Segmentation Noise Can Improve Robustness
If a model always sees one word under one fixed segmentation, it may overfit to that boundary pattern. Sampling alternative decompositions forces the model to learn relationships that survive several representational cuts.
The tokenizer becomes a source of controlled training augmentation.
13. Regularisation Treats Boundaries as Uncertain
Natural-language boundaries below the word level are often not uniquely determined by the computational objective. Subword regularisation uses that ambiguity rather than hiding it.
This is a strong representation principle: when several adequate cuts exist, training can benefit from seeing more than one.
14. Deterministic Inference Can Still Use One Best Path
A model may train with sampled segmentations and later use the highest-probability segmentation at inference for reproducibility and efficiency.
Training variability and serving determinism can therefore coexist.
15. Token Probability Is Not Semantic Probability
A high-probability subword piece is one that helps the tokenizer model its corpus effectively. It is not necessarily more meaningful or linguistically important than a lower-probability piece.
The probability belongs to the segmentation model.
16. Corpus Composition Still Controls the Model
The probability estimates arise from a training corpus. Languages and domains represented heavily in that corpus will shape which candidate pieces survive pruning and what probabilities they receive.
Unigram is probabilistic, not distribution-free.
17. Candidate Generation Matters
The final model cannot select a useful subword that never entered the candidate inventory. Candidate-generation rules therefore constrain what the later optimisation can discover.
The search space is a representation choice.
18. Character Coverage Matters in Multilingual Training
SentencePiece-style training can configure how much of the observed character distribution is covered explicitly. Rare characters outside the selected coverage may require fallback mechanisms depending on model configuration.
Multilingual tokenizers should choose this policy using real script distributions rather than one-language assumptions.
19. Vocabulary Size Still Creates the Familiar Trade-Off
A larger final vocabulary can retain more long candidate pieces and shorten sequences. A smaller vocabulary prunes more aggressively and relies on composition.
Probabilistic learning does not remove the embedding-table versus sequence-length trade-off.
20. A Large Candidate Vocabulary Is Not the Same as a Large Final Vocabulary
Unigram can explore a rich set of candidate pieces during training and still deliver a much smaller final inventory. The large search space exists to give pruning meaningful alternatives.
Training capacity and deployed vocabulary size are distinct quantities.
21. The Lattice View Is Powerful
A word or sentence can be represented as a lattice of possible token paths. Each path covers the source with a sequence of vocabulary pieces. The tokenizer scores these paths and selects or samples among them.
This makes segmentation ambiguity explicit rather than accidental.
22. Viterbi Finds a High-Scoring Complete Route
Dynamic programming avoids enumerating every segmentation independently. It can combine local best scores to find the globally best complete path under the model.
This is one reason probabilistic segmentation remains computationally practical.
23. Sampling Can Explore Near-Best Routes
Subword regularisation deliberately does not always take the highest-scoring route. It samples plausible alternatives according to controlled settings.
The model learns that meaning should survive more than one low-level segmentation.
24. Rare Words Benefit From Multiple Compositional Routes
An uncommon word may have several reasonable decompositions into known pieces. Exposure to several can strengthen reuse of shared substrings and reduce dependence on one rare token.
This is particularly relevant when data is limited.
25. Multilingual Systems Benefit From Raw-Sentence Training
Languages differ in whitespace conventions and morphology. Training directly from raw sentences lets one tokenisation framework operate without a separate language-specific word segmenter for every script.
This does not eliminate multilingual imbalance, but it reduces one source of pipeline dependency.
26. Normalisation Still Shapes the Candidate Statistics
Unicode canonicalisation, case policy and whitespace treatment occur before or inside the tokenizer pipeline and therefore change the substrings the model observes.
See Text Normalisation Before Tokenisation.
27. Unigram Does Not Discover Linguistic Morphemes Automatically
A probabilistically useful token can cross a morphological boundary, and a genuine morpheme can be represented through several pieces. The optimisation target is corpus likelihood under a finite vocabulary.
Statistical segmentation and linguistic analysis remain distinct.
28. Unigram Does Not Solve Syntax or Meaning
The tokenizer chooses model-ready pieces. Contextual model layers still need to determine syntax, reference, domain and meaning.
Segmentation is one layer in a longer representational stack.
29. Names Can Still Fragment
A rare name absent as a long token will be represented through smaller pieces. Probabilistic segmentation can choose the best available decomposition but cannot create a direct whole-name identity that the vocabulary does not contain.
Exact identity should remain attached to the source.
30. Numbers Remain Surface Strings
The model can assign probabilities to digit substrings, but those probabilities reflect corpus statistics rather than place-value semantics.
Mathematical structure must be learned or supplied at a higher layer.
31. Code Can Benefit From Domain Candidate Pieces
If source code is present in the tokenizer corpus, common operators, keywords and identifier fragments can survive pruning as useful tokens.
Domain representation begins with corpus design.
32. Unigram vs BPE Is Build-Down vs Build-Up
BPE is naturally explained as starting with small units and repeatedly merging. Unigram is naturally explained as starting with many candidate units and pruning toward a compact probabilistic vocabulary.
Compare How Byte Pair Encoding Works.
33. Unigram vs WordPiece Is Probabilistic Path vs Greedy Match
WordPiece application commonly selects the longest valid vocabulary piece from the current position. Unigram scores whole candidate segmentations under its probabilistic model.
Compare How WordPiece Works.
34. Unigram Offers a Natural Route to Segmentation Uncertainty
Because several paths have probabilities, the system can quantify and sample ambiguity instead of pretending that only one segmentation exists.
This makes Unigram especially elegant for subword regularisation.
35. Evaluation Still Needs Real Workloads
Measure token density, vocabulary utilisation, multilingual parity, reconstruction, exact-copy performance and downstream task results. A probabilistically elegant vocabulary can still be poorly matched to the intended receiver.
See Tokenizer Evaluation and Benchmarking.
36. The Unigram Audit
- How is the candidate vocabulary generated?
- What primitive units guarantee coverage?
- What corpus supplies the probability evidence?
- How are piece probabilities estimated?
- How is vocabulary pruning scored?
- What is the target final vocabulary size?
- How is the best segmentation found?
- Is subword regularisation or sampling used during training?
- How does token density vary across languages?
- How fragmented are names, numbers and code?
- Does the tokenizer round-trip required invariants?
- Does the final segmentation improve downstream performance?
37. What Students Should Remember
- Unigram begins with many candidate pieces.
- Each piece receives a probability.
- Several segmentations can cover the same string.
- The vocabulary is pruned toward a target size.
- Inference can choose the highest-scoring path.
- Training can sample alternative paths for subword regularisation.
- SentencePiece provides a widely used implementation route.
- Probabilistic segmentation still reflects corpus distribution.
38. The Deep Principle
Unigram treats a boundary not as a command carved into the tokenizer, but as one candidate route through a probabilistic vocabulary. The best cut is the one that makes the whole string most plausible under the model—and training can deliberately explore other plausible cuts.
Where BPE remembers a history of merges, Unigram keeps a vocabulary of possibilities and asks which complete segmentation best explains this input now.
Continue the Representation & Tokenisation Series
- How Byte Pair Encoding Works | From Frequent Pairs to a Learned Subword Vocabulary
- How WordPiece Works | From Subword Vocabulary to Greedy Longest-Match Tokenisation
- Tokenizer Training Corpus Design | How the Data Before the Model Shapes Every Token Boundary After It
- Canonical owner: World Representation & Cognitive Tools
