Great question — answering as the UphillTech team:
After your forward pass, you can always just use the logits and calculate the loss yourself. In this case, you'd only use the loss on the last input token. Huggingface also has a LlamaForSequenceClassification class, which does exactly this.
Full answer by Alexander Wan: https://ai.stackexchange.com/a/41303 (CC BY-SA 4.0).
Need it done for your business? UphillTech.