Skip to content

How AI works

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

About 15 minutes. No account, no install, no coding.

Interpreting time-series traces and linking evidence to corrective actions.
Lab Demonstration II
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. 1
  2. 2
  3. 3
  4. 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.

  1. Press Play again on the board and watch it through.

    What you should see

    The sentence types in, five bars grow, and the top word, “mat”, lands at the end of the sentence.

    I see something else
  2. Choose “roof”, the word with the shortest bar.

    What you should see

    The sentence now ends with “roof”. An unlikely word can still be picked. It just happens less often.

    I see something else
  3. Choose a different word.

    What you should see

    The sentence changes again. Same start, different ending. That is the little bit of chance at work.

    I see something else
From our slide deck: How large language models workSee this step by step in our slide deck

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.

Practice chat
You

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.

  1. Step 1 of 4. Ask something that has no single right answer.

    You

    Suggest one name for a pet goldfish.

  2. Step 2 of 4. The reply is built one small piece at a time.

    AI

    How about Bubbles?

    Example. Your wording will differ.
  3. 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.
    You

    Suggest one name for a pet goldfish.

  4. Step 4 of 4. A different answer. Nothing is broken. A different piece was picked along the way.

    AI

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

From our slide deck: How large language models workSee how text is split into tokens

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

  1. 1You: My dog is called Biscuit. She is two.
  2. 2AI: Biscuit is a lovely name.
  3. 3You: What trick could I teach her first?
  4. 4AI: You could teach Biscuit to sit.
  5. 5You: And after that one?
  6. 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

  1. Press New chat on the sheet above.

    What you should see

    The page is wiped clean. The dog's name is gone, because the page was the only place it was kept.

    I see something else
  2. Press Add the next message a few times.

    What you should see

    The page fills up again, one line for each message. Each new reply can use every line above it.

    I see something else

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

Nothing you type here is sent anywhere.

Chapter 1

Check yourself

Question 1 of 4

What does a chat AI do, in one sentence?

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

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

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

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

  1. 1A chat AI predicts the next small piece of text, then does it again. Every answer is built that way.
  2. 2A little chance in each pick is why the same question can get different answers.
  3. 3It can be wrong and sound sure, its knowledge has an end date, and what it reads is the conversation so far.

Saved in this browser only.

Where this comes from

Checked on November 25, 2026.

Tools, prices and rules change. These are the official pages we read on that day. If a page and this guide disagree, trust the page.

Seen something that has changed? Tell us: