Describe the training loop and tell the difference between learning a pattern and memorising examples.
A model can get almost every answer right on the data used to build it and still be wrong much of the time once it is put to work on real cases. Before you rely on a model's output, you need to know how it was trained and how it was checked afterwards. Those two facts tell you how much weight its answers can bear.
If you went to secondary school in Singapore, you probably know the "ten-year series", a thick book that holds ten years of past exam papers. Students use it in two ways. One group works through the questions until the topic makes sense to them. Another group memorises the answers. Both groups get high marks on practice papers. On the real exam, where some questions are new, the first group does well and the second group struggles. Machine learning depends on the same split between picking up a pattern and remembering answers.
In Lesson 2.1 you saw a model described as a calculation controlled by millions of dials. Training is the process that sets them. It runs three steps in a loop (guess, measure and adjust) and repeats them a very large number of times.
Suppose you manage a polyclinic and want to forecast how many patients will miss their appointments on a given day so that you can roster staff. You feed the model a single day from your records: a Monday in December, raining, during the school holidays, with 300 appointments on the books. The dials begin at random settings, so the first answers are poor. For this day the model guesses 10 no-shows.
In the measure step, you compare the guess with what really happened. The records say 45 patients did not come. The difference between the guess and the true figure is the error. Here 45 minus 10 = 35, so the model guessed 35 too low. Training is aimed at shrinking this error.
In the adjust step, an algorithm goes through every dial and works out whether a slight turn upward or a slight turn downward would have put the guess nearer to 45. Each dial is then moved a small step in whichever direction helps. After that, the model takes the next day from the records and goes round the loop again.
A single day carries very little information, and a single small nudge hardly shifts the model. You therefore run the loop across thousands of past days, then go back through the whole set several more times. Gradually the dials come to rest at settings that produce small errors on most days.
Large language models are built with the same three steps. The loop runs over a vast quantity of text, and every step moves billions of dials together.
The small size of each nudge is deliberate. Suppose you are a stallholder. You see one busy day and double your order, then see one quiet day and cut it in half. Because you keep responding to the most recent day, your order jumps around and you never reach a sensible amount. A model that turned its dials hard to match every new example would behave the same way, swinging back and forth without settling. With small steps, the dials move toward whatever most of the examples have in common.
High scores on the training examples prove nothing by themselves. As the clinic manager, you already have last year's no-show numbers. You want sound guesses for next month, on days the model has never seen. Doing well on unseen examples is called generalisation, and it is the reason for training a model at all.
A model that generalises has found the real pattern, for example that rain and school holidays both raise the number of no-shows. A model goes wrong when it latches onto quirks that belong only to the examples it happened to see. Give a model enough dials and it can match nearly every training example by storing them, random one-off events included. On one Tuesday in March, a random event caused exactly 52 no-shows at the clinic, and a memorising model would reproduce that 52. It resembles the classmate who memorised the ten-year series: it looks excellent on the data it trained on, and on new data it performs worse than a simpler model would.
This failure is called overfitting, where the model fits its training examples so tightly that it fails on new ones. The risk rises when the model is big and the examples are few, or when the examples are all very similar to each other.
Protection against overfitting begins before any training happens. The builders set aside part of the examples and keep them away from the model for the whole of training. This held-back set plays the role of an exam paper the student has never seen. The model learns from the rest of the examples and is then scored on the held-back set.
There are two outcomes for you to read. If the model scores well on its training examples and also on the held-back set, it has probably learned the pattern. If it scores well on training and poorly on the held-back set, it has memorised. In that case the builders change something and run the test again. They can supply more varied examples, switch to a smaller model, or train it for less time.
The held-back set also has to resemble the cases the model will meet in real use. A fair test uses the mix of cases you actually care about. If you scored the clinic's model only on dry weekdays in June, you would learn little about how it copes with rainy Mondays in December.
Nearly every model in use today was built with this training loop followed by a held-back test, from spam filters to the AI assistants in Module 3. When you weigh a model's output, find out what examples it was trained on, whether it was scored on examples kept out of training, and whether those examples looked like the cases you are putting to it. Give its output less weight if the answer to any of these is no or unknown.
You can now set out this process in plain steps yourself. Do it for two fruits that even people sometimes confuse, and give the fair test the same care you give the training.
Write four steps for teaching a model to tell durian photos from jackfruit photos. Include how you would test it fairly.
Junxiong-WFG Organisation is an authorised representative of AIA Financial Advisers Private Limited (Reg. No. 201715016G).