Free guide

How do AI chatbots work? Your question, step by step

AI chatbots work by predicting text one small piece at a time. Your message is split into tokens, wrapped with hidden instructions and the conversation so far, and passed to a model that guesses the next piece over and over until the reply is done. Here is each step in order, with no maths.

Verified 27 Sep 2026 3 live tool facts · How this is maintained


You type "why won't my sourdough rise" into a chatbot, press enter, and a tidy paragraph starts appearing word by word. Between those two moments a lot happens, and none of it involves the chatbot finding your question in a book of stored answers. This page follows one message through each step, in the order it happens, with what you see on screen at each point.

How do AI chatbots work, in one paragraph

AI chatbots work by predicting text. Your message is cut into small pieces called tokens, joined to some hidden instructions and the conversation so far, and passed to a large language model. The model has learned, from a vast amount of text, which piece tends to come next. It picks one, adds it to the end, and repeats until the reply is finished. Everything below is detail on those steps.

Step one: your words become tokens

The first thing that happens to your message is that it stops being words. A tokeniser chops it into tokens: often whole short words, sometimes parts of longer ones, sometimes punctuation. "Sourdough" might become two or three pieces. Each token is then turned into a list of numbers the model can work with.

What you see: nothing yet. Why it matters: tokens are the unit everything is counted in. Usage limits, how long a conversation the model can hold, and the bill a developer pays are measured in tokens, not words. Our guide to tokens and costs goes further.

Step two: hidden text joins your message

Your question never travels alone. Before it reaches the model, the chatbot wraps it in other text:

All of that has to fit in the context window, the most text the model can consider at once. In a very long chat, the oldest material can drop out of view or be squashed into a summary. That's why a chatbot sometimes forgets a detail you gave it an hour ago.

Step three: the model scores every possible next token

Now the model does its one trick. It looks at every token in the window and works out how likely each possible next token is. It doesn't consult a list of facts. What it has is a huge set of numbers, called weights, adjusted during training until its predictions matched the patterns in its training text.

Training happened long before you opened the app, in two broad stages. Pretraining on general text taught it language and a great deal about the world. Further training on examples of helpful replies, and on people's ratings of replies, shaped it into something that answers like an assistant rather than just carrying on your sentence.

Two consequences follow. Its knowledge has an end date, the knowledge cutoff, and it knows nothing after that unless something fetches newer information. And it has no separate sense of whether a sentence is true; a wrong date can score as highly as a right one.

Step four: one token is picked, and the loop goes round

The model hands back likelihoods, not a word. The chatbot then picks one token, usually from among the likely ones, with a little randomness allowed in. A setting called temperature controls how much. The chosen token is added to the end, and the whole lot goes round again to predict the token after it.

What you see: the reply appearing piece by piece. That streaming isn't decoration; the rest of the answer genuinely doesn't exist yet when the first words show. The randomness is also why answers differ each time you ask.

StepWhat happensWhat you see
1Your message is split into tokensNothing yet
2System prompt, history and attachments are addedNothing yet
3The model scores every possible next tokenA brief pause
4One token is picked and added, then repeatWords streaming in
5Sometimes a search or tool runs mid-answer"Searching", or a list of sources
6Safety checks and formattingThe finished reply

Step five: sometimes it fetches something first

Many chatbots can now step outside the model. When a question needs fresh information, the model can produce a request instead of an answer: search the web, read a file, run a calculation. The chatbot carries that out, puts the results into the context window, and the model carries on predicting with those results in view. Answers with source links are usually built this way.

The prediction step hasn't changed, though. A chatbot can cite a real page and still summarise it wrongly. Search-led tools say as much about themselves. Perplexity's strength, as its fact sheet puts it: Web answers with clickable sources✓. Its caution: Cited answers can still be wrong: open the sources✓.

Step six: what happens to your words afterwards

The reply arrives, but your message may not be finished with. Depending on the tool, the type of account and your settings, conversations can be kept and used to improve later models. For ChatGPT: Consumer chats can be used to improve models unless you turn it off in Data Controls; Business, Enterprise and Edu are excluded✓. That isn't part of how the answer was made, but it is part of what happens when you type. Check the settings on whichever tool you use, and keep private details out of a personal account.

Odd chatbot behaviour, explained by the steps

Once you know the sequence, the strange moments stop looking mysterious.

  1. A confident wrong answer comes from step three: likely-sounding text isn't always true text.
  2. An out-of-date fact is the knowledge cutoff, when no search ran in step five.
  3. Forgetting what you said earlier is a full context window in step two.
  4. A different answer to the same question is the randomness in step four.
  5. Agreeing with you too readily comes from training that rewarded replies people liked.

Seeing the steps for yourself in a lesson

Reading about tokens only gets you so far. In Teach me AI's lessons, ideas such as tokens, training and context windows come with step-through interactive explainers: you move through each stage yourself rather than reading a paragraph about it. Diagrams are made to read on a phone and are described in words for screen readers.

The ideas sit mainly in What AI actually is and How machines learn, at level I, and How large language models work, at level III, for anyone who wants the mechanics properly. You can open a complete sample lesson with no account to see how it feels, and interactive explainers shows what the step-throughs cover. The free placement works out where you'd start, and an honest beginner finishes it fastest.

Who this won't suit: if you want the maths, attention written out as equations, or code to train a model of your own, a beginner walkthrough isn't the right page. A university course or a technical textbook will serve you better.

Five minutes to watch it happen

Open any chatbot you can use and try this:

Explain in three short sentences what a knowledge cutoff is. Then tell me your own knowledge cutoff, and how confident you are about it.

Then, in the same tool:

Common questions

Does a chatbot learn from me while we're talking?

Not in the moment. The model's weights don't change during your chat; it only seems to learn because your earlier messages are resent with each new one. Separately, depending on the tool and your settings, your conversations may be used later to train future models. That's a setting worth checking.

Why do different chatbots give different answers to the same question?

Each one runs a different model, trained on different text in different ways, with its own hidden instructions from the company that runs it. Some search the web and some don't. Even one chatbot can answer the same question differently twice, because a little randomness is allowed when it picks each next piece of text.

Does a chatbot understand what I'm saying?

It handles meaning well enough to be useful: it can follow an instruction, notice a contradiction and change its tone. Whether that counts as understanding is a debate among researchers. For practical purposes, treat it as a very capable text predictor that has no experience of the world and no way to know when it is wrong.

How do AI chatbots work without an internet connection?

The model itself doesn't need the internet to produce text; everything it learned is stored in its weights. Most consumer chatbots still need a connection because the model runs on the company's computers, not your phone. Without a search step, it can only draw on what it learned before its knowledge cutoff.

Go deeper

Modules that teach this properly

More on this

Learning AI

Every guide on this topic →

Next step

Find out where you actually stand

A short placement assessment scores you across five skill areas and builds a path through our 18 released modules, skipping whatever you already know. No card needed.

Find your level
When this changes

The facts on this page are re-checked on a schedule. One email a month says what moved in AI tools and the rules, and what it means for you.

Once a month. We’ll email you a link to confirm, and every issue has a one-click unsubscribe. How we use your address.