Tokens and Next-Token Prediction
In this article
- Count the tokens in a text that has been cut into pieces, and tell why a word count gives the wrong budget for limits and prices.
- Trace a reply step by step: a probability for each possible next token, one token chosen and added, then the next step on the longer text.
- Say whether a reply ended on the stop signal or at the output limit.
- Explain why a high next-token probability does not show that a statement is true.
- Terms defined here: prompt, token, token ID, tokenizer, next-token probability, generation loop.
Overview
Ask a chat assistant "In which city is the Eiffel Tower?" and "Paris." comes back, written one small piece at a time, as Large Language Models showed. Two things are still hidden: what a piece is, and how the model settles on one piece at each step, out of all the pieces it could write. The answer also explains a stranger reply. Ask about zorb, a made-up computer tool that does not exist, and the assistant can describe a setting of it that nobody ever built, written with the same ease as "Paris". Afterwards you can count the pieces in a text, follow a reply from first piece to last, tell why it stopped, and say what the model's numbers measure.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- From text to tokens
- A probability for every next token
- The generation loop
- What the probability measures
- Sources
- Check yourself, 5 questions