AI for Normal People #1 | LLMs from Back-to-Front — Models

Home | Back to Blog Index | Prev | Next Coming Soon

2026-07-11

For the first few entries in this series, I am going to be focusing on a specific class of AI system: Large Language Models (LLMs). This is mainly because LLMs are by far the most visible thing that most people will think of when they hear "AI". These are the models behind ChatGPT, Gemini, Claude, DeepSeek, and many more you may or may not have heard of. The next reason is that most of my experience within the field is with LLMs. They were a key part of my thesis, and have now become an everyday tool for the work of many (perhaps most) software engineers.

First, I will be explaining what a Large Language Model is in reverse order, since this is the best way to make sense of these suddenly ubiquitous tools, starting with "Model".

What is a Model?

A model solar system. Public domain image

"Model" is obviously not just a machine learning term. In general, a model is a "simplified picture of something that actually exists". We make models all the time for all sorts of things. The image above is a model solar system; we refer to fashion "models" because they show you what clothes would look like under ideal circumstances; people use "model" trains to show how a real train would move around some shape of tracks.

Models are useful, but because they're all simplifications of reality, we can only get useful answers out of them if we ask them the right questions. If you ask the above model solar system what order the planets are in by distance from the Sun, it will give you the correct answer. But if you ask how far the planets are from each other, or how big they are relative to each other, it will be very wrong. Similarly, a fashion model won't tell you anything useful if they are a foot taller than you. They need to be roughly your height and build to be of any use in showing you what some clothes might look like if you bought and wore them.

Thus, the key to making good use of any kind of model is to understand exactly what kinds of questions they are designed to answer and what questions you are actually asking them, and ensuring those two line up.

Models in Machine Learning

When we talk about "models" in machine learning, we're talking about statistical models. These aggregate patterns to answer questions, and it turns out that pattern recognition is surprisingly hard for computers to do.

