Lesson 1 of 8
How AI generates text
8 min read
AI answers in full sentences in the blink of an eye. But how does it actually write them — what comes first?
One word at a time
AI doesn't dream up a whole sentence and then type it out. It writes the way your phone's autocomplete does — one word at a time, each time asking itself a single question: what word usually comes next? Pick a word, add it, ask again. The sentence grows out of that loop.
AI builds text one word at a time and never sees the finished sentence in advance — it only ever chooses the next word. This next-word guesser is what's called a language model.
Where the odds come from
So how does it decide what "usually comes next"? It doesn't keep a list of answers. Instead, for every word it could say next, it hands out a score — a gut number for how well that word fits. After "the cat sat on the", mat scores high; helicopter scores low. Then it turns all those scores into odds that always add up to 100, and picks from them. That's the whole engine: score every option, turn the scores into odds, pick one.
The odds aren't stored anywhere — they're computed fresh from the scores every single time. Raising one word's score doesn't just lift that word; it steals share from all the others, because the odds always total 100. The words compete.
The dial, explained
You've heard AI has a "creativity dial". Here's what it actually is. Temperature is one number that decides how sharply the top score wins. Turn it low and the highest score takes almost all the odds — the safest word, every time. Turn it high and the odds flatten out, so the long shots get a real chance. It never changes the scores — only how harshly the best one is rewarded.
That dial is the temperature. Low makes the odds peaky (the safe word almost always wins); high flattens them (surprising words get a chance). It doesn't touch the scores — it only sets how sharply the best score is rewarded.
Curious why a high setting is never the same twice? Picking is a weighted roll of the dice against those odds — so even with identical scores, the word can land differently every run.
Recap
- —AI writes one word at a time, always choosing what likely comes next
- —For each next word it computes a score, turns the scores into odds that add up to 100, then picks one
- —Temperature sets how sharply the top score wins: low is safe and predictable, high is creative and risky
On the engine, you drag one word's score up. What happens to the other words' odds?
Continue in the app
Take the whole AI from Scratch course — tracked
Get your personalized path, progress and streaks in the app — this lesson and every next one, in order.