No module named 'transformers.models' while trying to import BertTokenizer
13,575
you can change your code from
transformers.modeling_bert import BertModel, BertForMaskedLM
to
from transformers.models.bert.modeling_bert import BertModel,BertForMaskedLM
Related videos on Youtube
Author by
Icaru5
Updated on June 04, 2022Comments
-
Icaru5 almost 2 years
I am trying to import BertTokenizer from the transformers library as follows:
import transformers from transformers import BertTokenizer from transformers.modeling_bert import BertModel, BertForMaskedLM
However, I get the following error:
I am using transformers version 3.5.1 because I had a problem with the updated version which can be found here.
Does anyone know how to fix this? Apart from updating the transformers library to its latest version (that will unfortunately cause more errors).
Any help is appreciated!
-
cronoik about 3 yearsI can not reproduce this with transformers 3.5.1. Have you maybe created a package called
transformers
by yourself?
-