🧭 Guides

How AI chatbots actually work: training, tokens, prediction and why they make things up

A plain language guide to large language models: how chatbots are trained, what tokens are, how they predict each word, and why they sometimes give confident answers that are wrong.

Guides: How AI chatbots actually work: training, tokens, prediction and why they make things up

In short

An AI chatbot such as ChatGPT, Gemini or Claude runs a large language model (LLM). It was trained on enormous amounts of text to do one core job: predict the next small piece of text, called a token. When you ask a question, it writes the answer one token at a time, each time choosing a likely next piece.

That is why chatbots sound fluent and often get things right, and also why they sometimes make up confident answers that are wrong. The model is producing likely text, not checking facts. OpenAI's own researchers say training and testing methods tend to reward guessing over admitting "I don't know."

The practical rule: use chatbots to explain, draft and brainstorm, and check any specific fact (a name, number, date, quote or source) before you rely on it.

Step 1: Training, or learning from a mountain of text

A language model starts as a huge set of numbers, called parameters, set more or less at random. Training adjusts those numbers.

Pretraining is the big first stage. OpenAI describes it as predicting the next word in huge amounts of text. The model is shown a passage with the next piece hidden, guesses it, and is nudged toward the right answer. Repeat that across a vast amount of text and the model gradually absorbs grammar, facts that appear often, styles of writing and patterns of reasoning.

Importantly, OpenAI notes there are no "true" or "false" labels in this stage. The model only sees examples of fluent language. It learns what text usually looks like, which is not the same as learning what is true.

Fine tuning comes next. Developers train the model further on examples of good conversations and on feedback about which answers people prefer. This is what turns a raw text predictor into a helpful assistant that answers questions, follows instructions and declines some requests.

The result is a fixed model. It does not keep learning from each chat in real time. Some apps add a separate memory feature or let you choose whether your chats help train future models; our tips on what your chatbot remembers and whether your chats are used for training show where those settings live.

Step 2: Tokens, the pieces a model reads and writes

Models do not read letters or whole words the way we do. They split text into tokens. OpenAI's Help Center says a token can be a character, part of a word, a whole word or punctuation, and that spaces and capital letters can change how text is split.

For English, OpenAI gives these rough rules of thumb:

Measure Rough equivalent
1 token About 4 characters
1 token About three quarters of a word
100 tokens About 75 words

Other languages can split very differently. Tokens matter to you in two ways:

  • Limits. Each model has a context window, the maximum number of tokens it can work with at once. Very long documents or chats may be cut off or summarized.
  • Odd mistakes. Because a model sees chunks rather than letters, tasks like counting letters in a word or spelling backward can trip it up.

Step 3: Prediction, one token at a time

When you send a message, the chatbot turns your text into tokens and feeds them through the model. The model outputs a probability for every possible next token: perhaps "Paris" is very likely, "Lyon" much less likely, and so on. The app picks one, adds it to the text, and repeats. A long answer is hundreds of these tiny predictions in a row.

The design behind almost all modern chatbots is the Transformer, introduced in the 2017 research paper "Attention Is All You Need". Its key idea is attention: when predicting the next token, the model can weigh which earlier words in the conversation matter most. That is how it keeps track of what "it" refers to, or connects your question to an instruction you gave three paragraphs earlier.

A small amount of randomness is usually added when choosing each token. That is why asking the same question twice can give different wording, or occasionally a different answer.

Newer "reasoning" models

Some recent models produce internal reasoning tokens before the visible answer. OpenAI's Help Center notes these hidden tokens still count toward usage. Working through a problem step by step tends to help with maths, logic and planning. It is still prediction underneath, so it reduces errors without removing them.

What a chatbot is, and what it is not

It helps to compare a chatbot with tools you already know:

Tool How it answers What that means for you
Search engine Finds existing pages and shows you links You can see where information came from
Database or spreadsheet Looks up a stored value The same question gives the same answer
Chatbot (LLM) Generates new text from learned patterns Answers are fluent and flexible, but not looked up or guaranteed

A language model does not contain a neat list of facts it can consult. What it learned is spread across billions of numbers as patterns. That is what lets it do things nobody explicitly taught it, such as rewriting an email in a friendlier tone, explaining a concept for a child, or turning notes into a table. It is also why it cannot always tell you where a fact came from.

Many chatbot apps now add tools around the model: web search, file reading or memory. These feed extra text into the model's context window, so it can work with information from outside its training. The model still writes the answer by prediction, which is why it can misquote a page it has just read.

