Module 4 · Lesson 9

A neural network begins with parameters that do not yet encode the behavior we want. Training is the repeated process that adjusts those parameters.

A useful mental model is archery: make an attempt, measure the miss, determine how to adjust, and try again. Neural-network training performs a mathematical version of that loop at enormous scale.

1. Forward pass

A batch of training examples moves through the network and produces predictions. This is the forward pass.

2. Calculate loss

A loss function measures how well those predictions match the training objective. For a language model, the loss reflects how much probability the model assigned to the correct next tokens.

3. Backpropagate gradients

Backpropagation uses calculus and the chain rule to compute how changes in each parameter would affect the loss. The result is a set of gradients.

4. Update parameters

An optimizer uses those gradients to update the parameters. Gradient descent is the basic idea; practical systems commonly use more sophisticated optimizers and schedules.

batch
  ↓
forward pass
  ↓
loss
  ↓
backpropagation
  ↓
gradients
  ↓
optimizer update
  ↺ repeat

The learning rate matters

The learning rate controls the size of parameter updates. Too large and training can become unstable. Too small and learning may become painfully slow. Training recipes often change the learning rate over time rather than keeping it constant.

The goal is not necessarily zero training loss

A beginner explanation sometimes says training tries to drive loss to zero. Lower loss is desirable, but a model that memorizes the training set can still perform poorly on new data.

That is why validation matters. We watch whether performance improves on held-out data that is not being used for parameter updates.

The practical goal is generalization: learn patterns that remain useful beyond the exact examples seen during training.

This loop sounds simple in four steps. The difficulty comes from repeating it over huge datasets, large models, many devices, and long training runs without instability or wasted compute.


Demystifying AI series

← How Transformers Predict the Next Token   ·   Why LLM Pre-Training Uses So Many Tokens →