A chatbot doesn't "know" the answer to your question the way a person does. It's predicting the most likely next word, one at a time, based on patterns learned from an enormous amount of text. Here's what's really happening behind the reply.
A large language model (LLM) is the technology behind modern AI chatbots — it is, at heart, a very large version of the prediction idea from the machine learning article in this series, applied to text. Given some text, it predicts what word is most likely to come next. Repeated over and over, one word at a time, that simple prediction is enough to write essays, hold conversations, and answer questions.
Underneath a chatbot's reply is a model trained on an enormous amount of text — books, articles, websites, and more — learning to predict, for any given piece of text, what word (or part of a word) is statistically most likely to follow. That's the entire task the model is trained on. It never explicitly "knows" facts the way a person does; it has learned extremely detailed patterns about which words tend to follow which other words, across a staggering range of topics and contexts.
This is the same prediction loop from the house-price example in the previous article — predict, compare to the real answer, adjust — just scaled up enormously and applied to text instead of numbers, with the "answer" being the next word in billions of real sentences instead of a house price.
Models don't work with letters and words directly — they work with numbers. Text is first broken into pieces called tokens, which might be a whole word, part of a word, or a punctuation mark, and each token is converted into a number the model can process mathematically.
Notice that "rewarding" was split into two tokens. Breaking uncommon or longer words into smaller familiar pieces lets a model handle new or rare words it hasn't seen as a whole, by combining tokens it already recognises.
When a chatbot writes a response, it isn't planning the whole sentence in advance. It predicts one token at a time: given everything written so far, it calculates a probability for every token in its vocabulary, picks one (usually the most likely, sometimes with a bit of randomness for variety), adds it to the text, and repeats the entire process again for the next token.
This process, repeated hundreds of times for a long reply, is why longer responses take visibly more time to generate than short ones — the model is genuinely doing the same prediction step over and over, token by token.
Predicting the next word well requires understanding context — in the sentence "The trophy didn't fit in the suitcase because it was too big," knowing whether "it" refers to the trophy or the suitcase requires weighing the whole sentence, not just the words immediately before "it." LLMs use a mechanism called attention, part of an architecture called the Transformer, which lets the model weigh the relevance of every earlier token against every other token when producing its prediction — effectively letting it "focus" more on the words that matter most for the current decision, regardless of how far back they appeared.
This is the same layered, weighted structure introduced with neural networks in the previous article, adapted specifically to handle the order and relationships within language rather than fixed lists of numbers.
Building a modern chatbot generally happens in two broad stages:
Pretraining is what gives a model its broad knowledge and fluency; fine-tuning is what shapes it into something that behaves like a helpful assistant rather than simply continuing text in any direction.
Understanding an LLM's real limitations is essential to using one responsibly.
When a chatbot helps debug code, summarise an article, or draft an email, it is applying the exact same next-token prediction process described above — just guided by a prompt that steers which patterns from its training are most relevant to continue.
A large language model can feel like it's "thinking," but underneath every reply is the same mechanical loop: turn text into tokens, predict the most likely next token using patterns learned from enormous amounts of training text, add it, and repeat. It's a remarkable amount of capability to emerge from one repeated step — and understanding that step is what lets you use these tools well, instead of trusting them blindly.
10 questions. Select an answer for each, then submit to see your score instantly.