Every other guide is about using a finished model. This one shows where those billions of weights come from — the surprisingly simple loop of guess, measure, adjust, repeat. A little more math-flavored, but still no equations required.
0. Where do the weights come from?
All along we've said a model is its billions of weights — the numbers that hold its knowledge. But a fresh, untrained model starts with those numbers set to random junk. It knows nothing; its answers are gibberish.
Training is the process that turns that random junk into a useful model, by showing it mountains of examples and slowly correcting it. Astonishingly, the whole thing rests on one simple loop repeated billions of times. That loop is this guide.
1. The goal in one picture
Training has one job: find the setting of all the weights that makes the model's predictions match the real answers as closely as possible.
Analogy: A giant mixing board with billions of knobs (the weights). At first they're set randomly and the sound is noise. Training is patiently turning each knob a hair at a time until the music comes out right. Nobody sets the knobs by hand — a rule does it automatically, which is what the rest of this guide explains.
2. Measuring "how wrong" — the loss
To improve, the model first needs to know how badly it's doing. We give it an example where we know the correct answer, let it predict, and compare. A single number captures the gap between its guess and the truth: the loss (also called error or cost).
Big loss = very wrong.
Small loss = nearly right.
Zero loss = perfect on that example.
Loss is just one number for the gap between guess and truth. Training's whole job: shrink it.
The entire aim of training becomes crisp: make the loss as small as possible. Everything else is just how.
3. The core training loop
Here's the whole engine. It's just four steps, run over and over — millions or billions of times.
Predict → measure the loss → nudge every weight to reduce it → repeat. That's training.
Steps 1 and 2 are easy to picture. The magic is in step 3: how do you nudge billions of weights in the right direction? Two ideas make it work — gradient descent and backpropagation.
4. Gradient descent: rolling downhill
Picture the loss as a landscape of hills and valleys. Your current weights put you somewhere on it, at some height (your loss). You want to reach the lowest point — the smallest loss.
You can't see the whole map, but you can feel the slope right under your feet: which way is downhill. So you take a small step downhill, then feel again, step again. Keep going and you descend into a valley. That's gradient descent — "gradient" is just the fancy word for slope.
Feel the slope, step downhill, repeat — until you settle at the bottom (minimum loss).
Analogy: A ball in a bowl rolls to the bottom on its own. Gradient descent rolls the weights toward the setting with the least error.
5. The learning rate (step size)
How big should each downhill step be? That's the learning rate, one of the most important dials in all of machine learning.
Too big — you leap over the valley and bounce around, never settling (or fly off entirely).
Too small — you inch along and training takes forever.
Just right — steady, efficient progress to the bottom.
The learning rate is the step size: too big overshoots, too small crawls, just right reaches the bottom.
Analogy: Adjusting a shower tap. Tiny turns and you're freezing for ages; huge turns and you scald-then-freeze forever. The right-sized turn gets you comfortable fast.
6. Backpropagation: who's to blame?
Gradient descent says "step downhill." But a model has billions of weights across dozens of layers. Which ones do we nudge, and by how much? We need to know how much each individual weight contributed to the error. That's the job of backpropagation (backprop).
The prediction flowed forward through the layers. Backprop sends the error backward through the same layers, handing each weight its share of the blame — "you pushed the answer too high, ease off; you barely mattered, stay put." Every weight gets a personalized nudge in the direction that lowers the loss.
Forward pass makes the guess; backward pass shares the blame so each weight knows how to move.
Together they are the whole recipe: backpropagation works out which way is downhill for every weight; gradient descent takes the step. Repeat billions of times and random junk becomes a capable model.
7. Epochs, batches & data
You don't feed examples one at a time (too slow) or all at once (too much memory). You feed them in small groups called batches, updating the weights after each. One full pass through the entire dataset is an epoch, and training usually runs for many epochs.
Data flows in batches; one sweep over all of them is an epoch, and training runs many epochs.
And the data is everything. The famous phrase is "garbage in, garbage out" — a model can only become as good as the examples it learns from. Modern LLMs are pretrained on a huge slice of the internet, then refined on carefully chosen data.
8. Overfitting vs generalizing
There's a trap. If a model studies the same examples too long, it can start to memorize them instead of learning the underlying pattern — acing its practice set but flunking anything new. That's overfitting.
To catch it, we hold out some data the model never trains on (a validation set) and watch its loss there. When training loss keeps dropping but validation loss starts rising, the model has stopped learning and started memorizing.
When validation loss turns upward, stop — the model is memorizing, not learning.
Analogy: A student who memorizes last year's exam answers word-for-word gets 100% on that paper but fails a fresh test. You want understanding, not memorization — that's generalization.
9. How this connects to everything else
This loop is the foundation under every other guide in the set:
Pretraining is this loop run at massive scale on huge text data — that's how a base model like Llama or Gemma is born.
Fine-tuning & LoRA (guide 4) are the exact same loop, just shorter and on your data — LoRA simply freezes most weights so only the tiny adapter gets the nudges.
Embeddings (guide 3) and attention (guide 2) are learned by this loop too — the meaning-map and the Q/K/V weights are all just numbers that gradient descent settled on.
Edge tie-in: training is heavy and happens once, on big machines in the cloud. What lands on your phone is the finished model — so everything in guide 1 (quantization, KV cache, backends) is about efficient inference, i.e. using what training produced. Training creates; the edge consumes.
10. Test yourself
Pick an answer and it'll explain why. Score updates as you go.
1. What do a model's weights look like before training?
Random junk. Training is what turns those random numbers into useful knowledge.
2. What does the "loss" measure?
How wrong it is. Training's whole job is to make this number as small as possible.
3. Gradient descent works by…
Downhill steps. It follows the slope of the loss toward the lowest point (least error).
4. What happens if the learning rate is far too big?
Overshoot. Too-big steps leap over the valley; too-small steps take forever. You want "just right."
5. What does backpropagation figure out?
Blame assignment. It sends the error backward through the layers so every weight knows how to move.
6. What is one epoch?
A full pass. Data is fed in small batches; a complete sweep through all of it is an epoch.
7. Training loss keeps dropping but validation loss starts rising. This means…
Overfitting. It's acing the practice set but failing new data — usually a sign to stop training.
Score: 0 / 7
Mini-glossary
Training
Turning a model's random starting weights into useful ones by learning from examples.
Loss (error / cost)
A single number for how wrong a prediction is; training tries to minimize it.
Gradient descent
Repeatedly stepping "downhill" on the loss to reach the setting with the least error.
Gradient
The slope of the loss — which way, and how steeply, the error changes.
Learning rate
How big each downhill step is; too big overshoots, too small crawls.
Backpropagation
Sending the error backward through the layers to give each weight its correct nudge.
Batch
A small group of examples processed together before updating the weights.
Epoch
One full pass through the entire training dataset.
Overfitting
Memorizing the training data instead of learning general patterns.
Validation set
Held-out data used to check the model generalizes to things it didn't train on.
Pretraining
The huge first training run that creates a general base model.
Inference
Using the finished model to make predictions (what runs on the edge).
→ Ready for the deep end?Advanced Edge Internals — K-quants, NPUs, and continuous batching, the real engineering frontier.