Generate one token at a time
A language model builds a response one token at a time. Each chosen token becomes part of the context for the next prediction.
A token is a piece of text, such as a word, part of a word or punctuation. The context is the text available to the model, including the tokens already generated.
1. Predict probabilities
Use the current context to calculate the chances of possible next tokens.
For our picnic, we packed …
In our example: sandwiches 60%, umbrellas 25%, telescopes 10%, snow 5%. Together, these chances add to 100%.
2. Choose a token
A selection rule chooses one candidate. The top-choice rule picks the largest probability; sampling can pick a less likely candidate.
Top choice: sandwiches
We use top choice for this example.
3. Add it to the context
Append the chosen token to the text already written.
For our picnic, we packed sandwiches
This longer sentence is now the context for the next prediction.
4. Repeat with the new context
Calculate a new set of probabilities after “sandwiches”, then choose and append another token. A continuation such as “and” or punctuation can now fit.
For our picnic, we packed sandwiches …
Return to step 1 with this longer context. Do not reuse the original picnic probabilities.
The cycle continues until a stopping condition is met, such as an end-of-response token or a length limit. The model does not need to choose the whole response at once.
Trace the next cycle
Suppose the next chosen token is “and”. Say or write the complete context the model will use for the following prediction. Will it reuse the original 60%, 25%, 10% and 5%?
Check your reasoning
The new context is “For our picnic, we packed sandwiches and”. The model calculates new probabilities using that extended context. The original probabilities applied to the sentence ending at “packed”.