Read a token sequence

Reach for each comma and return to your resting position. · 135 words

A tokenizer splits input into units called tokens. A token can be a word, part of a word, or punctuation. Suppose a toy tokenizer splits sunlight into sun and light. It uses two tokens for that word. A different tokenizer could keep the entire word together and use only one.

Imagine a context window that can hold eight tokens in total for an input and its reply. If the instruction and question already use six under the chosen tokenizer, only two remain for output in this toy system. Changing the wording can change that budget without changing the request's meaning. Punctuation and spaces can affect the split as well. When planning a real request, use the tokenizer or counting method for that model and reserve enough room for the kind of response the task requires.

Check your recall

Can a word count determine the exact token count?

Check your answer

The count depends on the tokenizer and the input.

Sources and credits

Original KeyTouch lesson. Background reading · Hugging Face · LLM Course.