Cannot inherit from BertPretrainedModel anymore after ...
github.com › huggingface › transformersJul 26, 2019 · I think I followed all the steps in migration section of README but still the following code gives me the NameError: name 'BertPreTrainedModel' is not defined error. To migrate latest version, I cloned the repository and run pip install --editable . command within the directory. Here is the code: from pytorch_transformers import * class BertForMultiLabelSequenceClassification ( BertPreTrainedModel ): def __init__ ( self, config, num_labels=2 ): super ( BertForMultiLabelSequenceClassification
NameError: name 'BertTokenizer' is not defined - Beginners ...
discuss.huggingface.co › t › nameerror-nameJun 11, 2021 · NameError: name 'BertTokenizer' is not defined. I am trying to add custom tokens using this code below: # Let's see how to increase the vocabulary of Bert model and tokenizer tokenizer = BertTokenizer.from_pretrained ('bert-base-uncased') model = AutoModelForMaskedLM.from_pretrained ('bert-base-uncased') num_added_toks = tokenizer.add_tokens ( ['token_1']) print ('We have added', num_added_toks, 'tokens') model.resize_token_embeddings (len (tokenizer)) # Notice: resize_token_embeddings ...