AI models, explained

A short story about the main kinds of artificial intelligence model, how each one learns, and what each one is good at.

Scroll down to read the chapters in order, or use the menu to jump to any of them.

What is an AI model?

An AI model is a program that has learned patterns from examples instead of being given step-by-step rules. Show it enough examples and it can make a useful guess about something it has not seen before.

Training and using

A model is built in two stages. In training, it looks at a large collection of examples and adjusts a very large set of numbers, called parameters, until its guesses get better. In inference, the finished model uses those numbers to answer new questions.

Why there are different kinds

Different jobs need different designs. Writing a paragraph, painting a picture and spotting a spam email are different problems, so researchers have built different families of model for them. The next chapters walk through the most important ones.

Large language models

A large language model, or LLM, is trained on a huge amount of text to predict what comes next. Given some words, it works out which word, or piece of a word, is likely to follow. Repeating that step one piece at a time produces whole sentences and pages.

How it works

Most modern LLMs use a design called the transformer, introduced in a 2017 research paper titled “Attention Is All You Need.” Its key idea, attention, lets the model weigh how much each earlier word matters when it picks the next one. Text is first split into small units called tokens.

What they are good at

Things to keep in mind

An LLM can sound confident and still be wrong. It predicts likely text, so it is worth checking facts that matter.

Diffusion models

A diffusion model creates new content by starting from random noise and removing the noise, a little at a time, until something clear appears. Diffusion models are widely used to generate images, and the idea has also been applied to audio and video.

How it learns

During training, the model is shown real examples that have had noise added to them in many small steps. It learns to undo that damage one step at a time. To make something new, it runs the same process starting from pure noise.

Following a prompt

Many diffusion models can be steered by a written description. The text is turned into numbers that guide each denoising step toward what was asked for.

GANs and VAEs

Before diffusion models became popular, two other families were common for generating images and other data: generative adversarial networks and variational autoencoders.

Generative adversarial networks (GANs)

A GAN, introduced in 2014, trains two networks against each other. The generator tries to make convincing fakes. The discriminator tries to tell fakes from real examples. Each improves by competing with the other, until the generator’s output is hard to tell from the real thing.

Variational autoencoders (VAEs)

A VAE has two halves. An encoder squeezes an example down into a short list of numbers, and a decoder rebuilds the example from that list. Once trained, you can choose new numbers and let the decoder create something new that resembles the training data.

The trade-off

GANs are known for sharp results but can be tricky to train. VAEs tend to train more smoothly but can produce softer, blurrier results.

Other kinds of model

Generating text and pictures is only part of the picture. Many other models are built to recognise, sort or predict.

Classification and prediction models

These take an input and give back a label or a number: whether an email is spam, which category a document belongs to, or an estimate of tomorrow’s demand.

Convolutional neural networks

Convolutional networks are designed for images. They scan for simple patterns such as edges and build up to complex ones, and are widely used for recognising what is in a photo.

Recommendation models

These suggest items a person might like, based on patterns in what many people have chosen.

Reinforcement learning

A reinforcement learning system learns by trial and error. It takes actions, receives rewards or penalties, and gradually learns which actions pay off. It has been used to train game-playing programs and to control robots.

How they compare

Here are the families from the earlier chapters side by side.

Main model families compared
FamilyTypical outputCore idea
Large language modelText, codePredict the next token
Diffusion modelImages, audio, videoRemove noise step by step
GANImages and other dataA generator competes with a discriminator
VAEImages and other dataEncode to numbers, then decode
Classifier or predictorA label or a numberLearn patterns that map input to answer

Choosing between them

The best model depends on the job. Start from what you need as output, and the right family usually becomes clear. Real products often combine several kinds.

Closing

AI models are tools that learn patterns from examples. Language models predict words, diffusion models clear away noise, GANs and VAEs learn to generate by different routes, and many other models recognise and predict.

Three things to remember

  1. A model is only as good as the examples it learned from.
  2. Different jobs call for different kinds of model.
  3. Fluent output is not the same as correct output, so check what matters.

Thanks for reading. Scroll back up to revisit any chapter.