← AI Foundations

Can you predict the next word?

See how examples influence which words seem likely to come next, without assuming that the most likely word is certain.

When you type a message or a search, the computer often suggests the next word. Is it guessing what you mean, or using patterns from examples?

A sentence can have more than one sensible next word. A text generator needs a way to choose between possibilities.

How this lesson works: Engage, Explore, Explain, Elaborate, Evaluate
EngageCommit to a prediction before you test anything. A wrong guess is fine: it shows you what to look for.

Engage: Finish the sentence

Write down one ending of your own before looking at any examples. Why did you choose it? Keep your answer to revisit later.

Which word must come next after 'The cat sat on the'?

ExploreTry it on the board and compare what happens with your prediction.

Explore: Change the examples

Start with mat = 3, chair = 2, roof = 1. Predict the most frequent ending, then add five more lines containing roof. Press Update examples and explain why the prediction changes.

Try it yourselfYour edits are saved in this browser.

Add five roof examples and update the model.

Use the board. This ticks when you get there.

ExplainPut a name to what you saw, and why it works.

Explain: Patterns are not rules

Look at the original six examples and identify the ending that occurs most often.

Explain why the most frequent ending is not guaranteed to be chosen.

Complete the reflection using the evidence from the examples.

A simple model can count which words followed a phrase in its examples. More examples of one ending make that ending more frequent, but not certain. Select Show fractions and percentages on the board if you want to describe these frequencies numerically: mat is 3 out of 6, chair 2 out of 6 and roof 1 out of 6. If a generator samples endings in proportion to these counts, those fractions become its probabilities.

A probability is not a promise. The most likely choice is not the only possible choice.

Modern language models use tokens, neural networks and much more complex learned representations of context. Our small counting model is a way to investigate one idea: possible next words can have different probabilities.

Which ending appears most often in the original six examples?

On the board, roof is 1 of the 6 examples. If a generator picks endings in proportion to the counts, how often would you expect roof?

ElaborateUse the idea in a new situation.

Elaborate: Change the evidence

Discuss: does changing the examples change the meaning of the sentence, or just the pattern our model has learned from them?

Five more 'roof' endings are added. Which ending is now most common?

EvaluateLook back at your first ideas and what changed.

Evaluate: A new pattern

Without looking at the table, explain why a text generator might produce different endings for the same beginning. Then return to your first prediction: would you change it? Why?

A model sees 'I drink' followed by water four times and juice once. Which statement is justified?

ExplainPut a name to what you saw, and why it works.

Learning with AI: question a suggestion

An AI writing assistant suggests mat to finish “The cat sat on the”. Compare these two reactions:

Which reaction shows better judgement? Explain what you would check before accepting a suggested word. The suggestion above is a prepared example.

Looking ahead: Our model uses one fixed phrase and a small set of examples, so we can see both why it favours an ending and where it struggles. Modern language models predict tokens using much richer context and learned patterns. Their responses can be far more useful and convincing, but they still have blind spots — often harder to identify or explain. Treat an AI suggestion as something to evaluate, not automatically accept: does it fit your purpose, and what would you need to check?

Next: use dice to make a choice according to these probabilities.

You are writing about your cat, who sleeps on the roof. You type 'The cat sat on the' and the AI suggests 'mat'. What should you write?

Now you can
Next lesson2. Build a text generator with diceTurn word frequencies into dice outcomes, then sample words without always picking the most common one.
For teachers

Count example endings and distinguish a frequent next word from a certain one. About 25 minutes.

Open the teacher guide: answers, solutions, slides and a worksheet.

Students will be able to

Before class

Use the board as a transparent fixed-context model, not a miniature modern LLM. No AI account is required. The Explain it to me clip is an optional scaffold after prediction. Formal fractions and percentages are an optional extension, not a prerequisite: start with counts and bars. Ask learners to justify answers using counts rather than guesses about the writer's intentions. Common misconceptions: most likely means certain; the generator understands what the writer intends; changing the examples cannot change the prediction.

Running the lesson

  1. Engage: ask students to write their own ending before seeing any examples.
  2. Explore: count mat, chair and roof before revealing fractions; then add five roof examples.
  3. Explain: the Explain it to me clip or its text is optional; do not require watching before exploring.

The hard part (on purpose)

Students may read 'most common' as 'must come next'.

When students get stuck

Stretch and support

Stretch: Explain where the toy model differs from a modern AI assistant (tokens, much longer context, learned patterns).

Support: Use the prepared examples, read the explanation aloud and repeat a small trial.

Where it leads

Unit 1, lesson 2 uses a die to choose an ending by its chance. A physical die helps; no online AI account is needed.

What each step is for