Guides 5 min read By Bill Keeling-Ogilvie

AI Part 1: How AI Works

As a software developer at a company that is an early adopter of new tech, and as an early adopter myself, AI has been present in my life for a number of years now. From mid 2024, my day job began transforming from me solving problems and writing code all day, to me prompting an AI all day while it writes about 90% of the code. Some days, leaving me with yet more problems to solve.

For the non-tech versed, and even for those who work with AI on a daily basis, it can just seem like a magic black box. So in order to better convince you that I know at least a little bit about what I am talking about, let’s build a hypothetical, oversimplified AI together. I hope this gives you a small insight into how AI actually works. I will feel better too because at least one more person in the world (Hi mum!) will come away from this having a better understanding of these new tools we rely so much upon. This high level guide is aimed at the general AI consumer who uses apps like ChatGPT, Claude and Gemini.

Let’s build

The model

You can think of the model as the engine of our AI. It is the part that predicts what comes next. Examples of models are GPT-6, Opus 5 etc.

To create one, we need an algorithm: a fancy word for “a set of instructions”. This algorithm learns from data we feed it. This could be volumes of text, images, video etc. It uses what it learns to adjust millions of parameters to build our model. During that process, the model develops its own internal map of patterns and relationships, which we call “latent space”. You can think of latent space as a very complicated 3D graph with far too many data points to care about. In reality, it can have thousands of dimensions, though 3 works for our example. This process is called training. Once trained, the model uses this latent space to make predictions about new inputs it hasn’t seen before.

Training the model

How should we train our model? Let’s provide the algorithm with lots of data on colours. Over time, it maps the relationships in the model’s latent space, and learns that if you mix blue and red, you get purple. Then, we feed it lots of data on farm animals. It maps the relationship between pigs and the word “oink”. Finally, we give it vast amounts of data on European countries. It now knows about France and French stereotypes.

We just trained a model whose latent space forms a sort of map-and-mixer that is used to make predictions. We can now ask it* for a story about a “reddish, blue oinky boy at the Eiffel Tower”. It finds those relationships in its latent space, predicts a story about a purple French pig, and presents us with it. His name is Montgomery, and he wears a little beret and cravat. Our AI may be biased, but that is another topic for another day.

For the sake of accuracy, it does not predict the story all in one go. It goes token by token (a token is roughly a character, part of a word, or a whole word depending on context) and predicts the next most likely token based on the overall context and surrounding tokens. While this is monumentally impressive, we need to remember that in its current form, it only simulates emotions and a continuous subjective experience.

* Your prompt actually goes through the ‘harness’, and it uses the model to make predictions, but this is an extra layer of complexity and not really relevant for every day AI use. If you want a mental model for the harness, just think of it as the middle-man between you and the model. Using the engine analogy again, it is the rest of the car and you are the driver.

A thought experiment

Let’s pause for a brief thought experiment to illustrate how the model makes these predictions. I need you to finish these lyrics to a new children’s song for me. “Shoulders, elbows, wrists and…”. How many people might answer “fingers”, and how did they arrive at that answer. Pattern recognition and prediction! We do it too, and we are very good at it.

One important distinction between a human mind and an AI however, is that when the AI completes this task, it does not have a subjective experience to draw from. No fond childhood memories of singing “Heads, shoulders, knees and toes” in school. No trauma attached to that song from that one time a clown chased it through the woods singing it in that creepy clown voice. And it forgot, or simply does not “get it”, that your beloved pet fish “fingers” just died in a tragic hot air balloon incident and that maybe “fingers” is not the best answer for you to hear right now. At best, it just has more relationship data points to draw from. It is important to remember that AI does not know what a song is any more than two 2s know they are 4, but it can point to “song” on a map.

This should give you a high-level grasp of how AI works. Using it effectively though is a whole other topic. I’ll be writing a part 2 that introduces a few more useful concepts and provides an overview of how to get the most out of AI day to day. Part 3 will wrap things up with my opinions of AI and how not to use it.

Share
← Back to writing