BB

Batch — examples processed together

A group of examples processed at the same time. It adds one axis, of size B, at the front of every tensor. Every example in the batch goes through the same computation.

Hardware is fastest when it does many identical computations at once, so models process several sequences together. A batch of BB sentences, each NN tokens of width dmodeld_{\text{model}}, is one tensor of shape B×N×dmodelB \times N \times d_{\text{model}}.

The examples in a batch never mix, which is why most formulas in the course leave the batch axis out and describe one sequence. In training, each gradient step averages the loss over one batch (section 2.5).

Example

B=8,  N=1024,  dmodel=768  ⟹  8×1024×768B = 8,\; N = 1024,\; d_{\text{model}} = 768 \;\Longrightarrow\; 8 \times 1024 \times 768

Eight sequences of 1,024 tokens, each token a vector of 768 numbers.

Where the course uses it

Related terms