Remember word suggestions on your phone’s keyboard? You type “good” and your phone offers “morning”. The language models behind chatbots work on a similar principle, just on a gigantic scale. That simple idea, taken very far, explains both what they’re surprisingly good at and why they sometimes make things up.
Predicting the next piece of text
A language model learns from huge amounts of text: books, websites, articles, code. During training it solves one task over and over: guess what comes next. Every time it gets it wrong, its internal settings (called parameters) are nudged a tiny bit. After billions of attempts, the model starts to “get” grammar, style, facts and the links between ideas.
Why does guessing the next word teach so much? Because to guess well, you need to understand a lot. To finish the sentence “The capital of France is…”, you need a fact. To finish a joke, you need to understand humour. To continue a piece of code, you need to know how programming works. The model is never taught these things directly. They emerge because they help with guessing.
The largest models have hundreds of billions of parameters. You can think of them as an enormous number of tiny knobs, which together hold everything the model has absorbed. Nobody sets them by hand. They’re adjusted automatically during training, which takes months on thousands of specialised computer chips.
Tokens, not words
The model doesn’t read letters or whole words, but tokens: chunks of text. A common word might be a single token, while a rare one gets split into several pieces. In English, a token is on average about three quarters of a word. Languages like Polish usually need more tokens for the same text, because the words have many forms.
This explains some strange failures. Ask a model how many letters “r” are in a word, and it may get it wrong. It doesn’t see individual letters, only chunks, so counting them is surprisingly hard for it.
The answer is built token by token, and each new one is chosen based on everything that came before. That’s why answers appear gradually on the screen: the model really is writing them one piece at a time.
How the model “pays attention”
The big breakthrough came in 2017, when researchers at Google described a design called the transformer. Its key idea is called attention. When the model chooses the next token, it can look back at every earlier part of the text and decide which parts matter most right now.
Take the sentence: “The trophy didn’t fit in the suitcase because it was too big.” What does “it” mean? Attention lets the model connect “it” with “trophy” rather than “suitcase”. Older systems struggled with this kind of connection, especially over long texts.
Almost all of today’s well-known chatbots are built on this idea. ChatGPT, released at the end of 2022, made it famous far beyond the tech world.
Why the same question gets different answers
At each step, the model doesn’t pick one certain word. It calculates how likely each possible next token is. Then it chooses, with a bit of randomness. Usually it picks a likely one, but not always the most likely.
That’s why you can ask the same question twice and get two different answers. A little randomness makes the text sound more natural and less repetitive. Too much, and it becomes chaotic.
Where does the “conversation” come from?
A text predictor on its own isn’t an assistant yet. If you gave it a question, it might simply continue with more questions, as if writing a list. After the basic training, models are taught further using examples of good answers and ratings from people. That’s how they learn to answer questions, follow instructions and, at least in principle, turn down harmful requests.
The model also has a limited “working memory”, called the context window. It’s the amount of text it can take into account at once: your messages, its answers, and any documents you’ve pasted. Modern models can handle very long texts, but anything outside that window is forgotten.
Why it makes things up
A model is trained to produce text that sounds right. Most of the time, sounding right and being right go together. But when the model doesn’t “know” something, it doesn’t stop. It produces the most plausible-sounding answer, which can be a book that doesn’t exist, a wrong date or an invented quote. These are called hallucinations.
Newer systems reduce this by letting the model search the internet or check documents before answering, and by training it to admit when it isn’t sure. But the problem hasn’t disappeared.
Worth remembering
- A model can be wrong with total confidence. It sounds sure even when it’s making things up.
- Its knowledge has an expiry date. The model knows the world up to the end of its training, unless it has access to search.
- It doesn’t remember you between conversations unless the app has a separate memory feature.
- Don’t paste secrets. Depending on the service and settings, what you type may be stored or used to improve the model.
- It’s a tool, not an oracle. It works best as a helper whose work you double-check.
Frequently asked questions
Does AI understand what it writes?
That’s a question even experts argue about. The model clearly captures a lot of meaning, otherwise it couldn’t answer complex questions. But it doesn’t experience the world, and its “understanding” works very differently from ours.
Does it copy text from the internet?
Usually not word for word. It learns patterns from texts, not a database of copies. It can, however, reproduce very well-known passages that appeared many times in its training data.
Why is it good at writing but bad at maths?
Writing is exactly what it was trained for. Calculations require precise steps, while the model works by guessing likely text. That’s why many assistants now use a built-in calculator or run code for maths.