How AI Predicts the Next Word, Starting With “Peanut Butter and…”
Peanut butter and…
Did you say jelly? Fair guess. Now try it with a little more to go on. “Dear Grandma, the banana slices you tucked into my lunch were just right. You know how much I love peanut butter and…” Same three words at the end. Did you reach for the same filling?
A chatbot plays a version of that game. Type it a question, and the program that writes back, its language model, predicts what comes next one token at a time. A token can be a whole word, part of a word or even a comma. For our sandwich game, whole words will do.
A guessing game with its own answer key
Suppose your whole letter to Grandma is already on the page. Cover everything after banana with a card. Make your guess, then slide the card over one word. Whatever the letter actually says gives you an answer to check. You can play again one word farther down the page.
That’s how a language model gets its practice, or training. It reads part of a passage and puts odds on what comes next. Suppose the next token on the page is slices. The training software checks how likely the model thought slices was. It adjusts numbers inside the model so that, across many examples, the model’s guesses improve. Nobody has to fill out an answer key for each sentence.
You can see a small version of the game in TensorFlow, a toolkit programmers use to build and train models. Its text-generation lesson uses Shakespeare’s plays. The model in that lesson guesses one letter, space or punctuation mark at a time. A chatbot’s tokens can cover more ground. It might finish a whole word in one guess.
How Does a Chatbot Come Up With Its Words?
Grandma gets a vote
Imagine giving ten people just “peanut butter and.” Seven might say jelly, two might say honey, and one might say pickles. Those are made-up numbers, though somebody in that kitchen deserves a follow-up question.
Put those ten answers in a hat and draw one. Jelly has the best chance, but you could still end up with pickles. A chatbot can make a weighted draw like that, called sampling. Another option is to take the favorite every time. Either way, the token it picks joins the text it uses for the next guess. Choose banana and slices might follow. Choose jelly and the reply can head in a different direction.
A clue can sit a whole sentence away. Keep the last few words exactly the same and change the start of the letter. “Grandma, the strawberry patch is ripe” gives the model different clues from “Grandma, we’ve got two bananas going brown.” A good guess draws on what came earlier, just as yours did.
- Stephen Wolfram takes a half-finished sentence and shows the odds a model gives to words that might come next.
- His diagrams follow the guesses one by one, so you can see how a single choice changes the rest of the sentence.
From finishing a sentence to taking a request
Now ask for something different. “Write Grandma a thank-you note in two sentences.” To give a useful answer, a chatbot needs to recognize that this is a request and that two sentences is a limit.
In a 2022 study on following instructions, people wrote examples of good replies. They also ranked several replies the model gave to the same request. The researchers used both kinds of feedback to train it further. With practice like that, “Write Grandma a thank-you note” is more likely to get you “Dear Grandma” than another list of sandwich fillings.
One last round. What kind of jelly did Grandma put in your sandwich yesterday? A model could give you a lovely sentence about strawberries. If nobody told it what was in the jar, that detail is a guess. For this one, Grandma still has the answer.
How AI Learns Rules Its Programmers Never Wrote
Why AI Makes Things Up—and Sounds So Sure About It

QUOTE:
"Amateurs hack systems, professionals hack people."
