Whole course on one page
How AI Models Are Trained: A Visual Guide to Building Models from Scratch: 25 lessons, a few lines each. About 15 minutes to read. Use it to preview the course or to revise.
Start Here
1. What It Means to Train a Model opens the one-minute view
Training means a model guesses, sees how wrong it was, and changes its numbers a little. It does this many times.
Steps: 1. Make a guess · 2. Measure the mistake · 3. Change the numbers a little · 4. Repeat many times
✗ Thinking a person writes the model's rules by hand ✓ Give data and a way to measure mistakes; the loop sets the numbers
Words: Model, Loss, Parameters
📌 Guess, compare, adjust, repeat.
2. Data, Features and Labels opens the one-minute view
Training data is a table of examples. Features are the columns the model sees. The label is the answer it must guess.
Steps: 1. Collect examples you may use · 2. Pick the feature columns · 3. Name the label column · 4. Hide some rows as a test set
✗ Putting a column that already holds the answer into the features ✓ Use only features you would know before the answer
Words: Feature, Label, Test set
📌 Features go in. The label is what comes out.
Your First Model: Fitting a Line
3. A Model Is a Formula with Knobs opens the one-minute view
Our first model is a straight line: price = w × size + b. The letters w and b are two knobs that training sets.
Steps: 1. Take the size of a flat · 2. Multiply it by w · 3. Add b · 4. Read the guessed price
✗ Thinking the model understands flats like a person does ✓ Remember it is a formula that knows only its knobs and inputs
Words: Weight (w), Bias (b)
📌 A model is a formula with knobs. Training turns the knobs.
4. Measuring Mistakes: The Loss opens the one-minute view
The loss is one number for all of a model's mistakes. We square each mistake, then take the average.
Steps: 1. Find each error · 2. Square each error · 3. Add them up · 4. Divide by the number of examples
✗ Adding the errors without squaring them ✓ Square each error first, then take the average
Words: Error, Mean squared error
📌 The loss is one number for all the mistakes. Make it small.
5. Gradient Descent: Turning the Knobs Downhill opens the one-minute view
Gradient descent finds which way each knob makes the loss grow. Then it moves the knob a small step the other way.
Steps: 1. Work out the errors · 2. Find the slope for each knob · 3. Step each knob against its slope · 4. Repeat until the loss stops falling
✗ Adding the gradient to the knob ✓ Subtract the gradient times the learning rate
Words: Gradient, Learning rate
📌 Find the slope, step the other way, repeat.
6. Lab: Train a Line from Scratch opens the one-minute view
In this lab you write the loss, the slopes and the update step in Python. Then a line learns flat prices by itself.
Steps: 1. Run the starter file · 2. Write the loss · 3. Write the slopes · 4. Write the update step · 5. Predict a new flat's price
✗ Giving the model 55 when it learned sizes in tens ✓ Prepare new inputs the same way: 55 becomes 5.5
Words: Training loop, Scaling
📌 Data, model, loss, loop. That is every training program.
Classifying Things
7. From Numbers to Yes or No: Logistic Regression opens the one-minute view
The model adds up clues with weights. It turns the total into a chance from 0 to 1. A high chance means yes.
Steps: 1. Count the clues in the message · 2. Multiply each clue by its weight · 3. Turn the total into a chance · 4. Say yes if the chance is 0.5 or more
✗ Reading a chance of 0.62 as a sure fact ✓ Read it as how sure the model is about this one message
Words: Sigmoid, Threshold, Log loss
📌 Add weighted clues, turn the total into a chance, then compare it with the threshold.
8. Training, Validation and Test Sets opens the one-minute view
Split your examples into three piles. One pile is for learning. One is for choosing settings. One is for the final check.
Steps: 1. Remove copies of the same example · 2. Shuffle the examples · 3. Split into 70, 15 and 15 percent · 4. Keep the test pile locked away · 5. Use the test pile once at the end
✗ Trying many settings and keeping the best test score ✓ Choose settings on validation, then test once
Words: Training set, Validation set, Test set
📌 Learn on training, choose on validation, and check on test only once.
9. Overfitting and Underfitting opens the one-minute view
A model that is too simple misses the pattern. A model that memorises its examples fails on new ones.
Steps: 1. Measure the error on training data · 2. Measure the error on validation data · 3. Add clues if both errors are high · 4. Add data or stop early if gap is big
✗ Being happy with a very low training error ✓ Compare it with the validation error
Words: Underfitting, Overfitting, Early stopping
📌 Watch the validation error. When it rises while training error falls, stop.
10. Judging a Classifier: Accuracy, Precision and Recall opens the one-minute view
Count the right and wrong answers by type. Precision checks false alarms. Recall checks missed cases.
Steps: 1. Sort answers into four boxes · 2. Work out accuracy · 3. Work out precision and recall · 4. Pick the threshold by cost of mistakes
✗ Reporting only accuracy ✓ Report precision, recall and the four counts too
Words: Accuracy, Precision, Recall, Confusion matrix
📌 Count false alarms and misses separately, then decide which costs more.
Neural Networks from Scratch
11. Neurons, Weights and Activations opens the one-minute view
A neuron takes some numbers in and gives one number out. It multiplies each input by a weight, adds a bias, then bends the total.
Steps: 1. Take the inputs · 2. Multiply each input by its weight · 3. Add them up and add the bias · 4. Bend the total with an activation
✗ Think one neuron is clever on its own. ✓ See one neuron as a weighted sum and a bend.
Words: Weight, Bias, Activation
📌 Weights, then a bias, then a bend.
12. The Forward Pass opens the one-minute view
The forward pass is how a network makes a guess. Numbers go from the inputs, through each layer, to the output.
Steps: 1. Put the inputs in · 2. Work out each hidden neuron · 3. Work out the output · 4. Compare with the target
✗ Skip the activation on the hidden layer. ✓ Apply the activation before moving to the next layer.
Words: Layer, Hidden layer, Forward pass
📌 Input, hidden layer, output, then loss.
13. Backpropagation Without the Fear opens the one-minute view
Backpropagation finds how much each knob caused the mistake. It starts at the loss and passes the blame back, layer by layer.
Steps: 1. Find the blame at the output · 2. Work out the output knobs · 3. Pass the blame to the hidden layer · 4. Move each knob a small step
✗ Expect every knob to change after each step. ✓ Expect zero change behind a ReLU that was off.
Words: Gradient, Backpropagation, Learning rate
📌 Start at the loss, pass the blame back, multiply as you go.
14. Lab: Train a Tiny Neural Network opens the one-minute view
In this lab you train a small network on a pattern called XOR. You write the update step and watch the loss fall.
Steps: 1. Run the file and read the start loss · 2. Write the update step · 3. Print the rounded answers · 4. Try a bigger learning rate
✗ Add the gradient to each knob. ✓ Subtract the learning rate times the gradient.
Words: XOR, Seed, Update step
📌 Forward, loss, backward, update, repeat.
15. Making Training Work: Learning Rate, Batches and Epochs opens the one-minute view
Three settings shape training. The learning rate is the step size. A batch is a group of examples. An epoch is one full pass.
Steps: 1. Pick a learning rate · 2. Split the data into batches · 3. Train one epoch at a time · 4. Stop when validation loss stalls
✗ Change several settings at once. ✓ Change one setting, train again, and compare.
Words: Hyperparameter, Batch, Epoch
📌 Step size, batch, full pass. Change one at a time.
Models That Write Text
16. Tokens and Embeddings opens the one-minute view
A model only works with numbers. So text is cut into small pieces called tokens, and each piece gets a list of learned numbers.
Steps: 1. Take the text · 2. Cut it into tokens · 3. Give each token an ID · 4. Look up its embedding
✗ Using the ID numbers as if they were sizes ✓ Let each ID pick its own row of learned numbers
Words: Token, Vocabulary, Embedding, Dot product
📌 Tokens are the pieces. Embeddings are the learned numbers for each piece.
17. Predicting the Next Token opens the one-minute view
A text model looks at the text so far. It gives a chance to every possible next token, and the chances add up to 1.
Steps: 1. Read the tokens so far · 2. Give each next token a chance · 3. See the real next token · 4. Lower the loss a little
✗ Always taking the most likely next token ✓ Pick the next token using the chances
Words: Probability, Cross-entropy loss, Sampling
📌 Small loss means the real next token got a high chance.
18. Lab: Build a Tiny Text Generator opens the one-minute view
You build a text model that counts which letter comes after which. Then it writes new text by picking letters from those counts.
Steps: 1. Read the short text · 2. Count each pair of letters · 3. Turn counts into chances · 4. Pick letters by chance · 5. Write a longer text
✗ Removing spaces and full stops from the text ✓ Keep them, because they are characters too
Words: Bigram model, Random seed, Weight
📌 Count what follows what, then pick from the counts.
19. Attention and Transformers in Pictures opens the one-minute view
Attention lets each word look back at earlier words. It gives each one a weight, and the weights add up to 1.
Steps: 1. Compare with each earlier word · 2. Turn scores into weights · 3. Mix the earlier words by weight · 4. Repeat in many stacked blocks
✗ Thinking people set the weights by hand ✓ The weights come from knobs the model learns
Words: Query, Key, Attention weight, Transformer
📌 Score, turn into weights that add up to 1, then mix.
20. How Large Language Models Are Trained opens the one-minute view
Large language models are trained in three stages. First they predict next words, then they learn from examples, then from people's choices.
Steps: 1. Pretrain on next words · 2. Fine-tune on instructions · 3. Learn from human choices · 4. Use and check it carefully
✗ Thinking the model looks facts up while it answers ✓ Know that it predicts likely words from patterns
Words: Pretraining, Fine-tuning, Human feedback
📌 Pretrain, fine-tune on instructions, then learn from people's choices.
Training Your Own Models in Practice
21. Getting and Cleaning Data Responsibly opens the one-minute view
Before training, make sure you may use the data. Remove personal details. Then clean it and check that it is fair.
Steps: 1. Check you may use the data · 2. Remove personal details · 3. Remove copies and gaps · 4. Count each group for fairness · 5. Split and lock the test set
✗ Split the data first, then remove copies ✓ Remove copies first, then split the data
Words: Licence, Personal data, Bias
📌 Permission first, privacy second, then clean and check for fairness.
22. The Same Ideas in PyTorch opens the one-minute view
PyTorch is a free library that does the same training steps you did by hand. It works out the gradients for you.
Steps: 1. Predict with the model · 2. Measure the loss · 3. Clear old gradients · 4. Find new gradients · 5. Turn the knobs
✗ Forget to clear old gradients each step ✓ Call opt.zero_grad() before loss.backward()
Words: Tensor, Optimizer, nn.Linear
📌 Predict, measure, clear, backward, step. Run PyTorch on your own computer.
23. Fine-Tuning an Existing Model Instead of Starting Over opens the one-minute view
Fine-tuning means you take a model that is already trained. You train it a little more on your own small dataset.
Steps: 1. Pick a model whose licence fits · 2. Prepare your examples · 3. Test the base model first · 4. Train a little, slowly · 5. Compare the two scores
✗ Fine-tune without testing the base model first ✓ Test the base model first, then compare
Words: Base model, Fine-tuning, Licence
📌 Start from a trained model, teach it your task, and respect its licence.
24. Evaluating, Saving and Sharing a Model opens the one-minute view
Test the model once on data it has never seen. Report the true scores. Save it, and share it with a short label.
Steps: 1. Test once on the hidden set · 2. Compare with a simple baseline · 3. Save weights, code and settings · 4. Write a model card
✗ Report only the best-looking number ✓ Report all the scores and the baseline
Words: Test set, Baseline, Model card
📌 Test once, report honestly, and add a model card when you share.
25. Final Project: Train and Evaluate Your Own Model opens the one-minute view
Pick a small task and data you may use. Train a model, test it once, and write an honest model card.
Steps: 1. Choose a small task · 2. Get data you may use · 3. Clean, split and lock the test set · 4. Train and tune on validation · 5. Test once and write the card
✗ Hide a low score or round it up ✓ Report the real score beside the baseline
Words: Validation set, Test set, Model card
📌 Small task, fair data, one honest test, and a model card.
This page is a summary. It does not replace the lessons, where each idea has an example, pictures and practice.