🏁 Machines That Talk · Day 7

The Probability Race

Every time an AI picks the next word, it's not sure — it runs a race. It gives every possible word a score, turns the scores into percent chances, and the fastest one usually wins. But close races can flip. Let's start the engines.

↓ start the race
🏁 Lab · The Next-Word Race

Pick a word. Watch the race.

This little AI read a bunch of sentences. Pick a starting word below and it lines up the words that could come next — longest bar = biggest chance. Change the word and the whole race re-ranks in a flash.

After “the”, the race for the next word looks like this:

front-runner: —
See it? A bigger bar means a bigger chance — but even the front-runner is usually well under 100%. The model isn't sure; it's placing a bet on the most likely word.
📊 Scores → Chances (softmax)

How scores become percent chances

Where do those percents come from? Each word first gets a raw score. Type any 3 scores — the machine turns them into chances that always add up to 100%. A bigger score wins more chance, but never all of it.

0%
0%
0%
Try this: make one score huge (like 10) — it hogs almost all the chance. Make all three equal — they split evenly (a 3-way tie). A big score doesn't mean 100%; it's only big compared to the others.
🐞 Break-It Challenge

Make it a coin flip

Some races are photo-finishes. After the word “the”, the top two words are almost tied. When it's that close, the model's pick is basically a coin flip — run it again and a different word can win.

flip it to see
Watch for this: because the two leaders are neck-and-neck, sometimes one wins and sometimes the other — over 20 races it's roughly 50/50. When chances are close, the "winner" is mostly luck. That's why the same AI can answer the same question two different ways!
🏷️ The pro wordThose raw scores are called logits. The math that squeezes them into chances that add up to 100% is softmax. And the full list of every word with its chance is a probability distribution over the whole vocabulary. Every word an AI writes is one winner picked from that distribution.
🎯 Boss Build · Call the Winner

Bet on the front-runner

The bars are hidden. You get a starting word and 4 possible next words. Which one has the highest chance? Tap your bet, then reveal the real race. Call it right 3 times to win the badge!

Called: 0 / 3
🚀 Beyond the Basics

How the pros really do it

Our race lines up a handful of words. Real AI runs this exact race over a giant list of words — every single step. Here's how the scoring grew up:

🔢

Just counting (what you'd try first)

Count how often each word followed another and pick the most common. ✅ Dead simple. ⚠️ Never saw a word pair? Score is zero — it just breaks.

📊

Scores → softmax (what you built)

Give every word a score, then softmax turns them into a tidy set of chances that add to 100%. ✅ Always a real probability. ✅ Handles ties gracefully.

🧠

Transformer logits (the real deal)

A transformer outputs a logit for every token — tens of thousands of them — each step, then softmax picks. ✅ Fluent, flexible. ⚠️ Huge compute per word.

🏷️ Pro names to look upThe scores are logits, the squisher is softmax, and the full word list it scores over is the vocabulary (each word first becomes an embedding). How spread-out vs. peaky the race is gets tuned by temperature — tomorrow's toy.
🔬 Real Model Lab

The real probability race

The race above used counts. This is SmolLM2, a real neural network small enough for a basic laptop, running on your device — every bar is a real probability it computed for the next token. Change the context and watch the whole race re-rank for real. (~180 MB one-time download; then offline.)

not loaded

🎉 Day 7 Complete!

You learned the secret behind every word an AI writes: it scores every option (logits), turns the scores into percent chances (softmax), and picks a winner from that probability distribution. The favorite usually wins — but it's a race, not a sure thing.

Day 8: Build-a-Bot Personality →
Tomorrow: we grab the temperature dial that makes the race wild or safe — and use it to give your bot its own personality. 🎛️
AI Adventure · Machines That Talk · Day 7 — made for young inventors 🚀