How AI Models Workknobs, guesses, and corrections

Topic 2 of 90Module 1: Foundations3 min read

How does a model learn to predict the next word? Three ideas:

Idea 1: Everything is numbers. Computers can't process words. So words get converted into numbers (we'll cover exactly how in Tokens/Embeddings). The model is math operating on numbers.

Idea 2: The model is billions of adjustable knobs. These knobs are called parameters (we'll go deeper later). Think of a giant sound mixing board with 7 billion sliders. The position of all sliders together determines what output you get for any input.

Idea 3: Training = adjusting knobs by making mistakes. Here's the loop, and it's beautifully simple:

  1. Take a sentence from the training data: "The cat sat on the mat"
  2. Hide the last word: "The cat sat on the ___"
  3. Ask the model to guess. Early in training it guesses garbage: "banana"
  4. Compare guess to truth. Measure how wrong it was (this measurement is called loss — literally a "wrongness score")
  5. Nudge every knob slightly in the direction that would have made the guess less wrong
  6. Repeat trillions of times
The training loop: hide the last word, let the model guess, compare the guess to the truth for a loss score, nudge every knob (backpropagation), repeat trillions of times. The output is a probability distribution, sampled like a weighted dice roll.
The training loop: hide the last word, let the model guess, compare the guess to the truth for a loss score, nudge every knob (backpropagation), repeat trillions of times. The output is a probability distribution, sampled like a weighted dice roll.

Daily-life analogy: Learning to cook biryani by taste. First attempt: too salty. You don't know exactly which of the 20 ingredients caused it, but you adjust several slightly. Next attempt: better. Repeat hundreds of times and eventually your hands "know" the recipe. The model does this, except with billions of ingredients and trillions of attempts. The math that figures out which knob to nudge and how much is called backpropagation — you don't need to know its internals yet, just that it's the "blame assignment" mechanism.

Now, why did your exercise in Topic 1 give different answers each time? Because the model doesn't output one word — it outputs a probability for every possible next word: "later" 40%, "soon" 25%, "tomorrow" 15%... Then it samples from those probabilities, like a weighted dice roll. The setting that controls how adventurous this dice roll is is called temperature: low temperature = always pick the top choice (predictable), high temperature = take risks (creative, but more errors).

Summary

A model is billions of knobs. Training means: guess the next word, measure the mistake, nudge the knobs, repeat trillions of times. Output is a probability distribution, and we roll dice on it.

Mental model

A cook who improved by tasting millions of dishes and adjusting the recipe a tiny bit after each one.

Mistakes to avoid

  • Thinking training happens when you chat with it. It doesn't. The knobs are frozen when you use the model. Your chat teaches it nothing permanently.
  • Thinking "temperature 0" means the model is always correct. It just means it's always consistent — consistently wrong is possible.

Exercise

If you use any API (you know TypeScript — use the OpenAI or Anthropic SDK), send the same prompt with temperature: 0 five times, then temperature: 1 five times. Watch the difference. You just learned sampling by feel.