Zubnet AIApprendreWiki › Batch Size & Epoch
Training

Batch Size & Epoch

Mini-Batch, Training Epoch
Le batch size est combien d'exemples d'entraînement le modèle traite avant de mettre à jour ses paramètres. Un epoch est un passage complet à travers tout le dataset d'entraînement. Un modèle entraîné pour 3 epochs sur 1 million d'exemples avec un batch size de 1 000 traite 1 000 exemples par update, prend 1 000 updates par epoch, et 3 000 updates au total.

Pourquoi c'est important

Le batch size et les epochs sont les contrôles les plus fondamentaux dans l'entraînement. Le batch size affecte la vitesse d'entraînement, l'utilisation mémoire, et même ce que le modèle apprend (les petits batches ajoutent du bruit qui peut aider la généralisation ; les gros batches convergent plus vite mais peuvent généraliser moins bien). Le nombre d'epochs détermine combien de fois le modèle voit chaque exemple — trop peu et il sous-apprend, trop et il sur-apprend.

Deep Dive

In practice, stochastic gradient descent processes the training data in random mini-batches. Each batch gives an estimate of the true gradient — larger batches give better estimates (less noise) but cost more memory and compute per step. Typical batch sizes range from 32 (small models, single GPU) to millions of tokens (LLM pre-training across thousands of GPUs).

The Large-Batch Training Challenge

LLM pre-training uses enormous effective batch sizes (millions of tokens per update) distributed across many GPUs. At this scale, the learning rate must be carefully tuned — the linear scaling rule (double the batch size, double the learning rate) works up to a point, then breaks down. Gradient accumulation lets you simulate large batches on smaller hardware by accumulating gradients across multiple forward passes before updating.

Epochs in the LLM Era

Modern LLM pre-training typically runs for less than one epoch on the full dataset — the data is so large that the model never sees all of it. This is a shift from classical ML where 10–100 epochs was normal. Research suggests that repeating data (multiple epochs) can actually hurt LLM performance due to memorization effects, though this depends on data quality. Fine-tuning, by contrast, typically runs for 1–5 epochs on a much smaller dataset.

Concepts liés

← Tous les termes
← Backpropagation Beam Search →