An LLM never sees raw text. So what does it actually process?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
A token is the atomic unit an LLM reads and emits, usually a sub-word chunk of bytes mapped to an integer id by the tokenizer. The model only ever sees token ids, never raw text.
Imagine the language model only understands numbers, not letters. Before the model ever sees your message, a small program called the tokenizer chops the text into little pieces and looks up a number for each piece. Sometimes a piece is a whole short word like 'the'. Sometimes it is half of a long word, like 'token' plus 'ization'. Each piece gets its own number, and the model reads the list of numbers. When the model replies, it produces numbers, and the tokenizer turns them back into letters for you. The pieces are called tokens. They are not characters, they are not words, they sit somewhere in between. The bill you pay and the size of the conversation the model can remember are both measured in tokens, not in characters and not in words.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
5 min: state the byte-level definition, place the tokenizer as a separate component before and after the model, contrast tokens against characters and words, show that counts are tokenizer-specific, and link the concept to cost, context window, and latency.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating tokens as words or as characters. Tokens are sub-word units defined by the tokenizer, and the same string can produce different token counts under different tokenizers.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.