brainax

What is a tokenizer

A tokenizer is a program that cuts text into tokens before a language model reads it. A token is a piece of text: a whole word, part of a word, sometimes a space or a punctuation mark. Each token gets a number from the model's vocabulary, and the model sees a chain of those numbers, not letters.

Common words usually fit in one token, while rare and long ones get cut into parts. The same meaning in Russian, Arabic and many other languages often takes more tokens than in English, because model vocabularies were built mostly from English text. That's also why a model struggles to count the letters in a word: it never sees the letters.

Covered in the lessonWhat Are Tokens in AI and What Is a Context Window?Open the lesson →

More terms from this course