Class 8 · Unit 3: Generative AI · Lesson 3.1 · 40 min
What "generative" means
“I will come…” and the phone offers: home · tomorrow · later. “It knows what I want to say!” Does it?
Today you will: Build a next-word table by hand · Generate a sentence from it · See why it loops — and how a die fixes it
Story
Rahat is typing a message to his cousin. He types "I will come" — and the phone offers him three words before he has thought of any: home · tomorrow · later.
He taps tomorrow. Then the phone offers three more. He taps again. And again. In four taps he has a whole sentence he never actually wrote.
Rahat: “It knows what I want to say.”
Hiba is unconvinced. "It doesn't know you. It has just seen a lot of messages, and after I will come, people usually type one of those three."
Who is right? Today you build the thing inside the phone — by hand — and find out.
Watch
Predicting the next word — — scan code 8.3.1 in the printed book.
Learn it
The classifiers of Unit 2 answered which group is this? A generative model answers a different question: what probably comes next? It looks at everything written so far, predicts the next word, adds it, and does it again: predict, add, repeat. The phone's suggestion strip does this in a small way; the big systems that write whole essays do it at enormous scale. Either way, the predictions come from patterns counted in huge amounts of text, not from looking anything up.
Words to know
- Generative AI AI that produces new content: text, images, audio.
- Next-word prediction guessing the word most likely to come next, from patterns in many examples.
- Next-word table a count of which words follow each word in a text. It is the simplest language model.
- Loop text that goes round and round, because always choosing the single most likely word repeats itself.
- Randomness sometimes choosing a less likely word. It is why the same question can give different answers.
Step by step: a next-word table by hand
The text: "the boat crossed the lake. the boat stopped. the boatman sang."
| Word | Words that came next | Most common |
|---|---|---|
| the | boat, lake, boat, boatman | boat |
| boat | crossed, stopped | crossed / stopped |
- Count every word that follows each word. You are the machine.
- Generate: start with the. The most common next word is boat. Add it: the boat…
- Repeat from the new end: after boat comes crossed, and after crossed comes the, then boat again…
- Notice the loop: always taking the top word gives the boat crossed the boat crossed the…
- Add a little chance: roll a die to choose between the top two or three words, and the text varies, just as real systems do.
🕌 From our heritage
Generating every possible word mechanically is an old idea. Al-Khalīl ibn Aḥmad al-Farāhīdī (d. c. 786), compiling the first Arabic dictionary, worked through the permutations of Arabic root letters to list every combination the language could form, then asked which of them were actually used and which were not. His machine-like step was generating the possibilities; the scholarship was knowing which ones meant anything. A language model is in the same position, and so are you when you read its output.
Source: al-Farāhīdī, Kitāb al-ʿAyn (8th century), the earliest known Arabic dictionary.
Careful: your table knows only the words it counted. It does not know what a boat is, and it cannot check anything. A generative model predicts what is likely, which is not the same as what is true, as Lesson 3.5 shows.
On the laptop
You need: himal-story.txt (a short retelling of Himal and Nagrai) · LibreOffice Calc · next-word.ods · a die
Mission 1: Your mission
- ☐1
Read the story aloud in your pair.
- ☐2
next-word.odslists five words:the · king · snake · she · water. For each, write every word that comes straight after it in the story. You are the machine. - ☐3
In the last column, write the most common next word — the model's prediction.
- ☐4
Predict: if you always take the most common word, what will happen after ten words? Then generate from
the, one word at a time. - ☐5
Fix it the way real systems do: roll a die to choose between the top two or three words. Generate ten words again and compare.
- ☐6
Last row: what did the table know, and what didn't it know?
No laptop today?
Build the table on the blackboard from a printed story — each word's column filled by a different pair. Generate the sentence as a class, one student rolling the die.
Debate it
Your next-word table was built from one short story, so it can only write about kings, snakes and water.
If a table were built from every book, message and web page in the world, what could it write about? And would any of it be checked by anyone?
Check yourself — practice, not a test
1. "Generative" means the model:
- ○ Sorts photos into groups
- ○ Produces new content, such as text or images
- ○ Measures how accurate another model is
- ○ Stores facts in a table
2. Put the steps of generating a sentence in order:
- 1. Repeat from the beginning of the new text
- 2. Add that word to the text
- 3. Predict the next word
- 4. Look at the text so far
3. A generative model looks up facts in a dictionary before answering.
- ○ True
- ○ False
4. Always picking the most likely next word makes the text go round in a ______.
5. You ask the same question twice and get two different answers. This is mainly because the model:
- ○ Has learned something new in between
- ○ Does not always choose the most likely next word
- ○ Is broken
- ○ Is asking another model
Remember
Predict, add, repeat. It writes what is likely, not what is true.
Typing practice
Skill: typing whole paragraphs, Term 2 (5 min)
- On typing.com, open the paragraph practice your teacher has set for this term .
- Target this term: 30–35 WPM at 93% accuracy or better.
- Do not stop to fix every letter as you go. Finish the sentence, then read it back.
- Words for this unit:
generativepredictprobabilitysourceverify