AI Literacy Program · Shared interactive (used in Lesson 1 and Workplace Module 1)

How a chatbot picks the next word

A chatbot does not look up answers. It predicts a likely next word, over and over. Here is a tiny model you can run yourself — nothing is sent anywhere.

1. Choose a sentence starter

2. Generate words

Sentence so far:

Choose a starter, then press “Generate next word”.

Low temperature: the model almost always takes the most likely word (safe, boring). High temperature: unlikely words get a real chance (creative, sometimes nonsense).

3. What the model considers next

These are the model’s probabilities for the next word right now, adjusted by your temperature. The bar shows the size of each chance.

Next-word candidates with their probabilities
Next wordProbabilityChance

What is happening here

Every time you press “Generate next word”, the tiny model looks at the sentence so far and picks one word from a probability list. Nothing checks whether the sentence is true — that is not part of the machinery. The temperature slider reshapes the list: at low temperature the most likely word dominates; at high temperature, unlikely words get picked more often, so sentences become creative and sometimes nonsense.

Real chatbots work the same way in principle — with vastly bigger lists and patterns learned from enormous amounts of text. The key consequence is the same: fluent is not the same as correct. A chatbot can produce a beautiful sentence about something entirely false, with the same confident tone. That is why checking outputs is a skill of its own — see Workplace Module 2 or School Lesson 2.

Technical note: this page uses a small hard-coded table of word probabilities. It makes no network requests, stores nothing, and works offline.