Tokenization in NLP: How Machines Break Down Text
SkillVeris Team
AI Research Team

Tokenization splits raw text into smaller units called tokens, which can be words, subwords, or individual characters depending on the method.
In this guide, you'll learn:
- Subword tokenization strikes a balance between vocabulary size and the ability to represent rare or unseen words.
- Byte Pair Encoding and WordPiece are two widely used subword tokenization algorithms behind many modern language models.
- Tokenization directly affects context window usage, since models process a fixed number of tokens rather than a fixed number of words.
- Poor tokenization choices can hurt performance on languages with different structures than English, such as those without clear word boundaries.
1What Is Tokenization?
Tokenization is the process of breaking raw text into smaller units, called tokens, that a machine learning model can process as numerical input. It is the first transformation any piece of text undergoes before reaching a neural network.
Without tokenization, a model has no way to convert language into the fixed-size numeric vectors it operates on internally.
2Why Tokenization Matters for Language Models
The tokenizer determines how much of a sentence a model can meaningfully process at once, because context windows are measured in tokens, not words or characters.
A poorly designed tokenizer can split common words into unnecessarily many pieces, wasting context window capacity and making the model's job harder than it needs to be.
3Common Tokenization Approaches
There are three broad strategies for splitting text, each with different trade-offs between vocabulary size and the ability to handle unfamiliar words.
- Word-level tokenization: splits on whitespace and punctuation, producing intuitive tokens but a huge vocabulary and poor handling of rare words.
- Character-level tokenization: splits into individual characters, producing a tiny vocabulary but very long sequences and weaker semantic grouping.
- Subword tokenization: splits into frequent chunks smaller than words but larger than characters, balancing vocabulary size against flexibility.
4How Subword Tokenization Works
Most modern language models use subword tokenization because it handles rare and unseen words gracefully while keeping vocabulary size manageable.
Byte Pair Encoding starts with individual characters and iteratively merges the most frequent adjacent pairs until it reaches a target vocabulary size. WordPiece follows a similar idea but selects merges based on likelihood rather than raw frequency.
💡
5How a Tokenizer Is Trained
A tokenizer is trained on a large text corpus before the language model itself is trained. This training process learns which character sequences occur frequently enough to deserve their own token, building a fixed vocabulary that the model will use for its entire lifetime.
Because the vocabulary is fixed after training, any text the model encounters later, including new slang or technical jargon, must be represented using combinations of the existing tokens.
6Challenges Tokenization Introduces
Tokenization is not a neutral preprocessing step; it introduces real challenges that affect model behavior downstream.
- Languages without clear word boundaries, such as Chinese or Thai, require different segmentation strategies than English.
- Numbers and code can tokenize inconsistently, sometimes splitting digits in ways that hurt arithmetic reasoning.
- Token counts vary by language, meaning the same sentence can cost more or fewer tokens depending on which language it is written in.
7Tokenization in Practice
Developers working with language models rarely write their own tokenizer from scratch. Instead, they use the tokenizer that ships alongside a pretrained model, since token boundaries must match exactly what the model saw during training.
Understanding tokenization becomes practically useful when estimating costs or context limits, since providers typically charge and cap usage based on token counts rather than raw character counts.
8Next Steps for Learning NLP Fundamentals
Tokenization is a foundational concept that underlies embeddings, attention, and everything else a transformer-based model does with text. Once it clicks, concepts like context window limits and prompt length stop feeling arbitrary.
Learners looking to go deeper can explore SkillVeris courses covering Python for AI and ML alongside dedicated large language model content, where tokenization is covered as part of the broader modeling pipeline.
Related Reading
Get The Print Version
Download a PDF of this article for offline reading.
About the Publisher
SkillVeris Team
AI Research Team
Our AI team covers the latest in machine learning, generative AI, and emerging tech — clearly and accurately.
View all postsRelated Posts
Never miss an update
Get the latest tutorials and guides delivered to your inbox.
No spam. Unsubscribe anytime.