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 sentences, each tokens of width , is one tensor of shape .
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
Eight sequences of 1,024 tokens, each token a vector of 768 numbers.
Where the course uses it
Related terms
- Tensor — numbers on any number of axesAn array of numbers with any number of axes. In code every array is called a tensor: a scalar has 0 axes, a vector 1, a matrix 2. In prose the word usually means 3 or more.
- Shape and axesA tensor's shape lists the size of each axis, in order. (2, 3, 4) has three axes of sizes 2, 3 and 4. Checking shapes is the quickest way to follow a formula.
- N, T, L — sequence lengthThe number of tokens in the sequence. Different modules call it N, T or L. N² ("N squared") is how attention's cost grows with it.