Sometimes, when I’m feeling lazy or tired and someone asks me whether AI is magic, I just say, “Yeah, pretty much.” It’s a poor answer from someone who does this for a living, but you can probably see why I’m tempted. You type a question into a box and get back something that would have taken you half the morning to put together.

So this is my attempt at giving a slightly better answer.


A brief history

You’ve probably been using AI for years without giving it much thought. It’s been working away inside the services we use every day, often without an “AI” label anywhere in sight. The field itself goes back to the 1950s, and the technology getting so much attention today is one part of a much bigger picture.

IBM diagram showing machine learning within AI, deep learning within machine learning, and the emergence of generative AI.
Source: IBM. The dates give a broad sense of the field’s development, rather than precise invention dates.

When OpenAI released ChatGPT on the 30th of November 2022, initially using a model from the GPT-3.5 series, it gave people a very direct way to experience what this technology could do. You could ask a question, get a coherent answer, and carry on the conversation back and forth. It was revolutionary at the time.

ChatGPT is an example of generative AI, which means it’s an AI that creates content. Initially that meant text, although today’s generative AI tools can create images, music, video and more. To see how we got there, it helps to work through the layers in the diagram.

Machine learning

Machine learning is a branch of AI in which a system learns patterns from data. For example, you can train an email spam filter using messages that have already been identified as spam or legitimate email. It learns patterns that help it recognise potential spam in new messages, without someone having to write a separate rule for every possible scam.

Machine learning helps Netflix recommend shows you might like and Amazon suggest products you might want to buy. Most of us would simply think of these as useful features, without necessarily recognising them as AI.

Deep learning

Deep learning is a type of machine learning that uses neural networks. These process information through successive layers, learning increasingly complex patterns in text, images and sound.

Unlocking an iPhone with Face ID is one example of deep learning playing out in everyday life. Recognising speech when you dictate a message into your phone is another. Your phone needs to recognise your face in different lighting, or understand the same words spoken by different people.

The categories overlap. Deep learning is still machine learning, and a recommendation system or spam filter might use it too.

Today’s generative AI builds on these developments. For this article, I’m going to concentrate on large language models, usually shortened to LLMs. These are the models that process and generate language (text) in applications such as ChatGPT or Anthropic’s Claude.

How is an LLM trained?

When we say an LLM is “trained”, we mean it learns patterns from large amounts of material. The companies developing these models use text from across the internet, including articles, forums and websites, alongside books, research papers, computer code and other sources. The mix varies between models.

During training, the model is shown some text and tries to predict what comes next. Its prediction is compared with the original text, and the internal workings inside the model are adjusted to help it make better predictions. These internal workings are really just numbers, which in the industry are called parameters. The animation below shows this process slowed down. In practice, it’s repeated over enormous amounts of material.

How a language model learns. Use the video controls to play, pause or replay the animation.

Through this process, the model learns patterns in how language works and how ideas relate to one another. Those patterns can capture factual information, ways of explaining things and methods for solving problems. This helps explain how the same model can draft an email, explain a scientific concept or write computer code.

The range of subjects covered is enormous. Each dot in the image below represents a web document from OBELICS, a dataset created for training AI. The full map brings together 11 million of these documents, grouped by topic.

Click the image to open the interactive map in a new tab. Give it a moment to load, then zoom in and click on individual dots to explore the documents behind them. It’s a useful way to get a feel for the variety of material used to train AI.

A close-up of the OBELICS map, with coloured dots grouped around topics including the economy, climate change, energy and clinical research.
Explore the map on Nomic Atlas (opens in a new tab). About the OBELICS dataset.

What happens when you ask a question?

Once an LLM has been trained, it can use those learned patterns to respond to you. Your question goes into what’s called its context, along with information such as the conversation so far, any documents you’ve supplied, and instructions from the application.

I wanted to show this happening slowly enough that you can follow it, so I’ve used a simple example in the animation below. Watch what happens as each word is added to the answer.

A joke, one word at a time. Use the video controls to play, pause or replay the animation.

I’ve shown whole words to make the animation easier to follow. LLMs actually work with tokens, which can be words, parts of words or punctuation.

Inside the model, tokens are represented by numbers. The model processes these through its neural network, using the parameters it learned during training. A vast number of calculations produces probabilities for which token could come next. This happens rapidly, over and over, as the response takes shape.

Once a token has been selected, it becomes part of the context for the next pass. The answer builds up through that repeated process. The probabilities shown are illustrative, and the animation always selects the highest. Real systems can select from several likely options, which explains why asking the same question twice can produce different answers.

