Level 2 · Your phone keyboard

How does a phone keyboard predict your next word?

Goal: a keyboard that suggests your next word, like the three chips above a phone keyboard.

L2

Level 1 built a model that reads letters. Level 2 swaps letters for whole words: the same machine, now finishing your sentences.

1

What data does a keyboard AI learn from?

Short answer: A keyboard AI learns from everyday messages and can only suggest words it has seen in them. One message in ten is kept back to test it.

Why this step: A keyboard can only suggest words it has seen, so first you choose the messages it learns from.

Keep the kinds of message you send, then use them. Everyday texts, written by us.

What you just did: You picked the kinds of message you send; in training, one in ten is kept back, never studied, to test it fairly.

Recipe card +1 Collect examples: everyday messages, with one in ten kept back for testing.

Check: Why keep one message in ten back from training?
Show the answer

To test it on messages it never read. Only messages it never studied show whether it learned patterns or just memorised.

2

How does an AI split text into tokens?

Short answer: An AI splits text into tokens and gives each one a number. Here each token is a whole word; the numbered list is its vocabulary.

Why this step: Level 1 read letters; a keyboard suggests whole words, so it needs a new way to cut text up.

Tap a message to cut it into words.

What you just did: You cut a message into words and gave every word in your messages its own number: its vocabulary.

Recipe card +1 Cut messages into words and give each word a number: its vocabulary.

Check: What is its vocabulary?
Show the answer

Every word in your messages, each with its own number. It can only know words that appear in the messages it learns from.

3

What does next-word prediction actually learn?

Short answer: Next-word prediction learns the odds of each word coming next after the words before it: the Level 1 job, with words instead of letters.

Why this step: Before training, see the one thing it is trying to learn, using your own messages.

Press Count to see which word comes right after these two in your messages. Tap another start to count again.

What you just did: You counted which word comes right after a short start in your messages; those counts are the odds it must learn.

Recipe card +1 Its one job: predict which word comes next.

Check: After “see you”, your messages say “soon” most often. What should it learn?
Show the answer

To give “soon” high odds after “see you”. It learns odds for every next word, with the common ones highest, not a single fixed answer.

4

How is a next-word prediction model trained?

Short answer: A next-word model is trained like any AI model: it guesses odds for every word, checks the real next word and nudges every number, batch after batch.

Why this step: Counting works for short starts; to handle any sentence it must learn the odds by practice instead.

Start training. Watch its odds after your start move toward your counts.

After training

Train it to see these odds change.

The same loop as Level 1, now over every word, about 20 seconds:

  1. Guessodds for every word
  2. Checkagainst the real next word
  3. Nudgeturn every number a little
  4. Repeatnext batch of messages

What you just did: You trained it: it guessed odds for every word, checked the real next word, and nudged all its numbers, batch after batch.

Recipe card +1 Train: guess the next word, check, nudge every number, batch after batch.

Check: What changes during training?
Show the answer

Its numbers, nudged a little each step. The messages and vocabulary stay fixed; only its numbers move toward better odds.

5

How do you know when an AI is overfitting?

Short answer: An AI is overfitting when it keeps improving on messages it studies but gets worse on messages it never read. Keep the model from the moment the second score was best.

Why this step: Train too long and it memorises your messages instead of learning patterns; the kept-back messages show when.

Train a fresh copy from the start and watch two scores. Press Stop when you think it should stop.

What you just did: You watched two scores and kept the model from the step where messages it never read stopped improving.

Recipe card +1 Stop when messages it never read stop improving; keep that moment.

Check: Studied messages keep improving but never-read ones have stopped. What is happening?
Show the answer

It is memorising the messages it studied. Gains only on studied messages are memory, not skill that carries over to new text.

6

How does keyboard autocomplete suggest your next word?

Short answer: Keyboard autocomplete shows the three words its model gives the highest odds after what you typed; you tap one and it predicts again.

Why this step: This is the moment a real phone keyboard repeats every time you type.

Tap one of the three word chips just above the keyboard to add its word. Do it 3 times to build a message.

Taps: 0 of 3. Tap a word chip above the keyboard.

Try:

What you just did: You built a message by tapping its chips: each time it showed its three likeliest next words and you chose one.

Recipe card +1 Suggest: show its three likeliest next words; you pick one.

Check: Where do the three chips come from?
Show the answer

Its three highest odds for the next word. It scores every word it knows and shows only the top three.

7

Why is a word-level AI model bigger than a letter-level one?

Short answer: A word-level model is bigger because every word in its vocabulary needs its own numbers, and there are far more words than letters.

Why this step: Comparing it with Level 1 shows what makes a model bigger.

Tap Compare to set your keyboard beside your Level 1 name model.

What you just did: You set your keyboard beside your Level 1 model: it is bigger because every word needs its own numbers.

Recipe card +1 Ship it: numbers plus a small program; more words means more numbers.

Check: Why is the keyboard model bigger than the name model?
Show the answer

Each word in its vocabulary needs its own numbers. Thousands of words, each with its own card and score, outweigh 27 letters.

Explain how next-word prediction works

Put your seven recipe lines in the order you built them. If you can do this, you can explain a phone keyboard to anyone.

Tap the lines below one by one, first step first.

  1. Collect examples: everyday messages, with one in ten kept back for testing.
  2. Cut messages into words and give each word a number: its vocabulary.
  3. Its one job: predict which word comes next.
  4. Train: guess the next word, check, nudge every number, batch after batch.
  5. Stop when messages it never read stop improving; keep that moment.
  6. Suggest: show its three likeliest next words; you pick one.
  7. Ship it: numbers plus a small program; more words means more numbers.
In one minute

A phone keyboard learns from everyday messages, with some kept back to test it. It cuts messages into words and gives each word a number. Its one job is to predict the next word. Training makes it guess, check the real next word and nudge its numbers, batch after batch. You stop when messages it never read stop improving, because after that it only memorises. To suggest, it shows its three likeliest next words and you pick. The finished model is numbers plus a small program, bigger than the name model because every word needs its own numbers.

Go deeper: the maths behind Level 2

What just happened: how your model was made

  1. Your messages your messagesThe only thing it learns from. 1 in 10 is kept back, never read, to test it.
  2. Words become numbers one number per wordEvery word in your messages gets its own number: its vocabulary.
  3. A blank model random numbersIts size is chosen before training: one card and one output score per word.
  4. Training loop hundreds of stepsEach step reads a batch of your messages and nudges every number toward the right next word.
  5. Best moment kept its best stepWhere messages it never read stopped improving. After that it memorises the ones it studied.
  6. Your keyboard model numbers + a small programThose numbers and a small program. No messages inside, only odds.
  7. It suggests your messageIts three likeliest next words become the chips; you pick.

Surprise, in bits

messages it never readmessages it studies

Where its numbers come from

Two rules explain every line below.

  1. A card of numbers. Inside the model, every word travels as a list of numbers: its card. The builder picks the card's length before training.
  2. A × B is a grid of dials. Turning a card of A numbers into a card of B numbers needs one dial for every pair: A × B dials. “+ B” is one starting value for each new number.
  3. All start random. Training nudges every one of them (step 4). None stores a message.

Worked example: a toy model you can count by hand

    Same rules, real sizes