How Does AI Predict Words?
AI language models work out which word is likely to come next, then pick one and repeat. Here is how that works, and why it can produce confident mistakes.
Finish this sentence: “The water of Walden Pond is so beautifully …” Most people would say blue, green or clear. Almost nobody would say refrigerator. You have just predicted a word, and a language model does something similar when it writes.
The short answer: An AI language model works out how likely each possible next word is, based on the words before it. It picks one of the likely words, adds it to the text, and repeats the process.[1][2] Because it works from likelihood rather than checking facts, it can sound confident and still be wrong.[3]
Guessing the next word
Stanford’s textbook Speech and Language Processing uses this same Walden Pond sentence to introduce the idea. It explains that “a language model is a machine learning model that predicts upcoming words.”[1] More precisely, it “assigns a probability to each possible next word.”[1]
The CSIRO, Australia’s national science agency, describes the same core idea. A large language model is “at its core making a prediction about what word comes next,” and “that prediction is typically probabilistic.”[2]
An everyday comparison: a phone keyboard that suggests a next word is making a small version of the same kind of guess. This is an analogy to help picture the idea, not a description of how any particular keyboard is built.
What a probability means
A probability is a number that shows how likely something is. The textbook explains the idea with counting. To estimate the chance that blue follows “The water of Walden Pond is so beautifully”, you could look through a large collection of text and ask: “Out of the times we saw the history h, how many times was it followed by the word w.”[1]
Here is a small invented example. It is a hypothetical example with made-up counts, not real data. Imagine a tiny collection of ten sentences that start “The sky is”. Suppose six of them continue with blue, two with grey and two with pink. The probabilities are then:
- blue: 6 out of 10, or 0.6
- grey: 2 out of 10, or 0.2
- pink: 2 out of 10, or 0.2
The three probabilities add up to 1. A real model works with far more text and far more words, but the idea of counting how often each word follows is the same.

Why the words before matter
Predicting well depends on the words that come before. The textbook calls the simplest version a Markov assumption: “The assumption that the probability of a word depends only on the previous word is called a Markov assumption.”[1] A model that uses only the last word is very limited. A model that looks back over several words can make better guesses about what fits.
NIST, the United States National Institute of Standards and Technology, describes modern generative AI in the same way: “LLMs predict the next token or word in a sentence or phrase.”[3]
Did you know? Even a huge collection of text cannot cover every possible sentence. The textbook says that “even the entire web isn’t big enough to give us good estimates for counts of entire sentences,” because “language is creative; new sentences are invented all the time.”[1]
One word at a time
Writing a sentence with a language model is a loop. The model looks at the text so far, works out which words are likely next, picks one, adds it to the text, and then does the whole thing again.
Georgetown’s Center for Security and Emerging Technology notes that “LLMs work by receiving an input or prompt, calculating what is most likely to come next.”[4] It adds that “one of the highest probability words is picked to continue the text.”[4] The choice is not always the single most likely word, which is one reason the same question can get different answers.

Why AI can sound sure and still be wrong
Here is the important part. The model is predicting likely words, not checking a list of verified facts. NIST uses the word confabulation for what people often call a hallucination. It describes confabulation as “a phenomenon in which GAI systems generate and confidently present erroneous or false content in response to prompts.”[3]
NIST’s explanation links this to prediction: “While such statistical prediction can produce factually accurate and consistent outputs, it can also produce outputs that are factually inaccurate or internally inconsistent.”[3] A likely-sounding answer is not always a correct one.
The confident tone is part of the risk. NIST warns that people may believe false content “often due to the confident nature of the response.”[3] The Australian Government’s digital agency gives the same warning to public servants: “Be aware that generative AI can produce convincing but inaccurate content.”[5] Its guidance is to check what generative AI produces for accuracy before using it.[5]
Try it: guess the next word
Proposed at-home activity. This is a simple game that shows probability at work. Nothing is needed except a book or a story you already have at home.
- Choose a sentence from a book, and read it aloud up to the last word. Cover that last word.
- Write down three words you think could come next, and rank them from most likely to least likely.
- Uncover the real word. Which of your three guesses was closest?
- Repeat with a few more sentences. Notice which guesses were easy, and which were hard to predict.
What to notice: some words are easy to predict because the sentence has only a few sensible endings. Others are surprising because many words could fit.
Safety first: This activity needs only paper and a pencil, and no hazards. If you later try an online AI chat tool, ask a grown-up first, and do not type personal details such as your address, school or passwords into any tool.
Go deeper: the chain rule and its limits
Building a sentence from parts
The textbook explains that the probability of a whole sentence can be built from the probability of each word given the words before it. It calls this the chain rule, and notes that it “shows the link between computing the joint probability of a sequence and computing the conditional probability of a word given previous words.”[1] In practice, a model estimates each of those small probabilities, and multiplies them together to score a sentence.
Why counting is not enough
Simple counting fails for long sentences, because new sentences are invented all the time.[1] That is why language models estimate probabilities instead of looking up every answer.[1] The same logic helps explain why the output of a model can be fluent and still wrong: it is a best estimate, based on patterns in the text it learned from.[3]
Frequently asked questions
Does AI know the answer, or does it guess?
Both descriptions are partly right. The model calculates likely next words. NIST notes that this can give accurate outputs, but it can also give inaccurate ones.[3]
Why does AI sometimes sound very sure when it is wrong?
Its wording is produced by the same process that makes fluent text. NIST warns that users may believe false content because of the confident nature of the response.[3]
Does AI look up facts in a database?
Not in the simple way people often imagine. The CSIRO describes the core of a language model as a prediction about what word comes next.[2]
Is the next word always the most likely one?
No. Georgetown’s CSET says that the model does not always pick the single highest-probability word.[4]
What should I do if an AI tool gives me facts?
Check them for accuracy before you use them, with help from an adult. The Australian Government’s staff guidance says to check generative AI outputs for accuracy and warns that they can be “convincing but inaccurate”.[5]
The big idea
Likely next words, one at a time. A language model predicts which word is likely to come next, picks one, and repeats. That process can write fluent text, but likelihood is not the same as truth, so check important facts.
Related reading
More from William Wonderlab:
Explore more from scientists:
- Speech and Language Processing, Chapter 3: N-gram Language Models (Stanford University)
- Generative AI Profile, NIST AI 600-1 (National Institute of Standards and Technology)
References
[1] Dan Jurafsky and James H. Martin, Speech and Language Processing, Chapter 3 “N-gram Language Models” (Stanford University draft) (accessed 25 October 2026)
[2] CSIRO, “Balancing risk and reward: generative AI for business” (published 22 August 2023) (accessed 25 October 2026)
[3] National Institute of Standards and Technology (NIST), “Artificial Intelligence Risk Management Framework: Generative AI Profile”, NIST AI 600-1 (July 2024) (accessed 25 October 2026)
[4] Matthew Burtell and Helen Toner, “The Surprising Power of Next Word Prediction: Large Language Models Explained, Part 1”, Center for Security and Emerging Technology, Georgetown University (8 March 2024) (accessed 25 October 2026)
[5] Digital Transformation Agency (Australian Government), “Staff guidance on public generative AI” (accessed 25 October 2026)



