How Chatbots Like ChatGPT Work: Predicting the Next Word, Billions of Times
A large language model does not look up answers. It predicts the next piece of text. Understanding this one idea explains both its strengths and its mistakes.
Chatbots can write emails, explain science, and fix code. It feels like talking to a person who knows everything. Under the hood, the idea is surprisingly simple, and knowing it makes you a much smarter user.
The core idea
A large language model (LLM) is trained to do one thing: predict what text is likely to come next. If you write "The capital of France is", the most likely next word is "Paris". Do this repeatedly, one small piece at a time, and the model can write whole paragraphs.
The steps behind it
Collecting huge amounts of text
The model is trained on books, websites, code, and other writing. It learns patterns in how language works.
Breaking text into tokens
Text is cut into small chunks called tokens, which can be a word or part of a word. The model works with tokens, not letters.
Learning patterns
During training, the model plays a huge game of "guess the next token" and gets adjusted each time it is wrong. Over time, it learns grammar, facts, styles, and reasoning patterns.
Fine-tuning with human feedback
People rate answers, and the model is adjusted to be more helpful, polite, and safe.
Generating a reply
When you ask a question, it predicts one token at a time, building its answer, using your whole conversation as context.
Why it can feel smart
Language contains a lot of human knowledge. To predict the next word well across billions of examples, a model has to pick up facts, logic, and writing styles. That is why it can summarise, translate, and explain.
Why it makes mistakes
- It does not check facts in a database by default. It generates what sounds right.
- Its knowledge stops at a training cutoff date, unless it is connected to search tools.
- It can be thrown off by unclear questions.
- It can reflect biases in its training data.
The "context window"
A model can only "remember" a limited amount of text in a single conversation, called the context window. If a chat goes on very long, earlier details may be lost. Starting a new chat for a new topic often gives better answers.
What most people miss
- It does not learn from your chat in real time. A normal chat does not permanently update the model.
- Different models are good at different things. Some are better at code, others at writing or images.
- Your conversations may be stored. Check privacy settings and do not paste secrets such as passwords or confidential documents.