Training vs Inference
Two jobs, not one
Training is when a network learns: it looks at examples, measures how wrong it is, and updates its weights. Inference is when that finished network is put to work: the weights stay frozen, and a new input is sent on a forward pass only.
An everyday picture is a student and an exam. Training is the months of study: read, try, get it wrong, adjust. Inference is sitting the paper. You do not rewrite the textbook in the exam hall. You use what you already know, once, on a question you have not seen.
The same split shows up in a kitchen. Training is recipe development: taste, add a pinch of salt, taste again. Inference is serving tonight’s bowl. The recipe is already written.
The left-hand side is the loop from Training a Deep Net: data in, a prediction, a loss, a backward pass, a small step on the weights. It is heavy work, often on many GPUs, for days or weeks. The right-hand side is the daily job: a prompt or an image goes in, the same frozen weights are used, and an answer comes out. Speed and memory matter more than “make the loss a little smaller.”
The chat example on the right also mentions a KV cache. That is an inference trick for language models, and we pick it up on LLMs: Inference. This page stays with a small network, so the two phases are easy to see.
This is inference
When you ask a chatbot “Why is the sky blue?”, the model is not studying a new textbook. It is using weights it already has. The question is the input; a short burst of computation is the forward pass; the paragraph you read is the output. No gradient is computed. No weight is moved.
That is the whole idea, in one conversation. The rest of this page makes the same idea precise on a tiny classifier.
A small ANN, two phases
Take handwritten digits. During training, the network sees thousands of labelled pictures — this is a 7, this is a 3, this is a 5 — and slowly adjusts its weights so that the predicted label matches the true one. The tool for that adjustment is backpropagation, the same downhill walk as in ANN: Gradient and in the micrograd labs.
During inference, those weights are frozen. A new, unseen picture of a 7 is shown to the same network. The numbers flow forward, once. The output says “this is a 7,” perhaps with a confidence such as 98.6%. Nothing is learned from that one picture; the next 7, or a 2, will use the same weights.
If you only remember one contrast: training is learn and update; inference is freeze and predict.
The inference pipeline, step by step
The forward pass is the heart of inference, but a real pipeline has a little work on either side of it.
1. Capture. A digit is written on paper or a tablet, or photographed. The raw picture is not yet in the shape the network expects.
2. Preprocessing. The picture is resized to \(28\times 28\) pixels — 784 numbers, one per pixel — and the values are scaled into a simple range, often 0 to 1. This is housekeeping, not learning. It only makes the input match what the model was trained on.
3. Forward pass. Those 784 numbers enter the input layer. They are multiplied by the frozen weights, a non-linearity such as ReLU is applied in the hidden layers, and ten output scores appear, one for each digit 0 to 9. Those raw scores are often called logits.
4. Softmax and a decision. Softmax turns the ten scores into ten probabilities that add up to 1. The largest one is the prediction. In the figure, the 5 has the highest logit and a probability of about 0.97, so the answer is “digit = 5,” with 97% confidence.
None of these four steps updates a weight. That is what “forward pass only” means.
Frozen weights, data flows forward
Here is the same idea on a slightly different task, so the picture of the layers is easy to stare at. A \(28\times 28\) picture of a handwritten letter “A” is fed to a network with 784 inputs, two hidden layers (128 and 64 units, with ReLU), and 26 outputs, one per letter. The output for A is high, about 0.82; B, C and Z are small.
During inference, data flows forward through the network. There is no backward pass, no gradient, no weight update. The weights are frozen; the model is making a prediction. If you want to change those weights, you are back in training, and you need a labelled example and a loss.
That is also why a trained micrograd MLP can already be used as a tiny inference engine: after the training loop in Lab#DL01-4 you just call the model on a new input. The engine still could backward; inference is the choice not to.
Where this goes next
The same split — train once, then run many times with frozen weights — is how a language model is served. The mechanics get more interesting: tokens, a prefill step, a decode loop, and a cache of recent work. That is LLMs: Inference.
In one table
| Training | Inference | |
|---|---|---|
| Goal | Learn: make the loss smaller | Serve: produce an output for a new input |
| Weights | Updated on every step | Frozen |
| Direction | Forward and backward | Forward only |
| Needs labels? | Yes, for the loss | No |
| Typical worry | Accuracy, overfitting, compute for days | Latency, memory, how many requests you can serve |
| Everyday picture | Studying for the exam | Sitting the exam |
FAQ
Is inference the same as “test time”? Almost. People say test time when they evaluate a held-out set after training, and inference when a finished model is used in a product. In both cases the weights are frozen and the data go forward. The next page, on language models, also talks about spending extra compute at test time (thinking longer). That is still inference, not a new training run.
If the weights are frozen, can the model still be wrong? Yes. Frozen only means “not learning from this input.” A confident, frozen model can still misread a messy 7 as a 1. Training is how you try to reduce that; inference is how you use whatever you have.
Why not update the weights on every live question? You could, in principle, but you would need a trusted label, you would risk forgetting earlier lessons, and you would make each answer slower and less predictable. The usual design is: train carefully, then infer often.
Does a bigger network change the split? No. A huge language model has the same two phases. Only the engineering around inference grows: caches, batching, special attention kernels. That is the story on LLMs: Inference.
See also
References
- [1] The training loop, the loss, and the downhill step are set out on Training a Deep Net and ANN: Gradient. The small MLP you can train and then call on a new input is Lab#DL01-4.
- [2] Handwritten digit classification is the classic textbook task (the MNIST \(28\times 28\) greyscale digits). The pipeline on this page — resize, normalise, a small fully connected net, softmax — is the usual first version of that task, not a particular published model.
- [3] Serving language models, and the KV cache mentioned in the first figure, are taken up in LLMs: Inference.




