ROOM 03 / TASK 03

Building the Model

Understand training rounds, fair testing, smaller models, and learning across devices without assuming that private data is automatically safe.

Notes documented Oct 8, 2026 · 8 min read · Plain English

Make yourself comfortable
18px

Building a model involves several decisions. How often should it practise? How will we check its answers? Can it run on a small device? Where will training happen?

These choices affect cost, quality, and security. This guide explains the ideas from TryHackMe’s AI Models & Data room through original examples. Imagine a fictional repair service training a model to sort customer messages into “repair,” “delivery,” and “other.”

Training: practise, measure, adjust

A model contains parameters: numbers that influence its predictions. During training, it makes predictions, measures mistakes, and adjusts these numbers.

The mistake measure is called loss. A gradient describes how changing a parameter would change that loss. Backpropagation calculates gradients through the network. An optimizer uses them to update the parameters. These are connected steps with different jobs. PyTorch’s training explanation.

For our service, the input might be “My replacement screen has not arrived.” The training target is “delivery.” If the model predicts “repair,” the training process uses the error to guide an update. One update does not guarantee the next answer will be right.

Batches and epochs: how much practice?

A batch is a group of examples processed together. An epoch is one complete pass through the training dataset. They measure different things. PyTorch’s definitions.

Here is a small, invented example:

Setting Value Meaning
Training messages 1,200 Examples available for learning
Batch size 100 Messages in each batch
Batches per epoch 12 1,200 divided by 100
Training epochs 5 Five passes through those messages

With one update after every batch, this example has 60 updates: 12 × 5. Other training arrangements can combine several batches before updating.

Five epochs do not create 6,000 different messages. They reuse the same 1,200 examples. More practice can help, but repeating familiar material is not enough to prove useful learning.

Separate learning from checking

Use different examples for different jobs:

Dataset Job What our service does with it
Training set Learn parameter values Practise classifying messages
Validation set Guide development choices Compare settings and choose when to stop
Test set Evaluate the selected version Check fresh messages after those choices

Keep duplicate or closely related examples from crossing these boundaries. Otherwise, a supposedly new question may already be familiar. Repeatedly changing the model to improve its test score also weakens the independence of that test. Google’s dataset splitting guide.

For example, copies of the same customer conversation should not appear in both training and testing. The model could recognise familiar wording instead of learning how to handle a different customer’s problem.

Overfitting: good practice results, weak new results

Illustrative training and validation error curves. Training error keeps falling while validation error eventually rises; a marked checkpoint has the lowest validation error in this example.

Original illustration, not measured model results. Open it for a larger view.

Generalization means using learned patterns successfully on new examples. Overfitting happens when a model fits its training examples too closely and performs poorly on new data. Google’s overfitting explanation.

In our example, a model might learn that messages mentioning “Tuesday” usually mean delivery. That shortcut may work in the training collection but fail when someone requests a repair appointment on Tuesday.

Watch training and validation results together. If training keeps improving while validation gets worse, investigate. Early stopping means ending training when validation results stop improving under your chosen rule. It is one way to limit unnecessary training, not a promise of perfect performance. Keras early-stopping documentation.

Overfitting and privacy-related memorization are connected concerns, but they are not identical. Memorization can let a model reproduce particular training content. Good average test results do not prove that sensitive examples cannot be exposed. Researchers have demonstrated extraction of secret sequences from trained models. The Secret Sharer research.

For the repair service, remove unnecessary addresses and access codes before training. Checking category accuracy does not replace checking for private information in outputs.

Pruning and quantisation: two ways to reduce a model’s cost

Pruning removes or disables selected parts of a model. A method may set certain weights to zero, or remove larger structures. Think of reducing the number of active connections. Removing too much can damage useful behaviour. Setting numbers to zero does not automatically make every computer run the model faster; the software and hardware must use that structure effectively. PyTorch’s pruning guide.

Quantisation represents numbers with fewer possible values, often using fewer bits. A bit is a basic unit of digital storage. This can reduce memory needs. The challenge is keeping useful accuracy while using a less precise representation. Hugging Face’s quantisation overview.

Imagine a toy system that stores values only in steps of 0.25:

Original value Nearest allowed value Absolute difference
0.73 0.75 0.02
0.41 0.50 0.09
0.08 0.00 0.08

This is an illustration of rounding, not a real model conversion. Real quantisation methods choose numerical ranges and representations carefully.

Try the visual rounding example below. Change the gap between allowed values and watch how the numbers move.

Pruning changes which parts contribute. Quantisation changes how precisely values are represented. Neither process automatically removes private information or harmful behaviour.

For our service, treat a compressed model as a new version to evaluate. Compare incorrect categories, memory use, response time, and privacy tests. A smaller file is useful evidence about size. It is not evidence that every previous safety check still passes.

Federated learning: learn in several places

Federated learning coordinates training across participating devices or organisations. In a common arrangement, raw training examples stay with each participant. A coordinator combines model updates instead of collecting all those examples in one place. Original federated averaging research.

Three participants keep their raw training records locally, send model updates to a coordinator, and receive a shared model. Updates still need privacy and integrity protections.

Original diagram. The arrows carrying updates are not automatically safe.

Imagine three repair branches working together:

  1. Each branch receives the same starting model.
  2. Each trains locally on its own approved messages.
  3. Each sends an update describing changes to the model.
  4. The coordinator combines the updates.
  5. The branches receive the revised shared model for another round.

The branches can have different customers and language patterns. A result that works well at one branch may work poorly at another. Check each branch’s results as well as the overall average.

Local data does not mean zero privacy risk

An update is information produced from training data. It can reveal something about that data. Researchers have reconstructed training examples from exposed gradients under studied conditions. This does not mean every federated update reveals every record, but it disproves the assumption that updates are always harmless. Deep Leakage from Gradients.

A participant can also send a deliberately harmful update. Research has demonstrated backdoors in federated models: hidden behaviour activated by particular inputs. Keeping raw records local does not prevent this model-poisoning risk. Federated backdoor research.

Secure aggregation uses cryptographic methods so the coordinator can obtain a combined result without reading each participant’s individual contribution, under the protocol’s assumptions. It protects an important part of the exchange. It does not establish that every contribution is honest, or that the final model cannot reveal information. Original secure aggregation research.

For the three branches, this means checking participant identities, protecting update storage and connections, testing the combined model, and planning how to handle suspicious contributions. Privacy and protection against harmful updates both need attention.

Check your understanding

Do ten epochs mean ten different datasets?

No. They mean ten passes through the training dataset. Repeating examples does not make them new examples.

A quantised model uses less memory. Can we skip testing it?

No. Changing its numerical representation can change its answers. Measure the new version's quality, performance, and relevant security behaviour.

If raw messages stay at each branch, why protect the updates?

Updates can carry information about those messages. A dishonest participant can also send changes designed to harm the shared model. Local storage solves neither problem by itself.

A SMALL VISUAL EXAMPLE

See what rounding changes

These four invented numbers represent values between 0 and 1. Choose the gap between allowed values. Each number moves to its nearest allowed value.

Original number Rounded number

0.13 rounds to 0.25Difference: 0.12

0.37 rounds to 0.25Difference: 0.12

0.73 rounds to 0.75Difference: 0.02

0.91 rounds to 1.00Difference: 0.09

5 values are allowed: 0.00, 0.25, 0.50, 0.75, 1.00. The average difference for these four numbers is 0.0875.

This illustrates one idea behind quantisation. Real methods use their own ranges, scales, and storage formats. A smaller difference here does not measure a real model’s accuracy or safety.