# KeyError: 'logits'

**URL:** <https://discuss.huggingface.co/t/keyerror-logits/25863>\
**Category:** Beginners\
**Created:** [November 10, 2022, 12:17pm UTC](https://discuss.huggingface.co/t/keyerror-logits/25863 "2022-11-10T12:17:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![efiore](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@efiore](https://discuss.huggingface.co/u/efiore)\
**Post date:** [November 10, 2022, 12:17pm UTC](https://discuss.huggingface.co/t/keyerror-logits/25863/1 "2022-11-10T12:17:03Z")

</div>

Hi,  
I have created and trained a tokenizer. I then loaded using

**tokenizer = PreTrainedTokenizerFast.from\_pretrained(‘bert-base-he’)**

I then created a model using starting to load  
**model = BertForPreTraining.from\_pretrained(‘bert-base-uncased’)**

I did everything to train the model both with the MLM approach and the NSP approach and everything worked fine. So I saved the model in my google drive.

I now want to use the model but I get the following error: **KeyError: ‘logits’**

## This is the code I use:

# Initialize MLM pipeline

from transformers import pipeline

mlm = pipeline(  
“fill-mask”,  
model = torch.load(‘BHSA01.pt’, map\_location=torch.device(‘cpu’)), #it seems it wants just the model name in .json format  
tokenizer = PreTrainedTokenizerFast.from\_pretrained(‘bert-base-he’)  
)

# Get mask token

mask = mlm.tokenizer.mask\_token

# Get results for a particular masked phrase

phrase = f’{mask} בְּ רֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַ שָּׁמַ֖יִם וְ אֵ֥ת הָ’  
result = mlm(phrase)

# Print result

print(result)

* * *

Just one last note. Biblical Hebrew is written right to left. Can that create problem?

Thanks a lot for Your help!

Elia
