Batch size is the number of training examples processed together in one update or evaluation step. In language-model pretraining, a batch combines input and next-token target sequences; in classification, it combines padded token sequences with class labels. section 2.6 section 6.3
A PyTorch DataLoader uses batch_size to assemble dataset items into tensors. For GPT training, inputs and targets have shape [batch size, context length], with targets shifted one token after inputs. For classification, inputs have shape [batch size, sequence length], while labels have shape [batch size].
Inspecting an eight-example classification batch
With batch_size=8, iterating over the training loader produces input_batch with shape [8, 120] and target_batch with shape [8]. The first dimension is the batch size; the second records the fixed token length for each message.











