Chapter 2: How it's built

Learning from a mountain of text

Billions of random numbers become a model by guessing the next token trillions of times.

Lesson 5 of 9 · 3 min read · By the Learnfold team · Updated

A brand-new model knows nothing. Its internal numbers, called parameters or weights, are set at random, and a large model has billions of them. Ask it to continue "The cat sat on the" and it produces gibberish. Everything it later knows comes from one simple exercise, repeated an enormous number of times.

The exercise

Take a passage of real text. At every position, have the model guess the next token. Compare its odds with what actually came next. Then adjust every parameter a tiny amount in the direction that would have made the right answer a bit more likely.

The adjusting uses a method called gradient descent. For each parameter, calculus works out whether nudging it up or down would have reduced the error, and roughly by how much. All of them get nudged at once. One round of nudges does almost nothing. Repeat it across trillions of tokens and the nudges add up to a model that can write.

Nobody has to label the data. The text is its own answer key, because the next word is always right there. That's why this stage can use so much of it.

Interactive. Try it here or in the app.

Press Play or scrub the update step. The toy curve shows prediction error falling as training adjusts the weights.

What goes in

The training text for a large model is assembled from web pages, books, code, scientific papers, forums, and more. It's filtered to throw out spam, duplicates, and junk. For the largest models it runs to trillions of tokens. Training on it keeps thousands of specialized chips busy for weeks or months, which is why only a handful of organizations train the biggest models from scratch.

The mix matters a lot. More code in the mix makes a model better at code, and there's some evidence it helps with careful step-by-step reasoning more generally. Text that appears many times over tends to get memorized word for word. Deciding what goes in is one of the least glamorous parts of building a model and one of the most important.

What comes out

The result is called a base model. It does one thing extremely well. It continues text in a way that fits. Give it the start of a news story and it writes a plausible rest. Give it half a recipe and it finishes the recipe.

To get good at that, it ends up storing a great deal along the way. Facts, grammar in many languages, how arguments are usually built, what a polite email sounds like. None of it sits in a list you could read off. It's spread across the weights, and it's compressed. A model can't hold its training text word for word, because the weights are far smaller than the text. It holds something more like the patterns, with common things stored sharply and rare things stored as a blur. Keep that blur in mind. It explains a lot in the lesson on why models make things up.

Bigger has kept helping

Researchers found that when you scale up the model and the data together, with the computing power to match, prediction error falls along a smooth, predictable curve. These patterns are called scaling laws, and they're the main reason models grew so quickly. How long the curve keeps paying off, and whether lower error keeps turning into new abilities, is an open argument.

Rabbit holes

Questions worth chasing. In Learnfold, tap one and your tutor answers it as a new lesson in your course.

  • How can gradient descent work out which way to nudge billions of numbers at once?
  • Why would training on code help a model with things that aren't code?
  • What happens when a model is trained on text that other models wrote?
Follow these in Learnfold

Keep going in Learnfold

In the app you can ask about any sentence, follow a question into a new lesson, and pick up where you left off. This lesson opens right where you are.

Personalize has Learnfold’s tutor ask what you already know and what you want from it, then build a version of this course just for you. It uses AI, which needs a Learnfold subscription.

No app yet? Get Learnfold free

Get Learnfold

Learnfold is free on the App Store for iPhone, and this course is free to read in it.

  1. Get the app. Tapping the App Store button also copies this course’s link to your clipboard.
  2. Open Learnfold and tap Paste on the first screen to start with this course.
Download on the App StoreDownload on the App Store

Scan with your iPhone camera to open this course there. If Learnfold is installed it opens straight in the app.

Or send yourself the link:

Or see Learnfold on the App Store