How do AI chatbots like ChatGPT and Claude actually work?
1 Answer
At the heart of every modern AI chatbot is a large language model, often shortened to LLM. The basic job of that model sounds almost too simple: given some text, predict what word should come next.
The model learns this during a stage called pre-training. It is shown a massive amount of text, including books, websites, articles and code, and it practises predicting the next word over and over, billions of times. Every time it guesses wrong, its internal settings are adjusted slightly. After enough practice, it has absorbed grammar, facts, writing styles, reasoning patterns and even some programming knowledge, all stored as numbers inside a neural network.
Technically, the model works with tokens rather than whole words. A token is a piece of a word, so "unbelievable" might be split into "un", "believ" and "able". The model reads your message as a sequence of tokens and produces its reply one token at a time, each time choosing a likely next piece based on everything before it.
A model that has only been pre-trained is good at continuing text, but it is not yet a helpful assistant. So companies add a second stage of training. They show the model examples of good conversations and use human feedback to rate answers, rewarding responses that are helpful, accurate and safe. This is what turns a raw text predictor into something that answers questions, follows instructions and politely declines harmful requests.
When you type a question, the chatbot sends your message, the earlier conversation and some hidden instructions from the company to the model. The model then generates its reply token by token, which is why you often see the text appear gradually on screen.
Many chatbots now have extra tools around the model. They can search the web, read uploaded files, run code or remember preferences. The model decides when to use these tools, and the results are fed back into its response.
This design explains both the strengths and weaknesses you notice. The chatbot writes fluently because it has seen so much language. But it can also produce confident mistakes, called hallucinations, because it is generating the most likely-sounding answer rather than looking up a verified fact. That is why it is smart to check important details, especially numbers, dates and quotes.