Yes, you can just set the num_labels argument to the number of classes that you have.
model = AutoModelForSequenceClassification.from_pretrained("xlnet-base-cased",
                                                           num_labels=3)

If you pass the labels during forward, they will be used to calculate the loss with CrossEntropyLoss if more than one label, otherwise MSELoss will be used for a regression problem.

  
      github.com
  
  
    huggingface/transformers/blob/3552d0e0d89711404ec49b0080cd1f48ae224bb3/src/transformers/models/xlnet/modeling_xlnet.py#L1539-L1546 6

if labels is not None:    if self.num_labels == 1:        #  We are doing regression        loss_fct = MSELoss()        loss = loss_fct(logits.view(-1), labels.view(-1))    else:        loss_fct = CrossEntropyLoss()        loss = loss_fct(logits.view(-1, self.num_labels), labels.view(-1))