Before we see how pattern recognition applies to words (which we'll cover in the following post), it's easiest to see it in action with images. Suppose I gave you a giant stack of photos and asked you to sort them into piles, one with pictures containing birds, and one without. You are not allowed to look at them. You can only write down a list of rules which use the colour of the pixels in each photo to determine if it contains a bird or not. We can only use pixels because computers don't have eyes; to them a photo is a grid of coloured dots, each represented only with numbers.

This is nearly impossible. There are many different kinds of birds, which can take many poses or be in many different backgrounds. In fact, even if you did know there was a bird in a picture, you'd probably have a hard time even telling which pixels were the bird and which weren't from their colour alone.

xkcd.com/1425

A machine learning approach is different. Rather than writing rules by hand, we let the computer discover statistical patterns that usually separate bird photos from non-bird photos. But these patterns have to be stored somewhere. A machine learning model doesn't store them as a list of rules in English or a programming language. Instead, it uses a huge collection of numbers called weights (or parameters). The model itself is a chain of mathematical calculations. Each operation takes the image, combines it with some of these weights, and passes the result to the next operation in the chain until the last operation produces an answer like "90% chance this image contains a bird."

Input photo Calculations 90% bird [0.81, -1.25, 3.79] Weights

Training Models

The problem is that we don't know what the best weights should be for any given task. If you have to set a billion weights in a model which will detect birds for us, you're going to have a very hard time. This is where the "learning" in machine learning comes from. Instead of setting them ourselves, we use an algorithm to "train" the model to find the best weights for our task.

These weights are set randomly to begin with, so the output is essentially a new random guess for each new input. This is obviously not very good but what makes machine learning so powerful is that we can improve the weights, little by little, until they consistently produce a result we actually want.

Wrong Right Initial weight Wrong Right After one example

To do this, we need a "training dataset". This is a large number of examples, and labels for the examples. In the case of our bird detector, this would be a large number of photos with descriptions of what are in them. We can run each photo through our model to get the output, but because we already know which photos contain birds, we can calculate how wrong the output was. Then, using some maths that I won't get into here [1], we can find a tiny change for every weight in the model that would have made it a little bit more correct.

If you do this with enough examples, the model's weights should slowly move towards something that consistently gives us the right answers. If our dataset has many different kinds of bird in it, the differences between them, like their size or colour, should cancel each other out and we should be left with just their similarities — the core of "birdness", like beaks, feathers, and wings [2].

Inference

At the end of training, if we've done it right, we're left with a pipeline of mathematical calculations and weights to go with them that will give us an output that aligns with our expectations. This is what people are talking about when they refer to a "model": the combination of weights and calculations that converts input to output. The process of the conversion (running all the equations with a single input to get a single output) is called "inference".

At this point, we freeze the weights and deploy the model to whatever real task we care about (classifying birds). The main reason we keep training and inference separate is that training is hard and takes a lot more computation than inference, since you have to both produce the output and work out how wrong that output was to update the weights again. The weights don't have to be frozen forever, though. If we want to expand the training dataset, we can always resume where we left off.

When we have a model performing inference, our hope is that, by seeing enough different examples, the model will also make good predictions for new images it has never seen before because it has found the patterns it needs to be correct about future images. The ability for a model to do this is called generalisation, and training models that generalise well is the whole aim of machine learning.

What Models Learn

What's important to keep in mind is what a model, any model, actually learns to do, which is "to be as not wrong as it can about the data it was trained on".

"Not Wrong-ness"

As I noted earlier, when training a model we calculate how wrong it was about a particular output, given the output we were expecting. In our bird case, we might put in a picture that we know contains a bird, and get something like "65% chance this contains a bird". Because our answer card (which the model never saw) says it definitely contains a bird, this means that the model is partly right, but somewhat wrong about the image. If it had said there was a 20% chance of bird, then it would be much more wrong. As such, in the 65% confident case, we nudge the weights in the model a little bit so that next time it would be 70% confident about the same image, and in the 20% case we nudge them a lot, so that next time it will be 50% confident.

While we could push every weight all the way to being perfectly right about one image, this would make the model worse (perhaps much worse) for every other image, since every image will have different weights that produce the 100% most correct result. Instead, we calculate a small change and do this many times. The equation that we use to calculate the model's "wrongness" is called the loss function.

Training Data

The other important thing to keep in mind is that the model has not seen absolutely every image ever taken of every bird, and certainly not every image that could ever be taken. The model only ever received weight updates for images that we provided to it during training. If many of these were mislabelled (a bunch of pictures of bats got into our training set and we said they were birds, for example), then the model's weights will be updated in the wrong direction.

Alternatively, there might be subtle biases in our training data. Suppose that all the pictures we took of birds were in flight, while everything else was on the ground. Then, if we gave our model a picture of a bird sitting on the ground or in a tree, it would probably not find the bird. During training the model will probably notice that every photo containing a bird also has a whole lot of light blue pixels. Our process for updating model weights incentivises them to look for the path of least resistance. If it can always check the colour of the top-right pixel and be correct, then there's no need to learn what birds actually look like.

In this case, there is a mismatch between the questions we think the model is answering ("does this have a bird in it?") and those it is actually answering ("is the top-right pixel in this image light blue?").

What About Language?

We've discussed detecting birds in this post because it's an easy example to show what models are and how they work. The core idea is that, for all kinds of models, be they fashion, bird detectors, or LLMs, we have to make sure the questions they answer align with the questions we ask. Once we understand how models learn to recognise birds, we'll see that LLMs use the same principles, only with words rather than pixels.


[1] Partial derivatives and the chain rule, if you happen to remember high school calculus

[2] This isn't exactly how the maths works, but it's a useful way to think about what we're trying to achieve. Researchers have cracked open models to look inside and found that some of the time they do tend to find traits that we would recognise as feather-y or beak-y, but often they're doing something stranger and it's not always obvious why — we only know that whatever they're doing, they get the right answer in the end. One of the many things that makes machine learning interesting.