Why chatbots make up confident answers

When a chatbot states something false as if it were fact, people call it a hallucination. OpenAI defines hallucinations as plausible but false statements. Its September 2025 research paper gives two main reasons they happen.

1. Some facts cannot be learned from patterns. Spelling and grammar follow consistent patterns, so models rarely get them wrong. But a rare, arbitrary fact, such as a specific person's birthday or the exact title of an obscure report, appears too seldom in training text to be predicted reliably. OpenAI compares it to guessing a pet's birthday from its photo: no amount of skill makes that reliable. The model still produces something that looks like a right answer.

2. Training and testing reward guessing. OpenAI compares it to a multiple choice exam with no penalty for wrong answers. A student who guesses will score better on average than one who leaves blanks. If AI models are graded mainly on accuracy, they learn that a confident guess beats "I don't know."

OpenAI illustrates this with one of its own tests. An older model answered more questions and got slightly more right, but its error rate was far higher, because it rarely abstained:

Model (OpenAI SimpleQA test) Said "I don't know" Right Wrong
gpt-5-thinking-mini 52% 22% 26%
OpenAI o4-mini 1% 24% 75%

OpenAI's researchers argue that hallucinations are not inevitable, because models can be trained to hold back when unsure, and that benchmarks should penalize confident errors more than honest uncertainty. OpenAI says its newer models hallucinate less, but it also says hallucinations remain a fundamental challenge for all large language models.

When to be most careful

Hallucinations are most likely with:

  • Specific details: exact dates, numbers, prices, statistics and quotes.
  • Citations and links: invented article titles, court cases or URLs that look real.
  • Niche or recent topics: things that appear rarely in training data or happened after it.
  • Questions about real people, especially less famous ones.

They are less likely when you give the chatbot the source material yourself, for example by pasting a document and asking for a summary, though even then it can misread or overstate.

How to use chatbots well

  • Treat answers as a draft or a starting point, not a final source.
  • Ask for sources, then open them. Check that the page exists and actually says what the chatbot claims.
  • Verify names, numbers, dates and quotes against an official or original page.
  • Give context. Paste the relevant text and ask the chatbot to answer only from it.
  • Invite uncertainty. Saying "tell me if you are not sure" can help.
  • Get a professional for high stakes questions about health, money or the law.
  • Protect your privacy. Do not paste passwords, ID numbers or sensitive personal data. For families, see parental controls for AI chatbots.

Common mistakes

  • Assuming confidence means correctness. The tone of an answer says nothing about whether it is true.
  • Trusting a citation without opening it. Made up references are a classic hallucination.
  • Thinking web search removes all errors. A chatbot that searches can still pick a poor source or misread a good one.
  • Believing the chatbot learns from your corrections in real time. Usually it does not, beyond the current chat or an optional memory feature.

Where to go next

To see how today's leading models from Google, OpenAI and Anthropic compare, read our guide to the newest AI models. For why AI features often run on special chips, see CPU vs GPU vs NPU.

Frequently asked questions

How does an AI chatbot like ChatGPT work?

It runs a large language model: a program trained on huge amounts of text to predict what comes next. When you type a question, the model breaks it into tokens and generates an answer one token at a time, each time picking a likely next piece based on patterns it learned in training.

What is a token in AI?

A token is the unit of text a language model reads and writes. It can be a whole word, part of a word, a character or punctuation. OpenAI says that in English one token is roughly four characters, or about three quarters of a word.

Why do AI chatbots make things up?

They are trained to produce fluent, likely text, not to check facts. OpenAI's researchers argue that common training and testing methods reward guessing over admitting uncertainty, so a model may give a confident answer instead of saying it does not know. Rare facts, like a specific date or citation, are the most likely to be wrong.

Does an AI chatbot understand what it says?

Researchers disagree about what to call it, but the mechanism is pattern based prediction learned from text, not looking up facts in a verified database. That is why chatbots can explain ideas well and still get a simple fact wrong.

How can I check if a chatbot's answer is right?

Ask for sources and open them, check names, numbers, dates and quotes against an official or original page, and be extra careful with health, money and legal questions. If the chatbot can search the web, it can still misread a page, so check the page yourself.

Sources

  1. OpenAI: Why language models hallucinate
  2. arXiv: Why Language Models Hallucinate (Kalai et al., 2025)
  3. OpenAI Help Center: Understanding and counting tokens
  4. arXiv: Attention Is All You Need (Vaswani et al., 2017)