---
title: "How a Chatbot Picks Its Next Token"
description: "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 info"
canonical: https://lightmysky.com/learn/computing/how-a-chatbot-picks-its-next-token-mt_1Zbhamhzai
source: https://lightmysky.com/learn/computing/how-a-chatbot-picks-its-next-token-mt_1Zbhamhzai.md
retrieved: 2026-10-19
---

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# 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.

Subject: Computing · Area: Artificial Intelligence · Ages 12 to 13
Page: https://lightmysky.com/learn/computing/how-a-chatbot-picks-its-next-token-mt_1Zbhamhzai

## Ready when they can

- 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

## Lesson: One piece of text after another

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.

*(drawing: 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.

**Example.** 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.

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

## Practice

8 questions on this page, each with its working shown.

## Needs first

- [Machine Learning Basics](https://lightmysky.com/learn/computing/machine-learning-basics-mt_K6qtan847r)
- [Deepfakes and AI-Generated Content](https://lightmysky.com/learn/computing/deepfakes-and-ai-generated-content-mt_tzMr83pS8v)

## Opens up

- [Weighted Models: Learned Parameters and Written Code](https://lightmysky.com/learn/computing/weighted-models-learned-parameters-and-written-code-mt_3_1toZUxak)
- [Why a Chatbot Can Be Confidently Wrong](https://lightmysky.com/learn/computing/why-a-chatbot-can-be-confidently-wrong-mt_TMHNkprrks)
