Skip to content

AI Glossary · Concepts

What is Batch Size?

Batch Size

Batch size is the number of training examples a model looks at before it updates its parameters once. Most training uses mini-batches, small groups of examples, rather than one example at a time or the whole dataset at once.

Also known as: mini-batch, minibatch, mini-batch size

· Chain of Thought

Model TrainingAI Hardware

  • 3 sources

Imagine grading a stack of 10,000 practice exams to work out what to teach differently. You could change the lesson after every single exam, which is noisy and slow. You could read all 10,000 first, which takes forever per change. Or you could read 100 at a time, adjust, and continue. That middle option is a mini-batch, and 100 would be the batch size.

During training, the model processes one batch, measures its average error, and makes one update to its parameters. An epoch is one full pass over the training data, so with 10,000 examples and a batch size of 100, an epoch is 100 updates. Like the learning rate, batch size is a hyperparameter chosen by people.

The choice has practical costs. Bigger batches use the parallel hardware of a GPU more efficiently but need more memory, and research such as Keskar et al. found very large batches can hurt how well a model generalizes unless other settings change too. Goyal et al. showed one fix: scale the learning rate along with the batch and warm it up gradually. So when a team says it “doubled the batch size,” expect the learning rate and run time to change as well. At inference time, “batching” means grouping user requests to serve them efficiently; see continuous batching for that separate idea.

Sources