It guesses the next word

Next-word prediction. Lesson 1 of 38, in the part “How AI works”, 6 min. Free, with no account.

An experiment on AI. Give it half a sentence.

Below are two unfinished sentences. Press each one and see how AI finishes it.

One is a proverb. The other is about a bazaar where AI has never been.

  • A proverb: Finish this sentence: “Measure twice, cut ...”
  • A morning at the bazaar: Finish this sentence: “This morning I went to the bazaar and ...”

The proverb has one ending that everybody knows. The bazaar sentence could end in a thousand ways. Look at which one AI picked, and how sure it sounds.

Now you. Which word comes next?

We ordered plov at the choyxona. The cook lifted the lid off the ...

  • pot
  • river
  • Tuesday

You did not look into the kitchen. You have heard thousands of sentences like this one, so you know which word fits. AI does the same thing, only it has read far more than a person could in a lifetime.

This is where it starts. AI guesses the next word.

AI was trained on an enormous amount of text: books, websites, conversations. The first skill it learned there: look at the beginning and estimate which word is likely to come next.

After “Measure twice, cut” almost every text says “once”, so that is the word it picks. (Strictly speaking it works in pieces of words, but the idea is the same.)

And a long answer? The same thing, word after word.

AI adds one word, reads everything again and guesses the next one. A letter, a recipe, a poem are all written this way: one likely word at a time.

That is why the answer appears on your screen piece by piece. The app on your phone adds more on top: it can search the internet, and it can take time to think first. The words are still written this way.

Back to the bazaar. Where did the tomatoes come from?

Suppose AI finished the sentence like this: “This morning I went to the bazaar and bought fresh tomatoes.”

  • It remembered a real trip to the bazaar
  • It looked up what is sold at the bazaar today
  • In the texts it read, words like these often follow “bazaar”

Nobody went anywhere and there are no tomatoes. The sentence is not a report of something that happened. It is a likely continuation, and it reads exactly like a true one.

Here is the catch. Likely is not the same as true.

When millions of texts agree and are right, the likely word is also the true one: “The capital of Uzbekistan is Tashkent.” That is why AI is right so often. But when the texts are few, or the answer is not written anywhere, it can still produce a word that sounds right, in the same calm voice.

It sounds equally sure when it is right and when it is wrong. It may have thought and searched, and that helps. You cannot tell from the voice, so the last check is yours.

Three requests to AI. Which answer most needs checking?

  • Explain what the proverb “Measure twice, cut once” means
  • Name the capital of France
  • Tell me who the first director of the school in my village was

The first two are written in countless texts, so the likely answer and the true answer coincide. The director’s name is written almost nowhere, so a search has little to find. AI may say that it does not know. Or it may hand you a name that looks exactly like a real one.

Lesson 1 in three lines. What to keep

  1. AI writes by guessing the next word, again and again.
  2. It picks a likely word, not a checked one. Often the two coincide. Not always.
  3. A smooth, confident sentence is not proof. The rarer the fact, the more it needs checking, whether or not the app searched.

It read about the world. It was not there.