The last token is the final position in a sequence. In GPT-style classification, its output serves as the sequence summary because causal attention lets it incorporate every preceding token. section 6.5
For a four-token input, the data flow is:
- The model produces one classification vector per input position, with shape [batch, sequence length, classes]. section 6.5
- Select the final position with outputs[:, -1, :]. section 6.5
- Use the resulting vector as the input for spam-versus-not-spam prediction. section 6.5
Four-token input
For “Do you have time,” the output has shape [1, 4, 2]. Selecting the last position yields [[-3.5983, 3.9902]], the two-class logits for the sequence. section 6.5
Figure 6.11 The GPT model with a four-token example input and output. The output tensor consists of two columns due to the modified output layer. We are only interested in the last row corresponding to the last token when fine-tuning the model for spam classification.
Shows the four-token output tensor and highlights the final row used for classification. section 6.5
