Home / Learning hub / How machine learning works
Foundations / beginner guide

How machine learning works

How a model learns from examples, what training does with your labels and why careful annotation and evaluation decide how good a model becomes.

Beginner friendlyNo maths neededFree guide

The basic idea

In ordinary software a programmer writes the rules. A spam filter built that way might say “if the email contains these ten words, move it to spam”. Rules like that break as soon as spammers change their wording.

Machine learning turns this around. Instead of rules, the team collects examples, such as thousands of emails that people have marked as spam or not spam. A program then searches for the patterns that separate the two groups and uses them on emails it has never seen. The rules are learned from the examples, which is where the name comes from.

In short

A model is only as good as the examples it learns from. People who label and check those examples shape what the model ends up doing.

What a model is

A model is a large calculation that turns an input into an output. The input can be an email, a photo or a sentence. The output can be a label such as spam, a box around a car or the next word of a reply.

Inside the calculation are many adjustable numbers called weights or parameters. A small model has thousands of them, and a large language model has billions. At the start they are random, so the model’s answers are random too. Training is the process of setting these numbers so that the answers become useful.

How training works

Training repeats one short loop a very large number of times.

  • Predict

    The model takes a training example and gives its answer, for example “not spam”.

  • Compare

    The answer is compared with the label a person gave, here “spam”. The difference is measured as a number called the loss.

  • Adjust

    Every weight is nudged a little in the direction that would have made the loss smaller. This method is called gradient descent.

  • Repeat

    The next example follows. One pass through all the training data is an epoch, and training often takes several.

No single step teaches much. Millions of small nudges add up to a model that gets most examples right. Notice what the loop treats as correct, though. It is always the label. The model has no other source of truth, so a wrong label pushes the weights in the wrong direction just as firmly as a right one pushes them the right way.

Training, validation and test data

A team usually splits its labeled data into three parts.

  • Training data. The examples the model learns from in the loop above.
  • Validation data. Examples kept aside to compare versions of the model during development and to decide when to stop training.
  • Test data. Examples the model never sees until the end. They show how it will behave on new data.

The split matters because a model can look excellent on data it has already seen. If test items leak into training, the scores look better than the model really is. This is one reason projects ask you to keep tasks confidential and never reuse them elsewhere.

Learning or memorising

The goal is a model that handles new cases well, which is called generalisation. The risk is a model that remembers its training examples and fails on anything slightly different. That is overfitting.

Imagine a student who memorises last year’s exam answers. They score well on that exact exam and badly on a new one. A model does the same when its training data is too small, too repetitive or full of quirks. Varied, consistent examples help it learn the real pattern instead of the quirks, which is why projects ask for different topics, styles and difficulty levels.

Kinds of learning

Different problems call for different kinds of training. Most AI work you will meet touches the first and the last of these.

KindWhat it learns fromExample
Supervised learningExamples with labels that people addedPhotos with boxes around cars, emails marked as spam
Unsupervised learningData without labels, looking for structure on its ownGrouping customers by similar buying habits
Self-supervised learningRaw data that supplies its own answersPredicting the next word of a sentence, the first stage of a language model
Reinforcement learningRewards and penalties for its actionsLearning which answers people prefer, from their ratings

How language models are trained

Chat assistants go through several stages, and people take part in most of them.

  • Pretraining. The model reads a huge amount of text and learns to predict the next piece of it, called a token. This gives it grammar, facts and patterns of reasoning, along with the errors in its sources.
  • Fine-tuning on examples. People write prompts and ideal responses. The model learns from these demonstrations how a helpful assistant should answer.
  • Learning from preferences. People compare two answers to the same prompt and say which is better and why. These choices train a reward model or adjust the assistant directly, so it moves towards the answers people prefer.
  • Evaluation and safety testing. People score answers against rubrics and try to make the model fail on purpose. The results decide what gets fixed before a release.

To see the inside of such a model step by step, try the 3D lesson.

Where your work fits

Each common task in AI work feeds one part of this process.

What you doWhat it becomesWhat careless work causes
Label images, text, audio or videoTraining and test data for supervised modelsThe model copies wrong labels, and test scores stop meaning anything
Write ideal responsesExamples for fine-tuningThe model learns the errors, padding and tone of the examples
Compare and rank two answersPreference data and reward modelsThe model learns to please raters with length or confidence instead of being right
Score answers with a rubricEvaluation results that decide releasesReal problems go unnoticed until users find them
Try to break the modelSafety training and safety testsHarmful behaviour stays hidden

Why label quality decides the result

A model cannot be more consistent than the data it learned from. Three kinds of label problems matter most.

  • Random errors. A few careless labels scattered across a dataset make the model less certain and less accurate. Large datasets absorb some of this, yet every error still costs something.
  • Systematic errors. When the same mistake repeats, for example one annotator always labels sarcasm as positive, the model learns it as a rule. These errors are the most damaging because they look like a real pattern.
  • Inconsistency. When people handle the same edge case in different ways, the model gets contradicting signals and becomes unreliable exactly on the hard cases.

This is why guidelines, review and agreement checks exist. They keep the data consistent enough for a model to learn the right thing. For the practical side, read How data annotation works and Evaluating AI responses.

Before you move on

This optional checklist saves your progress in this browser only. Nobody grades it.

Ready to explore more?

Put this into practice in the annotation guide, look up terms in the glossary, or contact Denys Haidamaka if you have a specific question.

How data annotation works ↗