Lesson 2 — How AI Predicts the Next Word
In Lesson 1 you selected the most plausible next word. This lesson examines how you determined which word was plausible — because the same principle is the mechanism underlying every AI assistant.
This activity needs JavaScript enabled. The lesson below still covers everything.
What changed your prediction
The phrase remained the same — "reached for the ___" — but your prediction changed as soon as the sentence specified who was reaching. A chef reaches for salt; a judge reaches for a gavel. You did not select the most frequent word in English overall; you selected the most likely word given the preceding context.
This notion — the probability of an outcome given known information — is among the most important concepts in AI. It is termed conditional probability. The "condition" is the information already available, and new information changes the probability.
This principle is applied routinely in everyday reasoning. The probability of rain in general is one value, and a substantially different value given that the sky is dark and the wind has increased. The same event, with additional information, yields an updated probability.
Try it with real numbers
Words first, now numbers. The table below is a 40-day weather diary: each day is sorted by whether the morning was cloudy and whether it later rained. Counting days is all a conditional probability is — P(Rain) counts rainy days out of all days, while P(Rain given Cloudy) counts rainy days out of only the cloudy ones. Change the counts and watch both probabilities update.
This activity needs JavaScript enabled. The lesson below still covers everything.
Why this is the mechanism underlying an AI
A language model conditions on all preceding text — its "condition" — and computes: given that text, which word is most probable next? It does so one word at a time, with each generated word becoming part of the condition for the next.
This is why the same question can produce different answers depending on how it is posed. The text provided to the model constitutes the condition. Supplying more relevant context shifts the probability toward a better answer — the central skill developed in the prompting lesson.
Plausible continuation given the context?
For each sentence below, determine whether the suggested next word is a plausible continuation given the preceding text. Feedback is provided immediately for each response.
This activity needs JavaScript enabled. The lesson below still covers everything.
An important caveat
"Most probable given the context" is not equivalent to "true." A model is strongly influenced by its surrounding context, including misleading context. When the context is misleading, the most plausible next word may be plausibly incorrect. This reinforces the principle from the previous lesson: the model predicts; the user verifies.
Quick check
This activity needs JavaScript enabled.
← Previous: What AI Assistants Actually Are · Next: Working with an AI Assistant →