(Up to date) Transformer + Classifier example?

:wave: Hi there, I’m looking at adapting this tutorial here: Language Modeling with nn.Transformer and torchtext — PyTorch Tutorials 2.2.0+cu121 documentation

Instead of outputting probabilities of the next word in a sequence, I would like outputs to be class / label indices instead. I have found a great, semi-dated example here, but it relies on an old version of PyTorch, with some of the data imports no longer working and marked deprecated.

Would anyone know of a more up to date example that uses an nn.Transformer tailored towards classification, or be able to share generally how one might adapt the official torchtext example above to output classes instead?

Thank you :pray:

By the way, this is an extension of someone’s suggestion here to try Transformers for a classification problem: Help improving sports prediction model - #5 by J_Johnson