# Getting predictions

**URL:** <https://discuss.huggingface.co/t/getting-predictions/1552>\
**Category:** 🤗Transformers\
**Created:** [October 15, 2020, 1:29pm UTC](https://discuss.huggingface.co/t/getting-predictions/1552 "2020-10-15T13:29:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shainaraza](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/shainaraza/32/2854_2.png) [@shainaraza](https://discuss.huggingface.co/u/shainaraza)\
**Post date:** [October 15, 2020, 1:29pm UTC](https://discuss.huggingface.co/t/getting-predictions/1552/1 "2020-10-15T13:29:56Z")

</div>

Asking a very basic question but any suggestions would be highly appreciated, I am not able to see the predictions for this code from huggingface longformer piece of code, this is not related to longformer but a generic question:

> > > > import torch  
> > > > from transformers import LongformerForMaskedLM, LongformerTokenizer
> 
> > > > model = LongformerForMaskedLM.from\_pretrained(‘allenai/longformer-base-4096’, return\_dict=True)  
> > > > tokenizer = LongformerTokenizer.from\_pretrained(‘allenai/longformer-base-4096’)
> 
> > > > SAMPLE\_TEXT = ’ '.join(['Hello world! '] \* 1000) # long input document  
> > > > input\_ids = torch.tensor(tokenizer.encode(SAMPLE\_TEXT)).unsqueeze(0) # batch of size 1
> 
> > > > attention\_mask = None # default is local attention everywhere, which is a good choice for MaskedLM  
> > > > … # check `LongformerModel.forward` for more details how to set `attention_mask`  
> > > > outputs = model(input\_ids, attention\_mask=attention\_mask, labels=input\_ids)  
> > > > loss = outputs.loss  
> > > > prediction\_logits = output.logits

---

<div class="post-metadata">

**Author:** ![h56cho](https://avatars.discourse-cdn.com/v4/letter/h/c2a13f/32.png) [@h56cho](https://discuss.huggingface.co/u/h56cho)\
**Post date:** [October 15, 2020, 2:30pm UTC](https://discuss.huggingface.co/t/getting-predictions/1552/2 "2020-10-15T14:30:08Z")

</div>

Hi,  
each element in your logit vector stands for the classification probabilities for each class, so you just take the index of the maximum logit and that will be your predicted class.
