Iteration

In machine learning, an iteration is one update of a model's parameters during training, made after the model processes a single batch of examples.

Training happens in small repeated steps. In each one the model takes a batch of examples, makes predictions, measures how wrong it was, and adjusts its parameters slightly. Google's machine learning glossary defines an iteration as a single update of the model's weights and biases. In a neural network that involves two passes: a forward pass to calculate the loss on the batch, and a backward pass, backpropagation, to adjust the parameters according to that loss and the learning rate. The terms step and training step mean the same thing.

The batch size decides how many examples go into each iteration, and that links iterations to epochs. One epoch, a full pass over the training data, takes the number of examples divided by the batch size in iterations. Google's example: 1,000 examples with a batch size of 50 means 20 iterations per epoch.

Large models need a great many iterations. Meta's Llama 2 models were pre-trained on 2 trillion tokens with a global batch of 4 million tokens, which works out to roughly 500,000 iterations. Training charts, called loss curves, are usually drawn against iterations, and learning rate schedules are set in them: Llama 2's learning rate warmed up over its first 2,000 steps.

Iterations are also the unit in which problems are fixed. When Google's 540 billion parameter PaLM model hit sudden spikes in its loss during training, the team restarted from a saved checkpoint about 100 steps before each spike and skipped roughly 200 to 500 batches of data, after which the spike did not return at that point.

Outside training, iteration has its everyday meaning. When a company calls a model the latest iteration, it simply means version, and has nothing to do with training steps.

Common questions

What is the difference between an iteration and an epoch?

An iteration is one parameter update based on one batch of examples. An epoch is a full pass through the training data, which takes as many iterations as there are batches. With 1,000 examples and batches of 50, one epoch is 20 iterations.

Is an iteration the same as a step?

Yes. In machine learning, iteration, step and training step all mean one forward and backward pass over a batch followed by one update to the model's parameters.

What happens in one training iteration?

The model makes predictions on a batch of examples, a loss function measures the error, backpropagation calculates how each parameter contributed to it, and an optimiser adjusts every parameter a small amount to reduce it.

How many iterations does it take to train a large language model?

Hundreds of thousands is typical for large runs. Meta's Llama 2 models, for example, were trained on 2 trillion tokens in batches of 4 million tokens, roughly 500,000 iterations.

Finding more

Search for "iteration vs epoch vs batch" or "training step machine learning" to learn the terms. Google's machine learning glossary and Crash Course are reliable for definitions, and developers' technical reports give real numbers for batch sizes, token counts and training steps. When a story uses iteration to mean product version, it is not referring to training.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.