The model's pipeline returns an error
#2
by
Eduarda
- opened
Just by using the default code provided in the model's page, the pipeline returns the error KeyError: 'logits'. The pipeline is loaded fine in thepipe
variable but, when we test the pipeline with a string, the snippet pipe('Tinha uma [MASK] no meio do caminho.')
returns an error. I have tried multiple environments, and devices and acquired the same result.
import torch
from transformers import AutoTokenizer
from transformers import AutoModelForPreTraining
from transformers import AutoModel
model = AutoModelForPreTraining.from_pretrained('neuralmind/bert-base-portuguese-cased')
tokenizer = AutoTokenizer.from_pretrained('neuralmind/bert-base-portuguese-cased', do_lower_case=False)
from transformers import pipeline
pipe = pipeline('fill-mask', model=model, tokenizer=tokenizer)
pipe('Tinha uma [MASK] no meio do caminho.')
Eduarda
changed discussion status to
closed
Eduarda
changed discussion status to
open
When the model is downloaded directly from the pipeline function, the error is not displayed and the pipe returns the results for the [MASK] normally.
pipe = pipeline('fill-mask', model='neuralmind/bert-base-portuguese-cased')
pipe("Tinha uma [MASK] no meio do caminho.")
Does any one know the reason for this?
I got the same error, trying in Colab.
got the same error, following. also, Eduarda's workaround also worked for me