Tokenizer vocabulary and vocabulary size
What a token vocabulary is, how tokenizer vocab size affects segmentation and meaning, and why styled, reversed or mirrored Unicode text tokenizes poorly.
A tokenizer vocabulary is the fixed set of units a tokenizer is allowed to output. Every piece of text it processes is split into units from that set, and each unit is usually mapped to a numeric ID. The vocabulary size is simply how many distinct units the set contains. That one number shapes how text is segmented, how long the resulting sequences are, and how well unusual words, scripts and styled characters survive the process. This review explains the mechanism, the tradeoffs of vocabulary size, and where tokenization interacts badly with transformed text such as Unicode font styling, reversal and mirroring.
Two meanings of vocabulary
The term is used in two related but different ways. In corpus linguistics, the vocabulary of a text is the set of distinct word types found after word tokenization, and its size is the type count. In machine learning, a tokenizer vocabulary is a predefined inventory of units, often fragments of words, chosen before any particular text is processed. The first is measured from the data; the second is imposed on it. Keeping the two apart avoids a common confusion: a corpus can contain far more word types than a model tokenizer has entries, because the tokenizer builds rare words out of smaller pieces.
What tokenization actually changes
Tokenization does not rewrite the stored text. It produces a separate representation: a sequence of tokens, or token IDs, that points back to the original characters. Whether that representation can be turned back into exactly the same text depends on the tokenizer. Byte-level and some subword tokenizers are designed to be lossless, so decoding reproduces the input. Others apply normalization first, such as lowercasing, stripping accents, collapsing whitespace or converting Unicode to a canonical form. Those steps do change the characters the tokenizer sees, and the original cannot always be recovered from the tokens alone.
For word-level linguistic analysis, the decisions that change the outcome are the tokenization rules themselves: whether punctuation is split off, how contractions and clitics are handled, whether hyphenated compounds count as one word, and whether case is folded. Two analyses of the same text can report different vocabulary sizes purely because of these rules, so a reported type count is only meaningful alongside the rules that produced it.
Word, character and subword vocabularies
| Approach | What a unit is | Vocabulary size tendency | Main strength | Main weakness |
| Word-level | A whole word as defined by the rules | Grows with the corpus and is usually capped | Units align with how people read and count words | Words outside the vocabulary become an unknown token and their meaning is lost |
| Character-level | A single character or code point | Small and fixed per script | Almost nothing is out of vocabulary | Sequences become long and individual units carry little meaning |
| Byte-level | A single byte of the encoded text | Fixed and minimal, covering every possible byte | Any input can be represented losslessly | Non-Latin scripts and emoji expand into several bytes each |
| Subword (for example BPE, WordPiece, Unigram) | Frequent words plus fragments learned from training text | Chosen as a design parameter | Common words stay whole while rare words are composed from pieces | Segmentation reflects training data, so unfamiliar text fragments heavily |
How vocabulary size shapes results
A larger vocabulary lets more words and phrases exist as single units, which shortens sequences and keeps frequent words intact. The cost is a bigger lookup table, more parameters to store and train when the vocabulary feeds a model, and many entries that appear rarely in training and are therefore poorly learned. A smaller vocabulary is cheaper to store and covers rare forms by combination, but it breaks more words into pieces, lengthens sequences and pushes more of the interpretation work onto whatever consumes the tokens.
Coverage is uneven across languages and domains. A subword vocabulary learned mostly from one language or register tends to keep that material compact while fragmenting other scripts, technical terms and names into many short pieces. When comparing tokenizers, the useful question is not only how large the vocabulary is but how many tokens a representative sample of your own text produces and whether meaningful units stay recognizable.
- Signs a vocabulary fits your text: common words in your domain come out as one or a few tokens; the unknown token appears rarely or never; decoding returns the original text when lossless behavior is required.
- Signs it does not: ordinary words split into many fragments; names or non-Latin text balloon in token count; normalization silently removes distinctions you need, such as accents or case.
Combining marks, emoji and normalization
What a reader sees as one character can be several code points. An accented letter may be stored as a base letter plus a combining mark, and many emoji are sequences joined by invisible joiner characters or followed by modifiers. Tokenizers that operate on code points or bytes do not automatically respect these visual boundaries, so a single visible symbol can become several tokens, and a split can fall between a letter and its accent. Unicode normalization can merge a precomposed letter and its decomposed equivalent into one form, which changes token counts and type counts even though the text looks identical.
The same issue appears in reversal, a closely related transformation. Reversing by code point detaches combining marks from their letters, while reversing by user-perceived character keeps them together. The example below shows the code points involved; the outputs follow directly from the order of those code points rather than from any particular tool.
Input (decomposed): c a f e U+0301 displays as "café"
Code-point reversal: U+0301 e f a c accent is orphaned at the start
Grapheme reversal: e+U+0301 f a c displays as "éfac"
Styled, reversed and mirrored text in a tokenizer
Text transformations that look harmless to a human can change what a tokenizer receives. The effect depends on whether the transformation changes stored characters or only how they are displayed.
- Unicode "font" styling: generators that produce bold, script or double-struck letters usually substitute characters from separate Unicode blocks, such as mathematical alphanumeric symbols. These are different code points from ordinary letters, so a tokenizer trained on normal text is unlikely to have whole-word entries for them and tends to break the text into many small or byte-level pieces. Compatibility normalization can map many of these characters back to plain letters, but only if the pipeline applies it.
- Character reversal: the stored characters are reordered, so the tokenizer sees unfamiliar letter sequences that rarely match learned subwords. Expect heavier fragmentation and loss of recognizable words.
- Word-order reversal: individual words stay intact and tokenize normally, but the order that carries the sentence's meaning is lost.
- Mirrored glyphs: some mirror generators substitute look-alike characters from other scripts or symbol sets, which tokenizes much like font styling. Mirroring applied with CSS transforms changes only presentation; the stored text, and therefore its tokens, are unchanged.
- Bidirectional display: right-to-left rendering is decided by the Unicode bidirectional algorithm from the stored order, so display order and stored order can differ. Explicit direction-control characters, however, are real code points and do appear in the token stream.
Will the result remain usable after copying or sharing?
Token IDs are not portable. An ID only means something relative to the exact tokenizer and vocabulary that produced it, so sharing token sequences between systems with different vocabularies produces meaningless output. Share the decoded text, or record the tokenizer name and version alongside any token data.
Transformed text carries its changes with it when copied. Styled Unicode letters, reversed characters and look-alike substitutions paste as the substituted code points, so the destination's search, spell-checking, sorting and tokenization all operate on those characters rather than the plain words. CSS mirroring and styling do not survive plain-text copying at all, because only the underlying characters are copied. Screen readers and other assistive technology may announce substituted characters by their Unicode names, spell them out, or skip them; behavior varies by product and version, and no scoped test or documentation for a specific screen reader or destination was available for this review. Anyone relying on a particular platform should test it directly rather than assume one successful rendering applies everywhere.
A plain-text equivalent is needed whenever the text must be searchable, accessible, machine-analyzed or counted accurately. For linguistic analysis in particular, run tokenization on the plain original, and treat styled or reversed variants as separate data rather than as the same words.
Is a given tokenizer or transformation suitable for your use?
For word-type counting and corpus comparison, a rule-based word tokenizer with documented normalization is usually the clearest choice, because its units match what readers recognize as words and its vocabulary size has a direct linguistic meaning. For feeding text into a model, the tokenizer is fixed by the model, and the practical task is checking how efficiently it segments your material. The decisive tradeoff is between compact, meaningful units from a larger vocabulary and robust coverage of rare forms from a smaller one.
Plain text is preferable whenever meaning, searchability or accessibility matters more than appearance. Unicode styling, character reversal and glyph-substitution mirroring all degrade tokenization and downstream analysis; they suit short decorative uses where a plain version is also available. Presentation-only effects such as CSS mirroring leave the text and its tokens intact, so they are the safer route when a visual effect is genuinely needed.
Evidence gaps
No specific tokenizer, vocabulary size, token count or measurement was supplied for this review, so the comparisons above are qualitative and based on general, documented properties of Unicode and common tokenization approaches. Exact segmentation of styled or reversed text, and the behavior of named platforms or assistive technologies, should be confirmed by testing the specific tokenizer and destination you intend to use.