Welcome back
Last time we moved abroad and saw how a network can carry its old knowledge to a new task. It starts from a pretrained model and gently fine-tunes it, instead of starting over.
Until now, almost every network we’ve met has been a kind of judge. It looks at something and answers a question about it: which move? which bag? which bird? Today, for the first time, we ask a network to make something.
The novelist at her desk
Picture a novelist at a wooden desk, early morning, coffee going cold. She has written:
“The rain had not stopped for three days, and Margaret…”
What comes next? She doesn’t know the whole rest of the book. But she has a feel for what’s likely. “Margaret was” feels natural. “Margaret stood” feels plausible. “Margaret banana” doesn’t feel right at all. Years of reading have given her a quiet sense of which words tend to follow which.
She chooses one. Then, with that word now on the page, she asks the same question again. Word by word, a story appears that never existed before.
A network that guesses the next word
A generative language model works in almost exactly that way. Its training task is wonderfully simple: given some text, guess the next word.
It’s shown an enormous amount of writing, and over and over it practises that one guess. When it’s wrong, the loss tells it how wrong. Backpropagation traces the blame, and the weights shift a little. You know this loop by heart now.
To guess the next word well, though, the network has to learn a surprising amount: grammar, facts, tone, how arguments flow, and how stories tend to unfold. All of that knowledge lives in its weights, much like the novelist’s years of reading.
How it writes
Once trained, here is how it creates text:
- It reads everything written so far, usually with a Transformer, attention and all.
- It produces a score for every possible next word, and softmax turns those scores into probabilities. Maybe 30% “was”, 20% “stood”, and tiny amounts for thousands of others.
- It picks one, often not simply the top choice, but drawn somewhat at random according to those probabilities. That bit of chance keeps the writing from being flat and repetitive.
- It adds that word to the page and goes back to step 1.
A small dial called temperature controls how adventurous the picking is. Turn it low and the network plays it safe. Turn it high and it takes more creative risks, and sometimes more strange ones.
Beyond words
The same spirit reaches far beyond text. Image generators learn to create pictures, often by starting from pure static and removing noise a little at a time until a picture appears. This approach is called diffusion. Others generate music, speech or even protein shapes. The details differ, but the heart is the same: learn the patterns of many real examples, then produce new things that follow those patterns.
What to carry with you
A generative model learns the patterns in many examples, then creates something new one piece at a time, each time choosing what is likely to come next.
