Explainer
How AI actually works

Most people now use a chatbot every day, and almost nobody has been told how it works. The explanations on offer are either “it’s magic” or a page of jargon. This is a plain account of what happens when you type into ChatGPT, Claude or Gemini, and of why the things that go wrong go wrong the way they do.
It predicts the next piece of text
A language model does one thing. Given some text, it works out which piece of text is likely to come next, adds it, and repeats. An answer of five hundred words is that step taken several hundred times.
It learned what “likely” means from an enormous amount of writing. Nothing in that training gave it a store of facts to look things up in. What it has is a very good sense of how text continues, good enough to explain a bug, translate a letter or draft a contract. That is also why a model can be fluent and wrong in the same sentence: fluency is what it was trained for, and being right usually comes with it, but not always.
Tokens, and the window they have to fit in
The pieces of text are called tokens. A token is often a whole word and often part of one: a common word such as “the” is a single token, while a long or rare word is cut into several (“tokenization” becomes something like “token” and “ization”). In English a token averages about four characters, or three-quarters of a word. Spanish, like most languages other than English, takes somewhat more tokens to say the same thing, so the same conversation costs a little more and fills the window a little sooner.
The window is the context window: the most tokens the model can take in at once. Everything has to fit in it together:
- the instructions the product gives the model before you arrive,
- the whole conversation so far,
- any documents or search results,
- the descriptions of any tools it can use,
- and the answer it is about to write.
A window of 200,000 tokens with 8,000 kept back for the answer leaves 192,000 for everything else.
Two things follow. Cost and speed are counted in tokens, so pasting a twenty-message email thread to ask one question means paying to have twenty signatures read. And the model has no memory outside the window. When a long conversation outgrows it, the product has to drop or summarise the oldest part, and that is usually what has happened when a chatbot “forgets” that you asked for answers in Spanish an hour ago. The other common cause is dilution: the instruction is still there, but forty thousand tokens have arrived since, and an instruction buried in the middle of a long context carries less weight than one at the start or the end.
Why it makes things up
Ask a model to summarise the cancellation policy in a document that has no cancellation policy, and it may well write one. The question implies that an answer exists, cancellation policies have a familiar shape, and producing familiar shapes is what the model does. This is called hallucination. It is the normal behaviour of a system that continues text, and it shows up where the text it was given runs out.
It happens most in three situations:
- the source is thin or badly extracted, such as a scanned PDF or a table flattened into one line;
- the question presumes something, such as “what were the three criticisms?” when the notes contain one;
- nothing in the request leaves room for “I don’t know”.
The most useful prompting advice follows from this, and it is to add constraints. “Summarise this document” invites the model to fill gaps. “Summarise this document in five points, using only what is in the text, and say so where the text doesn’t cover something” gives it a way out that doesn’t involve inventing anything. That will not make the model reliable, but it narrows the room for a plausible wrong answer.
What “memory” is
A model does not learn from your conversation. Its training ended before you opened the app, and nothing you type changes it.
If an assistant remembers that you run a bakery and like short answers, the product around the model saved that as a note and puts it back into the window at the start of each conversation, where it costs tokens like everything else. This is worth knowing for two reasons. In most products the notes can be read, edited and deleted. And it explains why the same model behaves differently in two apps: what differs is what each one puts in the window.
Reasoning models
Some models are sold as “reasoning” or “thinking” models, and they do better on problems with several steps: a calculation, a plan, a difficult bug. They are the same kind of system doing the same thing. The difference is that before answering they write out their working, in tokens you often don’t see, and then write the answer with that working in the window. Predicting the answer to a hard problem in one go is difficult. Predicting the next line of a worked solution is much easier.
That is also why they are slower and cost more. The working is output like any other: it takes time to write, it is billed, and it takes up room in the window. For “rewrite this email” it buys nothing. For “should I lease or buy, given these numbers” it is usually worth it.
Images, sound and documents
A multimodal model takes in more than text: a photo of a broken appliance, a screenshot of a spreadsheet, a voice note. Underneath, the same thing happens. The image or the audio is turned into tokens of its own kind and placed in the window beside the words, and the model continues from all of it together.
So the same failures apply. It can misread a number in a chart, miss small text in a photograph, or describe with confidence something that is not in the picture.
Search and tools
Two additions account for most of the difference between a model and a product built on one.
The first is retrieval. Instead of hoping the model remembers something, the product searches for it (the web, your files, a company’s help pages), puts the few most relevant passages in the window, and asks the model to answer from those. This is what “retrieval-augmented generation” means. It is cheaper than pasting in everything, and an answer drawn from a passage in front of the model is far less likely to be invented than one drawn from its sense of what is usual. It is only as good as the search: if the right passage isn’t found, the model is back to guessing, now with unrelated text in front of it.
The second is tools. A model cannot check the weather or send an email. It can write a request for one, in a format the product gave it:
{ "tool": "check_weather", "arguments": { "city": "Cartagena" } }
The product reads that, decides whether to run it, runs it, and puts the result back in the window for the model to carry on from. The model proposes and the software around it acts. That boundary is where permissions, spending limits and logs belong, which is why it matters who built the product and how carefully.
What to do with this
A chatbot is a system that continues text, inside a fixed window, with a product around it deciding what goes into that window. Most of what seems strange about one stops being strange with that in mind, and a few habits follow from it:
- Give it the source. An answer from a document you supplied is worth more than one from its general sense of things.
- Send less. Trim the thread, the signatures and the boilerplate before pasting.
- Leave room for “I don’t know”, and say that you want it.
- Start a new conversation when the subject changes. A long one is not a better-informed one.
- Treat confidence as style. It sounds exactly as sure when it is wrong.
- Use a reasoning model for problems with steps, and don’t pay for one otherwise.