epoch
Here is a strange entry from the technical report on GPT-3, the model that started the chatbot craze. It read Wikipedia 3.4 times, but the huge archive of web pages Common Crawl only 0.44 times, that is, less than half. How can you read something “0.44 times”, and why did the developers deliberately make the model reread a small encyclopedia but not finish the internet? The answer is hidden in the data-mixture workshop below, and for now remember: an epoch can be fractional.
An epoch is one full pass over the training data: the model has seen every example exactly once. It is the oldest counter of training length, and still the main one when you fine-tune a model on your own data or teach it to recognise images or sounds. Too few epochs and the model has not managed to learn; too many and it has memorised the examples by heart, along with their errors, and answers worse on new data. This sheet has a calculator of steps and cost, a live experiment with overfitting and early stopping, mini-batches on an error surface, and a workshop that shows how many times a model will read each of its sources.
Calculator
How many steps in an epoch and how long to wait
Enter how many examples the dataset has, the batch size on one GPU, the number of GPUs and gradient accumulation: the model takes one step once it has collected the whole effective batch. Below you will see steps per epoch, steps in the whole training, learning-rate warm-up steps, and the time if you know how long one step takes.
How many tokens and how much money fine-tuning will take
Fine-tuning services charge for training tokens: the number of examples multiplied by their average length and by the number of epochs. Enter your data and the price from the price list; choose the currency yourself, the calculation does not depend on it. To the right of each epoch you can see what share of its benefit remains, if you believe the studies of data repetition.
Etymology
Stop, repeat and bake
Neural-network training is described with three words, and each came from its own kitchen: Greek philosophy, Latin rhetoric and the English bakery. Epoch once meant a halt, iteration a repetition, and batch a lot of bread baked at one time. Put them together and you get an exact picture: the model bakes answers in batches, over and over, and from time to time stops to mark a lap completed.
01 · Definition and order of examples
A lap of the textbook
Imagine a student preparing for an exam with a problem book. They solve problems five at a time, after each five they check the answers and draw conclusions, and on reaching the end of the book they start again. A five of problems is a batch, the checking and conclusions are a training step, and one pass through the whole book is an epoch. To remember the solutions better, the student will go through the book several times. But if they repeat it twenty times, they will learn the answers to exactly these problems by heart, typos included, and at the exam with new problems they will be lost.
It is the same with a neural network: nobody knows in advance how many epochs are needed. So part of the data is set aside and not shown to the model, and after each epoch the model is checked on it. While the error on the held-out data falls, training is paying off; when it starts to rise, the model has begun to cram, and training should be stopped. This technique is called early stopping. Before each epoch the examples are usually shuffled, so that the model does not get used to their order.
In which order the model sees the examples
Each row is an epoch, each cell is an example: the colour shows which example it is, from the first (blue) to the last (crimson). Batches are outlined with a frame. Switch the shuffling mode and the batch size and see how what the model sees in a row changes.
How to read the internet 0.44 times
Large language models are trained not on one dataset but on a mixture of several: filtered web pages, books, articles, code and encyclopedias. Developers decide in advance what share of the training tokens each source gets, and this share need not match its size. In GPT-3 training lasted three hundred billion tokens, and sixty percent of them were taken from Common Crawl, which held 410 billion. So the model managed to read only 180 billion, about 0.44 of its epoch, and the rest simply never got its turn.
Wikipedia, which has about three billion tokens, was given three percent of the training, roughly nine billion tokens, and the report records that it was read 3.4 times. The developers knowingly overfed the model with quality texts and underfed it with noisy ones: better to reread an encyclopedia three times than to finish random pages with ads and scraps of menus. Move the source shares in the data-mixture workshop and see when repeats become too many.
Overfit, shuffle, reread
In the “Overfitting” experiment real gradient descent fits a flexible curve to a few noisy points: move the epoch slider and watch the model first catch the pattern, then start to wiggle in order to pass through every point together with the noise. In the “Mini-batches” experiment the same descent walks over an error map in small bundles: you can see how batch size and shuffling change the path. And in the “Repeats” experiment a language model rereads the same corpus, and each next epoch brings less and less benefit.
02 · Orders of magnitude
From a tenth to ten thousand rounds
Drag the slider: it moves along a logarithm, and each division is ten times the previous one. On the left are the hugest datasets, which the model does not manage to finish reading; on the right are tiny tasks that a neural network runs thousands of times until it suddenly grasps the pattern. See where your own project would land.
03 · Data-mixture workshop
How many times the model will read each source
Here is the real GPT-3 data mixture from OpenAI’s 2020 technical report: five sources, their size in tokens and the share each received in training. Move the shares and the total training length, and you will see how many epochs fall on each source. Everything that is reread more than four times lights up red: beyond that, according to studies, repeats bring almost no benefit. The same arithmetic can be applied to your own data: enter it in place of the example.
04 · Epoch in code
Where the number of epochs is set and what the default is
Every library names the number of epochs a little differently, and the defaults differ by hundreds of times: from one epoch in Keras to a thousand in PyTorch Lightning if you specify nothing. Keep this in mind when running someone else’s example. Tap a row to read the details.
Three snippets worth keeping at hand
Setting epochs with a margin and adding early stopping is more reliable than guessing the number in advance: the model stops by itself when the validation error has stopped falling for several epochs in a row, and returns the best weights.
{code}05 · Writing rules
06 · Neighbouring units
07 · Historical section
For many years the rule was simple: once the validation error starts to rise, training further is useless. But in 2022 OpenAI researchers led by Alethea Power described a strange phenomenon. A small network was learning to add numbers modulo 97, and within a few hundred steps it learned all the training examples by heart, while on new ones it erred as if at random. It was not stopped, and tens of thousands of steps later, when any engineer would long since have given up, the accuracy on new examples suddenly jumped to almost a hundred percent.
The phenomenon was named grokking, after the word grok coined by the science-fiction writer Robert Heinlein, meaning “to understand to the very depths”. Having memorised the answers, the model kept slowly simplifying its weights and at some point found the real rule instead of a lookup table. Grokking occurs mostly on small mathematical tasks and with a strong penalty on large weights, while for ordinary data early stopping is still reliable. But it is a reminder: the number of epochs is not only a budget but also a question of what the model will have time to understand.
Series · AI
units of language modelsHow a neural network is measured
The epoch links data with training: tokens are what the model reads, parameters are what it adjusts, and epochs and steps show how many times and in what portions this happens. On the left is a console where these measures meet in one training run; on the right are the series sheets.
Catalogue of quantities
the whole index →The seven SI base units
A drop of acid changes the colour of the juice, salt colours the flame, water freezes at a tap. Below them are all Simetrium sheets, by discipline and alphabetically.
Open the index →





