Why is BPE's greedy encoding not guaranteed to produce the segmentation with the fewest tokens?
- Because it applies merges in priority order and never reconsiders, unlike a global search over all splits
- Because it randomly skips some merges at inference to regularize its output, which lengthens the sequence unpredictably
- Because it always prefers single-byte tokens over longer merged tokens whenever both happen to be available
- Because minimizing token count is trivial in linear time, so BPE deliberately trades it away for encoding speed
Why
BPE encodes by applying its ordered merge rules greedily from highest to lowest priority, committing to each merge as it fires without ever reconsidering earlier choices in light of later ones. Because it takes locally best steps, the final segmentation can use more tokens than a globally optimal split would, and finding the truly minimal segmentation is an NP-hard problem BPE does not attempt. The random-skip option describes BPE-Dropout, a training-time augmentation, not standard deterministic encoding. The single-byte-preference option is wrong because BPE prefers to apply high-priority merges, which build longer tokens, not to keep bytes separate. The trivial-in-linear-time option is false: minimal segmentation is not trivially solvable, which is exactly why greedy BPE is used as a practical approximation. Unigram, by contrast, uses Viterbi to find the segmentation that maximizes total token probability, which is globally optimal under its model. This distinction is the core reason Unigram can produce shorter or more principled segmentations than BPE on some inputs, even though BPE dominates in practice for its simplicity and speed.