Open Agent School · Public worked example
Tokens: meaning and example
Welcome! Take one idea with you today.
A tokenizer converts input into units called tokens and maps them to IDs a model can use. For text, tokens may represent whole words, word pieces, punctuation, or bytes. The exact split depends on the tokenizer and its vocabulary; there is no universal conversion from words to tokens.
Picture it: A booking assistant receives an English sentence, a customer name with accents, and a long reference code. The team assumes every word is one token and reserves no space for the answer. You need a budget that includes system instructions, retrieved context, the user message, and the expected output.
What is easy to mix up?
A word can span multiple tokens, and a token can include whitespace or punctuation. Token-to-word ratios vary across languages, domains, and tokenizer versions.
Teaching example by Open Agent School. Source: Hugging Face Transformers - Tokenization algorithms.