AI Learning Courses
AI Learning Courses › Tutorials › Tutorial 16
AI TUTORIAL 16 · 10 MIN READ

How AI learns: data labelling, training steps and what happens when you type (deep learning explained)

Before an AI can answer you, people label data, the model trains for weeks, and its weights are frozen. Learn each step of data labelling, the training loop, what happens inside when you give an input, and how deep learning fits in, with simple examples.

Turn on JavaScript to watch the animated lesson. The full tutorial text is below.

The big picture: two stages Watch

Every AI model lives two lives. First it learns, which is called training. Then people use it, which is called inference. Training happens once (or once in a while) and is very expensive. Inference happens every time you type a prompt or upload a photo.

  1. Collect data: photos, text, voice, numbers.
  2. Label it: add the right answer to each example.
  3. Train the model: guess, check, adjust, millions of times.
  4. Test it on examples it has never seen.
  5. Deploy it in an app, with the weights frozen.
  6. Inference: you give an input and get an answer.

Step 1: What is data labelling? Watch

A label is the right answer attached to an example. A photo with the label "cat", an email with the label "spam", a voice clip with the typed words. Data labelling (also called data annotation) is the work of adding these answers, mostly done by people.

Raw data gets a label from a person, a second person checks it, and the labelled dataset is split into train, tune and test parts.
Raw data gets a label from a person, a second person checks it, and the labelled dataset is split into train, tune and test parts.

Think of flashcards for a child: a picture on the front, the word on the back. The AI is the child, only it needs thousands of cards per word, not ten.

Kinds of labels Watch

Type of labelWhat the person doesUsed for
Classpicks a name: cat or dog, spam or not spamphoto apps, email filters
Bounding boxdraws a box around each car, person or signalself-driving cars, CCTV
Segmentationcolours every pixel of an objectmedical scans, photo editing
Transcripttypes out what is said in a voice clipvoice typing, Alexa, Google Assistant
Sentimentmarks a review positive, negative or neutralcustomer feedback tools
Rankingchooses the better of two chatbot answersmaking chatbots helpful and safe

How labelling is done, step by step Watch

  1. Write clear rules: for example, "label a photo cat only if the whole face is visible".
  2. Label: people use tools such as Label Studio (free and open source) to click, draw boxes or type answers.
  3. Check: a second person reviews a sample. When two people disagree, the rule is made clearer.
  4. Split: most examples, often 70 to 80 percent, are used to train; a small part is used to tune, and another part is kept hidden for the final test.

A famous example: ImageNet, the photo dataset behind the 2012 deep learning boom, has over 14 million images labelled by people around the world through online crowd work. Data labelling is also a real job today, and many labelling teams work from India.

Step 2: The training loop, inside Watch

Top: training changes the weights, example after example. Bottom: inference uses the frozen weights to answer your input.
Top: training changes the weights, example after example. Bottom: inference uses the frozen weights to answer your input.

A new model starts with random weights, so its first answers are pure guesses. Then the same four steps repeat:

  1. Example: give it one labelled example, say a photo labelled "cat". In practice a small group, called a batch, goes in together.
  2. Guess (forward pass): the pixels flow through the layers and the model says "cat, 30 percent sure".
  3. Loss: compare the guess with the label. The right answer was 100 percent cat, so the mistake, called the loss, is big.
  4. Adjust (backpropagation): work backwards through the layers to find how much each weight added to the mistake, and nudge every weight a little in the right direction. This is called gradient descent, and the size of the nudge is the learning rate.

After the nudge, the same photo might get "cat, 45 percent". One full pass over the whole dataset is called an epoch. Training runs many epochs, and the loss slowly gets smaller.

Step 3: Testing, then freezing Watch

While training, the model is checked on the tune (validation) set it does not learn from. If it scores well on training photos but badly on new ones, it has memorised instead of learning: this is called overfitting. At the end, the hidden test set gives the honest final score.

When the score is good enough, the weights are saved and frozen. That saved file of numbers is the trained model.

Step 4: What happens when you give an input (inference) Watch

Now you open the app and type or upload something. Here is what happens in a fraction of a second:

  1. Input: your prompt, photo or voice.
  2. Turn it into numbers: text is cut into tokens and each token becomes a list of numbers; a photo becomes pixel values.
  3. One forward pass: the numbers flow through all the layers, multiplied by the frozen weights.
  4. Scores: the last layer gives a score to every possible answer, like "cat 97 percent, dog 2 percent".
  5. Answer: the best one is shown to you. A chatbot picks one token, adds it to the text and repeats, word by word, until the answer is done.

Training vs inference in one table Watch

TrainingInference
What happensthe model learns from labelled datathe model answers your input
Weightschange after every batchfrozen, do not change
How oftenonce, or once in a few monthsevery time anyone uses it
Timedays to monthsa fraction of a second to a few seconds
Computer powerthousands of GPUs for big modelsone server, or even your phone for small models
Examplelearning from millions of cat photosface unlock checking your face

Where deep learning fits Watch

Deep learning is machine learning with neural networks that have many layers. "Deep" just means many layers. Everything above, the forward pass, the loss and backpropagation, is exactly how deep learning models are trained.

Each layer learns from the one before it: edges, then shapes, then parts, then the answer.
Each layer learns from the one before it: edges, then shapes, then parts, then the answer.

Nobody tells the layers what to look for. From the labelled photos alone, early layers learn edges and colours, middle layers learn shapes, and deep layers learn eyes, ears and whiskers. Chatbots like ChatGPT and Gemini are deep learning models too, with dozens of layers and billions of weights.

Try it yourself, free Watch

Open Google Teachable Machine (teachablemachine.withgoogle.com). Hold up a pen to your webcam for a few seconds, then a cup: that is labelling. Press Train: that is training. Now show it the pen again and watch the percentages: that is inference. All three stages in under two minutes.

Lesson learned Watch

People label examples, the model trains by guessing, checking and nudging its weights millions of times, and then the weights are frozen. When you type, the frozen model turns your input into numbers, runs one forward pass and gives the most likely answer.

Frequently asked questions

What is data labelling in AI?

Data labelling, or annotation, means adding the right answer to each example, such as "cat" on a photo or a typed transcript on a voice clip, so a model can learn from it.

What is the difference between training and inference?

Training is when the model learns from data and its weights change. Inference is when the finished model answers a new input with its weights frozen.

Does ChatGPT learn from my chat while I talk to it?

No, its weights do not change during a chat. It sees earlier messages because they are sent again with each new one. Some apps may use saved chats to train future versions, depending on your settings.

What are the steps of training a model?

Start with random weights, then repeat: give a batch of labelled examples, let the model guess, measure the loss, and adjust the weights with backpropagation. Test on unseen data at the end.

Is deep learning different from this?

Deep learning is the kind of machine learning that uses many-layer neural networks. It is trained with exactly these steps: forward pass, loss and backpropagation.