Lesson 1 of 57
AI, Machine Learning, and Neural Networks
Today, when people say "AI", they almost always mean one thing: a large language model (LLM), the kind of model behind ChatGPT, Claude, and Gemini. The word "AI" is much older than that, and it covers much more.
This lesson explains four terms that are used in every later lesson: artificial intelligence, machine learning, neural network, and deep learning. Each one is a smaller area inside the one before it, and large language models sit in the innermost area.
After this lesson you can say what each of the four terms means, explain why a chat app and the model behind it are two different things, and describe in plain words how a model is trained.
| Term | Short meaning |
|---|---|
| Artificial intelligence (AI) | Computers doing work that normally needs human thinking |
| Machine learning (ML) | Building such a system by training it on data instead of writing its rules by hand |
| Neural network | One kind of machine learning model: layers of adjustable numbers |
| Deep learning | Machine learning with neural networks that have many layers |
| Model | A thing that turns an input into an output |
| Training | Adjusting a model's numbers until its outputs match known answers |
flowchart TB
subgraph AI["Artificial intelligence: the goal"]
subgraph ML["Machine learning: learn the rules from data"]
subgraph NN["Neural networks and deep learning"]
LLM["Large language models"]
end
end
endThe diagram shows how the terms nest. Every large language model is a neural network. Every neural network is built with machine learning. Machine learning is one way of building AI.
1. AI is older than chatbots
AI became famous because of large language models, but people used AI every day long before that. Three common cases:
| Where | What you see | What the AI decided |
|---|---|---|
| An online shop | A "Recommended for you" row | Which products to show you, based on what you bought before |
| A video site | "Watch next" and "More like this" | Which video goes at the top of your feed |
| A bank | One payment marked "unusual activity" | Which transaction, out of thousands, looks suspicious and should be held for a check |
None of these systems chat with you. Most people never notice them. They are still AI.
So the term "artificial intelligence" was in use for decades before large language models existed. Large language models are a recent part of the field, and they are the part most people now think of first.
2. AI is an umbrella term
Product recommendations, video recommendations, fraud detection, and large language models work in very different ways. They share one name because they share one goal: teach a computer to think or work like a human would.
This means "AI" does not name a technique. It names the goal, whatever technique is used to reach it.
3. Narrow AI and broad AI
AI systems differ in how many kinds of work they can do.
| Good at one specific thing | Useful across many areas |
|---|---|
| Flagging a suspicious transaction | Writing, translating, summarising |
| Ranking the next video in a feed | Explaining something, or planning a job |
| Reading a postcode off an envelope | Deciding which step to take next |
| Narrow, and usually invisible to the user | This is where large language models sit |
A fraud detector is very good at one job and cannot do any other. If you asked it to translate a sentence, it would have no way to answer. A large language model is different because one model can help with many unrelated jobs.
4. Two classic areas: computer vision and language processing
AI is made of several fields. Two of them come up again and again in this course.
Computer vision is the field of getting computers to understand pictures. A picture goes in, and a statement about what is in it comes out. For example, a photo goes in and the label "person" or "car" comes out.
Natural language processing (NLP) is the field of getting computers to understand human language. A sentence goes in, and something the computer can act on comes out. Take the sentence "book a table for four". An NLP system breaks it into parts:
| Part of the sentence | What it means to the system |
|---|---|
| book | the action |
| a table | what to book |
| for four | how many |
The result is a request that a booking program can carry out.
5. A model is not a product
When you use ChatGPT, GitHub Copilot, or Claude Code, it feels like you are talking to "the AI". In fact you are using a product that has three layers.
| Layer | What it is |
|---|---|
| The product you open | ChatGPT, Claude, GitHub Copilot, and similar apps |
| The agent, also called the harness | The software wrapped around the model that lets it act |
| The model | A large language model. Text goes in, text comes out |
The names you know are the top layer. The model sits two layers below.
The reason for the middle layer is that a large language model can only do one thing: read text and write text. It has the intelligence, but it has no hands. It cannot open a browser, read a file, or write a file on its own.
So the model makes a decision and writes it down as text, for example "read the file report.txt". The software around the model reads that text and carries out the action on your machine.
flowchart LR
M["The AI model<br/>text in, text out<br/>makes the decision"]
subgraph H["The software around it (agent or harness)"]
A1["Open the browser"]
A2["Read a file"]
A3["Write a file"]
end
M -- "decides what to do" --> H
H -- "sends back the result as text" --> MThe model supplies the intelligence. The product is everything that is built around it. This split between "model" and "the software around the model" is used in almost every later lesson.
6. Machine learning: learn the rules from data
Machine learning (ML) is a subfield of AI, and it is the way nearly all modern AI is built.
There are two ways to build a system that makes decisions.
| The old way: write every rule | Machine learning: train on data |
|---|---|
| A person spells out the conditions | You show the system many examples |
| A person spells out the checks | It finds the patterns itself |
| Every case must be thought of in advance | The rules are never written down |
| If nobody thought of a case, the system cannot handle it | This is how modern AI is built |
In machine learning, the thing you train is called a model. A machine learning model works out useful patterns from data on its own, instead of following decision rules that a person wrote by hand. The patterns are stored inside the model as numbers called parameters, which section 9 explains.
Training a system instead of writing its rules changes the work of the people who build it:
- The system can change and grow over time, because it can be trained again on new data.
- The team behind it supplies data and checks results. It does not write rules.
- The team does not have to predict every possible situation in advance.
7. An example that is not machine learning: enemies in a game
Think of the enemies in a computer game. They often seem clever, but most of them were not trained on anything. They follow a list of rules that a programmer wrote by hand:
If health is low -> take cover
If outnumbered -> run away
If the player is near -> attack
... and so onFor a game, this is fine. A game is a controlled space. The set of things that can happen is fixed in advance, so a programmer can list a rule for each one. The real world is not like that.
Putting a real, large AI model inside the game would not work well, and the reason has nothing to do with gameplay. Such a model is expensive to train and develop, and it needs high-end hardware to run. That would put the game out of reach for most players. A fixed list of rules costs none of that.
The difference in one line: a game enemy follows rules that someone wrote, and a language model follows patterns that nobody ever wrote down. The model was trained, not programmed.
Large language models, recommendation systems, and almost all other modern AI are built with machine learning. Because of that, they are flexible. They are not limited to the cases someone thought of in advance, because they work from patterns in the data they were trained on.
8. Neural networks and deep learning
A neural network is a special kind of machine learning model. The name comes from the brain.
In a brain, living cells called neurons pass signals to each other. An artificial neural network copies that idea in software. There are no cells. There are boxes that hold numbers, connections between the boxes, and the numbers can be changed.
| In a head | On a computer |
|---|---|
| Living cells | Boxes holding numbers such as 0.42, 0.31, 0.88 |
| Signals passing between cells | Connections between the boxes |
| Learning changes the cells and their links | Training changes the numbers |
The brain picture is only a loose comparison. It explains where the name came from. It does not mean a neural network thinks the way a brain does.
Deep learning means machine learning with neural networks that have many layers. "Deep" refers to the number of layers. The two terms, neural networks and deep learning, are usually mentioned together.
9. The plain definition: a parameterized model made of layers
Without the brain comparison, the definition is this: a neural network is a parameterized model made of connected computational layers. Each word has a plain meaning.
| Word | Meaning |
|---|---|
| Model | A thing that turns an input into an output |
| Parameterized | Full of numbers that can be adjusted. Each number is called a parameter |
| Layers | The numbers are arranged in stages, and each stage feeds the next |
Data goes in on one side. It passes through the first layer, where it is combined with that layer's numbers. The result goes to the second layer, and so on. At the end, something new comes out.
flowchart LR
I["Data in"] --> L1["Layer 1<br/>0.42, 1.07, 0.19 ..."]
L1 --> L2["Layer 2<br/>0.88, 0.31, 0.64 ..."]
L2 --> L3["Layer 3<br/>0.42, 1.07, 0.19 ..."]
L3 --> L4["Layer 4<br/>0.88, 0.31, 0.64 ..."]
L4 --> O["A new outcome<br/>(new text, for ChatGPT)"]The numbers inside each layer are the parameters. In the end a neural network is a very large set of numbers, organised in layers. What comes out depends on what the network was built for. For ChatGPT, the outcome is new text.
A shop makes this concrete. Think of a product recommendation system:
flowchart LR
P["Bought in the past<br/>Running shoes (Mar)<br/>Water bottle (Apr)<br/>Rain jacket (Jun)<br/>Head torch (Sep)"]
N["The network<br/>layers, connections,<br/>and numbers"]
R["Recommended for you<br/>a new list of products"]
P --> N --> RA list of products the shopper bought goes in. It passes through all the layers. A new list of recommended products comes out.
10. Where the numbers come from: training
A network can hold billions of numbers. Nobody sits down and types them in. They are worked out by running examples through the network itself. This process is called training.
Training needs examples where the correct answer is already known. For the shop:
- The input is data you already have: a shopper's past purchases.
- The known output is what that shopper really bought next. This is on file, so it is known in advance.
flowchart LR
X["Example input<br/>a past purchase list"] --> N["The network being trained"]
N --> G["The network's guess"]
G --> C{"Compare with the<br/>answer already known"}
C -- "adjust the numbers a little" --> NDuring training, the network sees the input and makes a guess. The guess is compared with the known answer. Then the network's numbers are adjusted a little so that the next guess is closer. This is repeated over a very large number of examples until the network's outputs line up with the known answers.
So during training, you already know the answer. You adjust the model until its output matches what you expect.
11. The same network in training and in production
After training, the network is taken out of training and put to work. This is called using it in production. The network is the same. The situation is different.
| In training | In production |
|---|---|
| Both sides are known | Only one side is known |
| A past purchase list goes in | A real shopper's purchases go in |
| What they bought next is on file | What they will buy next, nobody knows |
| The numbers are adjusted until the two agree | Recommendations come back out |
In production there is no answer to compare against. The network uses the numbers it learned in training to produce its best output for an input it has never seen.
Large language models work this way too. They are neural networks that were trained on examples and are then used on new inputs. The next lesson explains what those examples were and what an LLM does with them.
12. Two common questions
These two questions come up as soon as people start using AI coding tools. Both answers use the word token. A token is a small chunk of text, a whole word or a piece of one, and it is the unit a language model reads and writes. The lesson on tokens covers it in full.
1. Are tokens created on the client, for example inside a coding agent? How does the client know the token counts?
No. For a hosted model, tokens are created on the provider's servers, not in the app on your machine. The steps for one request are:
sequenceDiagram
participant C as Client (chat app or coding agent)
participant S as Provider's server
C->>S: Request, sent as plain text
Note over S: Tokenizer turns the text into tokens
Note over S: Model reads the tokens and writes new tokens
Note over S: Tokenizer turns the new tokens back into text
S->>C: Reply as text, plus a usage report- The client sends the request as ordinary text.
- On the server, a tool called the tokenizer splits that text into tokens.
- The model reads those tokens and produces new tokens as its answer.
- The tokenizer turns the new tokens back into text, and the server sends the text to the client.
The client knows the counts because the server reports them. Every reply comes with a small usage report, similar to this:
usage:
input_tokens: 1284
output_tokens: 412A coding agent reads these numbers from each reply and adds them up. That is where its "tokens used" or "context used" display comes from. The server is the one that did the counting, and the same numbers are used for billing.
A client has two other ways to get a count before sending anything:
- Ask the provider. Some providers offer a separate token-counting request. The client sends the text and gets back the number of tokens it would use, without running the model.
- Estimate locally. Some providers publish their tokenizer, so a client can run it on your machine and count exactly. Where the tokenizer is not available, a client can use a rough rule such as one token for about four characters of English text. That gives an estimate, not the exact figure.
There is one case where everything happens on your machine. If you run a small model locally, as described in the next lesson, the tokenizer and the model both run on your computer, so the tokens are created there.
2. How does a language model understand and write code? Was the same code already in its training data? How does it predict the next token?
To a language model, code is text. It is split into tokens in the same way as an English sentence. The training text included a very large amount of public code in many programming languages, along with documentation and questions and answers about code. So the model learned code the same way it learned language: by finding patterns in examples.
The model does not store the programs it saw and look them up later. Training does not save text. Training adjusts the model's parameters, as section 10 described. What stays in those numbers is patterns, such as:
- the grammar of each language: where brackets close, how a loop is written
- common ways to do common jobs: reading a file, sorting a list, calling a web service
- how names relate to behaviour: a function called
totalusually adds things up
This is why a model can write code it has never seen. Your project did not exist in its training data, but the patterns your project is made of did. A programmer who has read thousands of programs can write a new one without copying any of them. The model's situation is similar, with one difference: the programmer understands what the code is for, while the model works from patterns in tokens.
Exact copies can still appear. Text that was repeated very many times in the training data, such as a standard licence header or a famous short function, can come back word for word. This is the exception. Most generated code is assembled from patterns, not recalled.
Prediction works one token at a time. The model looks at all the tokens so far and gives every token in its vocabulary a score for how likely it is to come next. Suppose the code so far is:
for (int i = 0; i < n; iThe model's scores for the next token might look like this. The numbers are made up for the example.
| Possible next token | Probability |
|---|---|
++ |
92% |
+= |
5% |
-- |
1% |
| every other token together | 2% |
Almost every loop the model saw in training that started this way continued with ++, so that token gets the highest score. One token is chosen and added to the end. Then the whole process runs again on the longer text to choose the token after that, and so on until the answer is complete. A long function is written as hundreds of these small steps.
When you use a coding tool, the code you are working on is sent to the model as part of the request. So the model's predictions follow your code, not only its training. This is how it uses your variable names and matches your style. The lessons on the context window and context explain what is sent.
Predicting likely tokens is not the same as checking that code is correct. A model can write code that looks right and is wrong, or call a function that does not exist, because such text can still be a likely continuation. This is why generated code has to be run and tested, and why coding agents run the tests themselves and read the results.
Interview points
- AI is the name of a goal: getting computers to do work that normally needs human thinking. It is not one technique, and it existed long before large language models.
- Narrow AI does one job well, such as fraud detection. A large language model is useful across many kinds of work.
- Computer vision turns a picture into a statement about what is in it. Natural language processing turns a sentence into something a computer can act on.
- A model is not a product. The model reads and writes text. The agent or harness around it carries out actions such as reading files, and the product is the app on top.
- Machine learning means the system learns its rules from data. In the older approach, a person writes every rule and must predict every case.
- A game enemy that follows hand-written rules is not machine learning. A hand-written rule list works when the set of possible situations is fixed and small.
- A neural network is a parameterized model made of connected layers. Parameters are adjustable numbers. Deep learning means neural networks with many layers.
- In training, both the input and the correct output are known, and the parameters are adjusted until the model's output matches. In production, only the input is known.
Summary
- AI contains machine learning, machine learning contains neural networks and deep learning, and large language models are neural networks.
- Recommendations, fraud detection, and postcode reading are AI that existed before chatbots.
- The model supplies intelligence as text. The software around it gives it a way to act.
- Machine learning replaces hand-written rules with training on examples.
- A neural network is layers of numbers. Data goes in, passes through the layers, and a new output comes out.
- Nobody types the numbers in. Training sets them by comparing the model's guesses with known answers.
- A trained network is then used in production on inputs whose answers nobody knows.