Attention Is All You Need

Most current LLMs use a type of neural network called a transformer. That’s the “T” in GPT, which stands for Generative Pre-trained Transformer.

A key part of a transformer is a mechanism called attention. This allows the model to give different weight to different parts of the context as it processes each token, helping it pick up relationships between words and ideas.

Take the sentence “The dog couldn’t fit through the gap because it was too narrow.” With your human intelligence you know that “it” refers to the gap. Change “narrow” to “big” and you’d know “it” meant the dog. Attention helps an LLM use the surrounding words to make connections like this.

Why GPUs matter

All those calculations help explain why graphics processing units, or GPUs, have become so important to AI. GPUs were originally developed to create and display computer graphics, including those in video games. To do that, they need to handle lots of calculations at the same time.

That turns out to be useful for AI too. Neural networks involve a lot of calculations using grids of numbers, known as matrices. GPUs can handle many of those calculations at once, making them well suited to both training models and running them.

Tools and software

So far, we’ve looked at how an LLM generates text. But the LLM is just one part of it. The software which houses the LLM can also give it access to tools, allowing it to look things up and carry out tasks. Examples of tools are web search, document readers, calculators, tools that run code, and connections to other apps such as email, calendars or customer databases.

For example, if you ask the AI for a supplier’s latest prices, the LLM can request a web search. The surrounding software runs that web search and returns the results to the model, which can then use them in its answer. That gives it information beyond what it learned during training. This all happens at lightning speed.

AI is not like Googling

Asking an AI a question works differently from a traditional Google search. Google finds existing websites that match your search. An LLM generates a brand new answer using what it learned during training and the information in your conversation.

AI tools can also search the web, and Google now includes AI-generated answers, but finding information and generating a response are different processes.

The same process can extend to taking action. If you ask it to update a customer’s address in a database which it is connected to, it can do that too, provided it has access to the system and permission to make the change. The model requests the change. The software carries it out and tells the model what happened.

This can happen several times within one task. The model gets a result back, uses it to decide what to do next and requests another tool if needed.

The harness

All of this needs organising. Something has to assemble the conversation and relevant documents, tell the model which tools it can use, handle its requests and pass back the results. You’ll often hear this surrounding software described as a harness.

The term is used fairly loosely. Alongside tools and context, a harness can manage permissions, approval steps and a record of what happened. Its architecture is simply how those parts are arranged and connected.

It can also manage memory. An application might save a preference or a summary of previous work, then bring it into the context of a later conversation. That gives the model information it can use next time, without having to train it again.

Call it magic

AI has been part of everyday life for decades, often working quietly in the background. Now we can chat with AI directly, describing what we want in ordinary language and developing an idea through conversation. That makes it useful for a much wider range of tasks, including ones we might never have thought to use software for.

It can still feel like magic. But there’s a mathematical process behind it, and hopefully this has made that a little clearer. Next time someone asks me, I should probably make the effort to explain. Or just send them this article.

A short glossary

Term What it means
AI The broad field concerned with systems that perform tasks involving abilities such as learning, reasoning and decision-making.
Machine learning Techniques that learn patterns from data and apply them to new examples.
Deep learning Machine learning using neural networks with multiple layers.
Generative AI AI that produces content such as text, images, audio or video.
Model The trained mathematical system used to process inputs and produce outputs.
LLM A large language model is trained on large amounts of text and other material to process and generate language.
Transformer A type of neural network that uses attention to process relationships between parts of its input.
GPT Generative Pre-trained Transformer, the name of OpenAI’s GPT model family.
Training The process of adjusting a model’s parameters using examples and feedback.
Prompt The request or instructions you give the system.
Token A unit the model processes, often a word, part of a word or punctuation.
Context window The limit on how much information a model can work with in one go, measured in tokens.
Inference Running a trained model to produce an output from an input.
Tool A capability the system can call, such as search, calculation or access to a business application.
Harness The surrounding software that manages context, tools, execution and controls.
Agent A system that uses a model to choose and carry out steps towards a goal.
Credits A provider’s unit for charging for usage. Credits aren’t the same as tokens. The relationship depends on the service and task.

The names you’ll come across

Company names, model names and product names often get used interchangeably. It helps to separate them.

Company Product
OpenAI ChatGPT
Anthropic Claude
Google Gemini
Microsoft Copilot

The product is what you interact with. Its models, tools, connections and permissions determine what it can do. A familiar product name alone won’t tell you whether a particular feature or integration is available in your version.