Inside the Chatbot
How a language model turns your message into an answer
Your mission
Send a message to an AI assistant and follow it inside: watch it split into tokens and numbers, pass through the model, and come back one predicted token at a time. Then run your own tokenizer, build sentences from next-token probabilities, and see attention connect the words.
Explore
Send the message and follow it through all five steps, then look closely at a token.
- 1User prompt
- 2Tokenization
- 3Model processing
- 4Token generation
- 5Final response
All token IDs, vectors and probabilities in this game are illustrative, not values from a real model.
What really happens when you send a message to an AI assistant? A large language model follows a sequence of computational operations. Press Send the message and follow it, step by step.
0 of 7 discoveries made
Experiment
Tokenize your own text, build sentences from next-token probabilities, and watch attention link the words.
Chatbot experiments
Try each one. They tick themselves off.
0 of 6 experiments done
Challenge
Six messages: count tokens, predict the next token, order the steps, and sort predictive from generative AI.
Chatbot cheat sheet
- Prompt → tokens → model → tokens → response
- Token: a word, part of a word or punctuation
- Token ID: a number; embedding: a vector of numbers
- The model predicts the next token, again and again
- Attention links words that belong together
Finish all 6 messages to finish this stage.
Understand
Here is what the chatbot was showing you, in the words you need for the exam.
What is generative AI?
Generative AI refers to AI systems designed to create content based on patterns learned from training data: text, images, music and speech, videos and animations, computer programs and code.
| Traditional predictive AI | Generative AI |
|---|---|
| Recognises a cat in an image | Generates a new image of a cat |
| Predicts which videos you will enjoy | Creates a video from a description |
| Classifies a message (e.g. spam or not spam) | Writes a new message |
Generative AI produces new content, while many other machine-learning systems focus on classification or prediction.
Large language models
A large language model (LLM) is a machine-learning model, typically based on a large neural network, trained to process and generate language. LLMs answer questions, summarise documents, translate, explain concepts, generate code and write text. They are the models behind ChatGPT and other AI assistants.
LLMs learn statistical patterns and relationships in language from large amounts of training data.
Text as numbers
Computers can't directly perform neural-network calculations on written words. So the text is divided into tokens (tokenization). A token may be a whole word, part of a word, or punctuation; the exact division depends on the tokenizer.
Each token gets a numerical token ID, and the model uses learned embeddings to represent tokens as numerical vectors (a vector is a collection of numbers), so it can do mathematical operations and learn relationships among tokens.
Generating text, token by token
Many LLMs are trained using next-token prediction. The model analyses the available context and estimates probabilities for possible next tokens ("The sun rises in the …": east, morning, sky…). It selects a token according to its generation procedure and repeats the process, building a response token by token.
Transformers and attention
A Transformer is a neural-network architecture widely used in modern LLMs. One of its most important components is the attention mechanism, which lets the model combine information from different tokens. In "Sarah put her laptop on the desk because it was overheating", the model must connect "it" with "laptop". Transformers process contextual relationships rather than treating each token independently.
What happens when you send a message?
- 1User prompt: you enter a question or instruction.
- 2Tokenization: the text is divided into tokens.
- 3Model processing: the neural network (a Transformer) processes the available context.
- 4Token generation: the model generates an output sequence.
- 5Final response: the generated tokens are converted into readable text.
Some AI assistants can also use external tools to retrieve information, run programs, access data or perform actions. Generating a response and performing an action are different capabilities.
Beyond chat: vibe coding and AI agents
Vibe coding: users describe what they want in natural language, and generative AI produces or modifies the code (describe → AI generates → run → describe changes → AI modifies). Understanding, testing and verifying the software remain important.
An AI agent uses an AI model and available tools to carry out steps toward a goal. Its parts: the AI model, a goal and instructions, tools, feedback, and permissions and guardrails. A chatbot gives answers; an agent can plan, act, check results and continue, within its permissions.
Can AI make mistakes?
Yes. Common limitations: hallucinations (convincing but incorrect information), bias, outdated knowledge, reasoning errors and security vulnerabilities. Intelligent-looking behaviour does not guarantee accuracy, reliability or safety.
Use AI responsibly: verify important claims, protect privacy, understand AI-generated code, keep human oversight of agents, and think independently. The person using an AI system remains responsible for its outputs and actions.
Words to know
- Generative AI
- AI that creates new content from patterns learned in training data.
- LLM
- A large language model: a large neural network trained to process and generate language.
- Token
- A unit of text: a whole word, part of a word or punctuation.
- Token ID
- The number assigned to a token.
- Embedding
- A learned vector of numbers that represents a token.
- Next-token prediction
- Estimating the probabilities of possible next tokens from the context.
- Transformer
- A neural-network architecture used in modern LLMs.
- Attention
- Lets the model combine information from different tokens in the context.
Exam tip
To explain how a chatbot answers, list the five steps in order: prompt → tokenization → model processing → token generation → final response, and stress that the model generates its answer one token at a time by predicting probable next tokens from the context. Mention that text must become numbers (token IDs and vectors) first, and that a fluent answer can still be wrong.