Practical_NLP_in_PyTorch
Practical_NLP_in_PyTorch copied to clipboard
ImportError: cannot import name 'PretrainedBertIndexer'
when trying to understand bert_text_classification.ipynb
this part of notebook
from allennlp.data.token_indexers import PretrainedBertIndexer
token_indexer = PretrainedBertIndexer( pretrained_model="bert-base-uncased", max_pieces=config.max_seq_len, do_lowercase=True, )
apparently we need to truncate the sequence here, which is a stupid design decision
def tokenizer(s: str): return token_indexer.wordpiece_tokenizer(s)[:config.max_seq_len - 2]
gives this error
ImportError Traceback (most recent call last)
ImportError: cannot import name 'PretrainedBertIndexer'
NOTE: If your import is failing due to a missing package, you can manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the "Open Examples" button below.
allennlp version used is 1.0.0
seems version differ , I could not find the solution what should I do?