LightMySky

How a Chatbot Picks Its Next Token

A language-model chatbot generates text in small pieces called tokens. It uses learned patterns and the available context to select a next token, adds it, and repeats. Some chatbots also retrieve information with tools.

No account needed. Progress saves in this browser.

What a learner can do afterwards

  • Describe the loop of selecting a token, adding it to the text and continuing
  • Explain that language patterns are learned from training text while people write the learning software
  • Explain how random token selection can produce different answers to the same prompt

1 · Read

You have seen how models learn patterns from examples. A language-model chatbot generates text in pieces called tokens. A token can be a word, part of a word or punctuation. Using the text available so far, the model selects a next token, adds it, and repeats. Some chatbots also use tools to search for information.

Text so farSelect next tokenAdd tokenRepeat
Each generated token becomes part of the context for later tokens.

The model learned language patterns during training on large amounts of text. People wrote its learning software; they did not write a separate answer rule for every possible question. Training patterns and the current context both affect its output.

Try it together

For 'The cat sat on the', mat and rug are possible next words. Each might be one token. If random selection is used, repeated runs can choose different tokens and continue differently. Randomness is a setting, not a requirement. With fixed choices and the same context, an answer can repeat.

A language-model chatbot selects and adds tokens using learned patterns and context. This generates text without necessarily copying a checked answer. Fluent claims can be false. Check important facts in a reliable source. Open any retrieved result or citation and read whether it supports the claim. For a wording draft, check that it says what you meant.

A chatbot adds tokens using learned patterns and context. Random choices can change its wording. Generated claims and retrieved sources still need checking.

Generating text and checking it was written for this dataset.

2 · Watch

Take it off screen

Print a worksheetA4 with an answer key page for grown-ups. No screen, no internet.

Where it sits

Where this leads

Jobs that lean on this skill. Follow one to see everything it is built on.

Then practise

8 questions wait behind this lesson, each with its answer explained. Every answer feeds the sky: stars light as they are learned, and dim when it is time to come back.

Spotted a problem on this page? Tell us
How a Chatbot Picks Its Next Token · Computing, ages 12 to 13 · LightMySky