In sequence classification with transformer models (e.g., spam detection with GPT-style models), the model produces a logits tensor of shape (batch_size, seq_len, num_classes). The standard convention is to use only the logits at the last token position to make the classification decision.
Implement a function predict_last_token that takes:
logits of shape (batch_size, seq_len, num_classes).The function should:
Note: Applying softmax before argmax is unnecessary because softmax is monotonic - the argmax of the logits equals the argmax of the probabilities.