DAILY PRACTICEBuild your AI engineering skills, one problem at a time.Try today's challenge
InferenceAIStart learning path

Generative AI · Beginner

Tokenization

Tokenization converts text into units a language model can map to token IDs.

TRY IT YOURSELF

Split a sentence into words

This uses whitespace only, not an actual model tokenizer.

AIsystemsneedcarefulevaluation
5 whitespace pieces

How it works

A tokenizer applies its own normalization and segmentation rules, then maps resulting pieces through a vocabulary. Common systems use subwords rather than simply splitting on spaces.

A concrete example

A word may be one token or several pieces depending on the tokenizer and vocabulary. The demonstration below only splits on whitespace to make the first step visible.

Watch for this

Do not assume a word count equals a model token count. Use the target model tokenizer for billing and context estimates.

Try it yourself

Type a short sentence and observe the whitespace pieces. Then compare with a real tokenizer.

Continue to practice →

Read the source: Hugging Face: tokenization algorithms ↗

Related concepts

Embeddings →

Prompt engineering →

Fine-tuning →