Here's the whole secret of ChatGPT, Claude, and Gemini in one line: a language model does ONE thing — it guesses the next word. Over and over. Let's build one you can play with, and write a sentence by only ever picking what comes next.
Your sentence so far is below. Under it are the model's top guesses for what comes next, with a bar showing how sure it is. Click any guess to add it — then it guesses again from the new last word. That's literally how an AI writes. Try 🤖 Auto-write to watch it always grab its #1 pick.
The bar = the model's confidence. Longer bar = it saw that word follow more often in its training text. Grown-ups call that a probability.
Our model only read a tiny story about a little robot. Tap a word below — it drops that word into the predictor above. The words in green live in its training text; the words in red do not. Watch what the guesses look like when it's off the map.
You've seen how it thinks. Now predict its prediction! Here's a bit of text ending in one word. Four words are offered — pick the one the model thinks is most likely to come next. Get it right and you score. Nail 3 to win the last badge!
Your model only looks at the last word. Real AIs look at everything you wrote. Here's how next-word prediction grew up:
Ignore context, always say the word that's most common overall. ✅ Dead simple. ⚠️ Says "the" forever — the sentence never makes sense.
Count which word usually follows the last one (or last few). ✅ Actually forms phrases. ⚠️ Forgets the start of the sentence and any word it never saw.
A neural net weighs every word you wrote, learned from billions of sentences. ✅ Stays on topic for pages. ✅ Handles new words. ⚠️ Huge and expensive to train.
The toy above counts word-pairs. This is SmolLM2 — a real neural language model that learned from millions of web pages, small enough to run on a basic laptop — right on your own device. Type a start and watch its real next-word probabilities, then let it write. One-time ~180 MB download; then it's cached and runs offline.
First time only — after it downloads, it runs offline and loads instantly.
You built a language model and learned its one job: guess the next word. You wrote a whole sentence just by picking what comes next, you saw it flail on words it never learned, and you even out-guessed the bot. Every AI chatbot on Earth is a giant, fancy version of what you just played with.