Subword tokenization explained
How a subword tokenizer splits text into pieces, what it changes, why its output is not shareable text, and when plain text is the better choice.
A subword tokenizer breaks text into units that are usually smaller than whole words but larger than single characters. Language models and many text-analysis pipelines use these units as their input. This overview covers what subword tokenization does, what it changes about your text, whether its output stays usable outside a model, and when you should keep plain text instead.
What a subword tokenizer does
Word-level tokenizers fail on any word missing from their vocabulary. Character-level tokenizers handle any word but produce very long sequences. Subword tokenization sits between the two. Frequent words tend to stay whole, and rare or unseen words are split into smaller pieces the tokenizer already knows. The vocabulary is learned from a training corpus, and its size is chosen in advance by whoever builds the tokenizer.
Common approaches
| Method | How the vocabulary is built | Typical boundary marker |
| Byte-pair encoding (BPE) | Starts from characters or bytes and repeatedly merges the most frequent adjacent pair until the target vocabulary size is reached | Varies by implementation; byte-level variants often show a leading space as a special symbol such as Ġ |
| WordPiece | Merges pieces in a similar way but picks merges by how much they improve the likelihood of the training data, not by raw frequency | ## prefix on pieces that continue a word |
| Unigram language model | Starts from a large set of candidate pieces and prunes those that contribute least to likelihood; can produce alternative segmentations of the same text | Often used through SentencePiece, with ▁ marking a preceding space |
| SentencePiece (framework) | Treats input as a raw character stream, spaces included, so text does not need to be split into words first; implements both BPE and unigram | ▁ marks a preceding space |
A subword tokenization example
The splits below are illustrative. They show each method's marker conventions and are not output captured from a specific tokenizer. Real splits depend entirely on the trained vocabulary, so the same word can be one token in one model and several tokens in another.
Input: unbelievably readable
WordPiece-style: un ##believ ##ably read ##able
SentencePiece: ▁un believ ably ▁read able
Byte-level BPE: un believ ably Ġread able
In WordPiece, ## means the piece attaches to the one before it. In SentencePiece, ▁ stands for a space before the piece. To reverse the split, called detokenization, you remove or convert the markers and join the pieces. In each line above, doing so gives back the original two words.
What the transformation actually changes
Splitting by itself does not rewrite characters. It produces a sequence of pieces, and the model works with integer IDs mapped to those pieces. Nothing about appearance changes, so this is unrelated to font styling or display effects. The steps that run before splitting, however, often do change characters, and these changes may not be reversible.
- Unicode normalization: many tokenizers normalize input first. SentencePiece commonly applies NFKC by default, which can turn compatibility characters, such as full-width letters or stylized "font" letters from the Unicode math ranges, into their plain equivalents.
- Lowercasing and accent stripping: uncased BERT-style WordPiece tokenizers lowercase text and remove accents, so "Café" and "cafe" become identical.
- Unknown characters: a tokenizer without byte fallback may replace characters it has never seen with a single unknown token, and the original character is lost.
- Whitespace: some pipelines collapse repeated spaces or handle line breaks and tabs differently from ordinary spaces.
Combining marks and emoji need extra care. A byte-level tokenizer can split one visible character into several tokens. Examples include a letter followed by a combining accent, or an emoji built from several code points joined with zero-width joiners. None of the resulting pieces displays correctly alone, and the original reappears only when every piece is rejoined in order. Cutting a token sequence at a length limit can split such a sequence and leave a broken or substituted glyph. This follows from how byte-level splitting works. How often it happens depends on the vocabulary, and no measurements were available for this review.
Will tokenized output stay readable and usable?
A token sequence is an internal representation, not a reading format. If you copy a list of pieces with their markers into a document, message or search field, people and software will read the markers and fragments literally.
- Accessibility: a screen reader will generally read out markers and word fragments as they appear, so a token list cannot stand in for readable text. No specific assistive technology was tested for this review.
- Search and editing: fragments such as ##ably do not match the words people search for, and spell checkers will flag them.
- Round-tripping: detokenization restores the exact original only if no lossy normalization happened earlier. Otherwise you get back a normalized version.
- Portability: splits and token IDs belong to one vocabulary. A sequence produced by one tokenizer means nothing to another.
Keep or restore the original string whenever a person will read, search, quote or edit the text. If you need to reproduce the input exactly, store the raw text alongside the tokens instead of relying on detokenization.
Is subword tokenization suitable for your use?
Subword tokenization is the right tool for preparing text as model input, or for measuring length the way a model does, for example against a token budget. Its main benefit is that a fixed vocabulary can cover rare words, names and typos without falling back to unknown tokens, while keeping sequences much shorter than character-level splitting would. The decisive tradeoff is that the segmentation is statistical, not linguistic. Pieces do not reliably match prefixes, roots or suffixes. Text in languages or scripts that were underrepresented in the training data can also be split into more pieces, which affects cost and how much fits in a model's context.
- Plain text is the better choice when:
- The output is meant for human readers.
- You must preserve casing, accents, stylized Unicode characters or exact whitespace, and the tokenizer normalizes them.
- You need a linguistically valid breakdown of word structure. A morphological analyzer is better suited for that.
- You are exchanging data between systems that use different tokenizers.
Evidence gaps
This overview relies on the generally documented behavior of common methods. No specific tokenizer, vocabulary or version was tested, so it reports no token counts, real model splits or compatibility results. To evaluate a particular tokenizer, run representative samples of your own text through it, including accented words, emoji sequences and any non-Latin scripts you use, and check that the detokenized output matches the input.