How AI works
See the one move behind every chatbot answer, and why it can be wrong.

- Time
- About 15 minutes
- You do not need
- No account, no install, no coding.
- You need
- Nothing.
- You will be able to
- Say in one sentence what a chat AI does.
- Say why the same question can give different answers.
- Name three things it gets wrong.
One move, repeated
You do not need to know how to code. You do not need an account for this chapter. Everything happens on this page.
A chat AI is a program you talk to by typing. Inside it is something called a large language model. That is a long name for a simple job.
A large language model does one thing: it predicts the next piece of text. Every chatbot answer is built from that one move, repeated.
That goes for every chat tool in this guide, whoever makes it. Once you can see the one move, the rest of the guide makes sense.
So here is the whole idea in eight words. Predict the next word. Then do it again.
Watch it pick a word
The board says token. For now, read it as word. The number beside each word is its chance of being picked: 0.41 means about 41 times in 100.
Next-token prediction
- 0.41
- 0.18
- 0.11
- 0.07
- 0.04
Probabilities are illustrative.
Now you pick. Choose any of the five words.
- 1
- 2
- 3
- 4
The board shows the move once. The model reads “The cat sat on the”. It scores the words that could come next. One token is picked, usually a likely one, with a little randomness.
That little bit of chance is why the same question can get a different answer each time. It is not broken. It is how the picking works.
A full answer is this move done over and over, one small piece at a time, until the reply is finished.
Your turn: pick the word
Three small steps on the board above. Nothing is sent anywhere.
Press Play again on the board and watch it through.
What you should see
I see something elseThe sentence types in, five bars grow, and the top word, “mat”, lands at the end of the sentence.
Choose “roof”, the word with the shortest bar.
What you should see
I see something elseThe sentence now ends with “roof”. An unlikely word can still be picked. It just happens less often.
Choose a different word.
What you should see
I see something elseThe sentence changes again. Same start, different ending. That is the little bit of chance at work.
Same question, two answers
Here is what that chance looks like in a real chat. Play it, or step through at your own speed.
Step 1 of 4
Ask something that has no single right answer.
Suggest one name for a pet goldfish.
A practice chat we wrote. Nothing is sent anywhere. The replies are examples. Your wording will differ.
A practice chat we wrote. Nothing is sent anywhere. The replies are examples. Your wording will differ.
Step 1 of 4. Ask something that has no single right answer.
YouSuggest one name for a pet goldfish.
Step 2 of 4. The reply is built one small piece at a time.
AIHow about Bubbles?
Example. Your wording will differ.Step 3 of 4. Start a new chat and ask the very same thing.
The screen is cleared.
A new chat. The page is empty again.YouSuggest one name for a pet goldfish.
Step 4 of 4. A different answer. Nothing is broken. A different piece was picked along the way.
AIYou could call it Finn.
Example. Your wording will differ.
It reads in small pieces
We said “word”, and the board said “token”. A token is a small piece of text, often a whole word and sometimes part of one. Models read text as tokens. Common words are one token; rarer words are split into pieces.
For example, one way to split “Tokenization is fun” gives four pieces: Token, ization, is, fun. That split is only an illustration. Each model has its own way of cutting text up.
This is why a model can stumble on spelling or on counting the letters in a word: it never saw the letters, only the pieces.
How it learned to do that
Nobody typed the answers in. The model was trained, which means it practised on a huge amount of text until its guesses got good. It happened in three stages.
Pretraining
Learn to continue text from a huge collection of documents. The result is a base model: it completes documents, it does not answer questions.
Fine-tuning
Train further on example conversations written by people, so the model learns the shape of a helpful reply.
Feedback
People compare answers, and reinforcement learning pushes the model toward the ones they prefer.
Reinforcement learning is a kind of practice with a score. Answers people prefer score higher, and the model is adjusted to give more answers like those.
Notice that none of the three stages is a fact check. The model learns which text is likely. That is not the same as learning which text is true.
What it is not
A chat AI writes so smoothly that it is easy to trust too much. Three things to keep in mind every time you use one.
It is not a search engine
A language model does not look facts up unless it is given a tool such as search. It produces text that is likely, which is not the same as text that is true.
It can sound sure and be wrong
When it states something false with full confidence, that is called a hallucination.
Its knowledge has an end date
Its knowledge stops at the date its training data was collected. Check anything that matters.
Its working memory is one page
When you chat, the model does not only read your last message. It reads the whole conversation so far, every time, and then predicts what comes next.
Inside one conversation it can look back at what was said. That is all it has to go on. Start a new chat, and the page is empty.
Some tools now add a memory feature on top, which copies notes from your old chats onto the new page. ChatGPT has one (opens in a new tab). The model itself still only reads what is on the page.
That stretch of text has a name: the context window. The people who make Claude call it a working memory for the model, and describe it like this.
“the amount of text a language model can look back on and reference when generating new text”
One conversation: what the AI can look back on
- 1You: My dog is called Biscuit. She is two.
- 2AI: Biscuit is a lovely name.
- 3You: What trick could I teach her first?
- 4AI: You could teach Biscuit to sit.
- 5You: And after that one?
- 6AI: After sit, you could try stay.
Look at the last two lines. You only said “that one”, and the AI still knew you meant sit. It could look back up the page. The lines are an example we wrote.
Your turn: wipe the page
Press New chat on the sheet above.
What you should see
I see something elseThe page is wiped clean. The dog's name is gone, because the page was the only place it was kept.
Press Add the next message a few times.
What you should see
I see something elseThe page fills up again, one line for each message. Each new reply can use every line above it.
From talking to doing
Everything so far is about text going in and text coming out. On its own, that is all a model does.
Give the same model some tools, such as a way to read files or search the web, and it can do things as well as say things. Here is how the official Claude Code guide puts it.
“Without tools, Claude can only respond with text. With tools, Claude can act: read your code, edit files, run commands, search the web”
A model with tools, working in a loop, is called an agent. You meet one in chapter 7. The move inside it is still the one you just watched.
If something is confusing
We can only tell you what it does. It predicts likely text, one piece at a time. Likely is not the same as true.
It can still be very useful. Just do not treat its answers the way you would treat a teacher's or a textbook's.
Not unless it is given a tool such as search. Without one, it writes from what it learned in training, and that has an end date.
That is normal. One piece is picked each time with a little randomness, so two replies can differ.
If the two answers disagree on a fact, that is your signal to check the fact somewhere else.
Press Play again in the corner of the board. It also pauses when you scroll it off the screen.
If your device is set to reduce motion, the board shows its finished picture straight away and the button reads Show steps. Press it to go through one step at a time.
The words become buttons only after the board has played all four steps. Wait for the line “Now you pick”, then choose one.
No. The board says so itself: “Probabilities are illustrative.” They show the idea. A real model scores many thousands of pieces, not five.
Our slide deck goes further, with tokens, attention and training drawn step by step: open the slide decks.
For videos and courses we picked from other teachers, see Large language models.
Two official pages we used: the Anthropic glossary (opens in a new tab) and How Claude Code works (opens in a new tab).
Chapter 1
Check yourself
Question 1 of 4
What does a chat AI do, in one sentence?
What does a chat AI do, in one sentence?
- It looks every answer up in a database.
- It predicts the next piece of text, again and again.
- It copies answers from one website.
Show the answer
It predicts the next piece of text, again and again. Every answer is built from that one move, repeated.
You ask the same question twice and get two different answers. Why?
- It is broken.
- One piece is picked each time with a little randomness.
- Someone else is typing the replies.
Show the answer
One piece is picked each time with a little randomness. Usually a likely piece is picked, but not always the same one. So the reply can change.
Which of these can a chat AI get wrong?
- Facts, even when it sounds sure.
- Things that happened after its training data was collected.
- Both.
Show the answer
Both. It can state something false with full confidence, and its knowledge stops at the date its training data was collected.
You start a new chat and ask, “What was my dog's name?”, in a tool with no memory feature turned on. What is most likely?
- It tells you the name.
- It cannot tell you.
Show the answer
It cannot tell you. Its working memory is the conversation so far. A new chat has nothing in it yet. Tools with a memory feature can paste notes from old chats in, so yours may surprise you.
What you learned
- 1A chat AI predicts the next small piece of text, then does it again. Every answer is built that way.
- 2A little chance in each pick is why the same question can get different answers.
- 3It can be wrong and sound sure, its knowledge has an end date, and what it reads is the conversation so far.
Where this comes from
Checked on November 25, 2026.
Seen something that has changed? Tell us: