AI Foundations 1: How does AI predict words?

Witjo

AI Foundations 1 · about 9 minutes · no jargon

AI doesn’t know anything. It guesses. Watch it happen.

Every answer ChatGPT has ever given was built one small guess at a time. In nine minutes you will watch it do that, control it yourself, and learn to spot when it goes wrong.

Soft abstract shapes suggesting a phone suggesting the next word

Imagine you are texting a friend and your phone suggests the next word. You tap it, and the phone suggests another. A chatbot works the same way. It does not look up an answer. It predicts the next small piece of text, then the next, until it decides to stop.

That is the whole trick. The AI has read a huge amount of writing and learned which words tend to follow which other words. When you ask it something, it uses those patterns to guess a likely reply, one piece at a time.

In the box below, step through how a reply is built one piece at a time instead of looked up all at once. Click the numbers, or press Next step.

The model begins with the prompt text so far rather than pulling a finished answer from storage.
It scores candidate next pieces based on patterns seen in its reading.
A chosen piece joins the sequence, and the context updates for the next step.
It repeats this small step over and over until it reaches a stopping point.

This is a simplified picture. A real AI weighs tens of thousands of words at every step, but the process is the same.

What just happened

You followed four steps showing how a sentence is built one piece at a time—scoring candidates from the text so far and repeating until a stopping point—rather than looking up a pre-written answer.

Why it works this way

The AI has read a lot of text and counted which words follow which other words. It turns those counts into probabilities: numbers between 0 and 100 percent that say how likely a word is. It picks from that list, adds the word, and repeats. It never plans the whole sentence. It only ever looks one step ahead.

Worked example. Start with “The capital of France is”. The demo gives Paris 72 percent, “a” 10 percent, “known” 9 percent, Lyon 8 percent, and banana 1 percent. Those five numbers add up to 100 percent. If the AI picks Paris, the next list might be comma 40 percent, full stop 35 percent, and “and” 25 percent. After two picks, the sentence could be “The capital of France is Paris,”. Each step used only the words so far, not a fact check.
An AI does not retrieve an answer. It predicts the next small piece, over and over, until it decides to stop.
Go deeper: what is a “token”?

A token is a small chunk of text, often a word or part of a word. The AI predicts one token at a time. “Paris” might be one token. “unbelievable” might be split into several. The percentages you saw are the AI’s odds for each possible next token. Real systems choose from tens of thousands of tokens at every step, which is why the simplified demo uses only a handful.

Step 2 · Beat the AI

Think you can predict its pick?

Guess before it reveals its odds.

You have a lifetime of reading and listening. So does the AI, in its own way. When you see “Sorry I’m late, my train was”, your brain fills in “delayed” before you even think about it. The AI does the same thing, but with numbers instead of a feeling.

Think of a weather forecaster. They do not know if it will rain. They say “80 percent chance” because they have seen many similar days. The AI is a forecaster for words. It says “84 percent chance the next word is water” because it has seen many similar sentences.

Answer the three questions below. After each answer you will see why every option is right or wrong.

It matches common phrase patterns It reasons about train schedules Unusual words cannot appear
It is a frequent text continuation It verifies clinical records first Odd words have zero chance
It is a classic story opening It outlines the full plot first No other word can follow it

What just happened

You answered three questions and saw the reasoning behind every option. Everyday phrases like ‘train was delayed’, ‘drink more water’, and ‘once upon a time’ rank high because they are common patterns in text.

Why it works this way

The AI’s odds come from counting. If “train was delayed” appears far more often in its reading than “train was purple”, then “delayed” gets a much higher percentage. It has no idea what a train is. It only knows which word sequences are common. That is why it can sound smart and still be blind to meaning.

Worked example. For “The doctor told me to drink more”, the demo gives water 84 percent, tea 13 percent, and glue 3 percent. Those add to 100 percent. A real AI might weigh thousands of possible next words, but the top few would still be water and tea. Glue is possible only because it is a word that can follow “drink more” in some rare text, so it gets a tiny chance.
The AI’s guess is a mirror of its reading, not a check of reality.
Go deeper: why “banana” sometimes appears

Even a silly word can get a small percentage if it ever appeared in a similar sentence during training. The AI does not filter for sense. It only ranks by how often a word followed similar words before. A tiny percentage is not a mistake in the math. It is the math being honest about a rare pattern.

Step 3 · Where the odds come from

Same sentence. Different reading. Different guess.

What decides the percentages?

Three readers with three different books, each seeing a different word

Imagine three cooks. One only reads cooking blogs. One only reads chemistry books. One only reads fantasy novels. Ask all three to finish “He carefully poured the … into the pot” and you will get three different answers. Each cook’s guess is shaped by what they read.

The AI is like those cooks, but it has read a mix of everything. Its percentages are a summary of that mix. Change the mix, and the guess changes. That is why two AI systems trained on different text can give different answers to the same question.

Choose a reading focus below. Each one shows how different training text shifts what follows ‘He carefully poured the … into the pot.’

Text centred on recipes and kitchens makes food liquids like ‘soup’ or ‘sauce’ top picks.
Lab and chemistry writing shifts odds toward terms like ‘solution’ or ‘acid’.
Fiction with magic and brews makes words like ‘potion’ or ‘elixir’ much more likely.
A wide mix of sources blends domain cues rather than locking into one genre.

The AI is a mirror of its reading. That is its strength, and the source of its blind spots.

What just happened

You compared four reading focuses and saw how different training material shifts which words are most likely to follow the same sentence.

Why it works this way

Training is the process of showing the AI a large amount of text and adjusting its internal numbers so it gets better at predicting the next token. If the text is mostly cooking, the numbers lean toward cooking words. If it is mostly chemistry, they lean toward chemistry words. The AI has no separate “common sense” file. Its sense is its reading.

Worked example. In the cooking tab, soup gets 58 percent, sauce 25 percent, water 15 percent, and potion 2 percent. Those add to 100 percent. In the fantasy tab, potion jumps to 66 percent and soup drops to 2 percent. The sentence did not change. The reading did. A real AI trained on the whole internet would blend all three, so its top word might be water, because water is common in every kind of text.
Change the reading material and you change the guess. The AI’s knowledge is its training text, nothing more.
Go deeper: what “training” actually adjusts

Inside the AI are billions of numbers called weights. During training, the AI predicts the next token, compares its guess to the real next token, and nudges the weights so the guess improves. After many rounds, the weights settle into patterns that reflect the training text. The AI never stores the text itself. It stores the patterns. That is why it can sound fluent but still make things up.

Step 4 · Roll the dice

Why you never get the same answer twice.

It rolls weighted dice at every step.

A bag of colored balls, mostly blue with a few red and gold ones

If the AI always picked the single most likely word, every answer would be identical. That would be boring and often unhelpful. So the AI adds a little randomness. It still favors likely words, but it sometimes picks a less likely one. This is called sampling.

Think of a bag of colored balls. Most are blue, some are red, a few are gold. If you draw without looking, you usually get blue. But sometimes you get red or gold. The randomness dial changes how many balls of each color are in the bag. Turn it up, and the rare colors become more common.

Slide the control below across 5 levels of randomness—from 1 (very predictable top picks) to 5 (flatter odds where less likely words appear more often).

At level 1, the top word dominates strongly, giving nearly the same answer each time. At level 2, likely words still lead heavily with only rare variation. At level 3, top choices usually win while allowing moderate variety. At level 4, odds flatten noticeably so less common words show up more often. At level 5, odds are much flatter, increasing variety and the risk of surprising or off-track words.

What just happened

You moved the slider from level 1 (very low randomness) up to level 5 (high randomness) and saw how higher randomness flattens the odds so less likely words appear more often.

Why it works this way

The AI turns its raw scores into probabilities. The randomness dial, often called temperature, changes how sharply those probabilities favor the top word. A low temperature makes the top word dominate. A high temperature flattens the odds, giving every word a fairer chance. The AI then samples from that list, like drawing a ball from the bag.

Worked example. The demo gives practice a score of 3, read 2.2, listen 1.6, sleep 0.4, and panic -0.3. At low randomness, practice might get 90 percent and panic near 0 percent. At high randomness, practice might drop to 35 percent and panic might rise to 8 percent. Those are simplified numbers, but the direction is real: higher randomness means more surprises.
Randomness does not make the AI smarter. It makes its guesses more varied, for better and for worse.
Go deeper: why chat apps use a middle setting

Too little randomness and the AI repeats itself. Too much and it drifts into nonsense. Most chat apps pick a middle value so answers stay sensible but not identical. Some tasks, like writing code or answering a math question, often use a lower value because you want one reliable answer. Creative writing tools often use a higher value because variety is the point.

Step 5 · Real or invented?

It sounds just as sure when it is wrong.

Can you tell which one the AI invented?

A confident tone is not evidence. A person who says “I am absolutely sure” can still be wrong. The AI is the same. It writes a made up fact in the same smooth voice as a true one, because both are just likely word patterns to it.

This is called a hallucination: when the AI states something false as if it were true. It is not lying. It has no intention. It is doing exactly what it was trained to do, which is produce text that sounds likely. A fake court case with a real looking name and volume number sounds very likely indeed.

Judge these four items. For each one, decide whether it is real or invented. Then read the reason.

Brown v. Board of Education of Topeka, 347 U.S. 483 (1954)
Hartwell v. Lakeside Airlines, 925 F.3d 1339 (11th Cir. 2019)
The Great Gatsby, by F. Scott Fitzgerald, published in 1925
The Quiet Signal, a bestselling 2011 novel by Dr. Elena Marsh

What just happened

You judged four items and then saw the real answer with a reason. Two were real and two were invented. The invented ones looked just as polished as the real ones. That is the point: polish is not proof.

Why it works this way

The AI generates text that fits the pattern of a citation or a book title. A real citation has a name, a volume, a page, and a court. A fake one can have all of those too, because the AI has seen thousands of real citations and learned the shape. It does not check whether the case exists. It only checks whether the words look right together.

Worked example. “Hartwell v. Lakeside Airlines, 925 F.3d 1339 (11th Cir. 2019)” has the exact shape of a real case citation. A lawyer who trusted the shape filed it in court. In 2023, lawyers in a New York court were fined for filing a brief with AI invented cases. The lesson is simple: look up the name, the number, and the date before you rely on them.
Confidence is not evidence. Check names, numbers, dates, and citations before you trust them.
Go deeper: why hallucination is not a bug you can fully remove

The AI is built to predict likely text, not to track truth. Truth and likelihood often overlap, which is why it is usually right. But when a false statement is more likely in the training text, or when the AI fills a gap with a plausible guess, it can produce a hallucination. Developers add checks and tools, but no system that predicts text can guarantee every fact. The reliable habit is human verification.

Step 6 · Prove it

Three questions. Let’s see what stuck.

You have seen the AI guess, watched its odds shift with its reading, rolled its dice, and judged its confident mistakes. Now check what you can explain in your own words. These three questions are not about memorizing numbers. They are about the ideas behind the numbers.

Answer each one, read the explanation, and then see your result. If you miss one, the explanation tells you where to look back.

How replies get built?

  • Looks up stored facts
  • Picks next pieces step-by-step
  • Thinks like a human first
  • Edits one fixed answer

Effect of higher randomness?

  • Boosts factual accuracy
  • Rare words appear more
  • Runs double fact checks
  • Speeds up responses

Why fake cases look real?

  • Tries to trick users
  • Matches citation shape
  • Database is too small
  • Renames real rulings
0/3

Your result

What you now know

  • AI writes one small guess at a time, never a whole answer at once.
  • Its odds come from what it read, so it mirrors its reading.
  • It sounds equally confident when it is wrong, so check names, numbers and dates.

Get the monthly summary

One short email a month with the best new topics on the site.

No daily mail, no spam. Just a short note when something worth reading is added.

One short email a month. Unsubscribe any time.

Words you met

  • Token: a small chunk of text, often a word or part of a word. The AI predicts one token at a time.
  • Probability: a number between 0 and 100 percent that says how likely something is. The AI gives every possible next token a probability.
  • Training: showing the AI a large amount of text and adjusting its internal numbers so its guesses improve. The AI’s patterns come from this text.
  • Randomness: a setting that changes how sharply the AI favors its top guess. Low randomness means stable answers. High randomness means more variety and more surprises.
  • Sampling: picking a token from the probability list instead of always taking the top one. This is why the same prompt can give different answers.
  • Hallucination: when the AI states something false as if it were true. It happens because the AI writes what sounds likely, not what has been checked.
  • Weights: the billions of numbers inside the AI that store its learned patterns. Training adjusts these numbers.
  • Temperature: another name for the randomness dial. It controls how flat or sharp the probability list is.

All numbers and percentages in these exercises are simplified teaching numbers. Real AI systems use far more data and far larger numbers, but the ideas shown are the real ones.

Understand AI without the jargon

Get our newest AI lessons by email: how models work, what agents can really do, and how to use AI well.

Witjo Newsletter Signup – AI

One short email a month. Unsubscribe any time.

Save to list

Scroll to Top