Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'PretrainedBertIndexer' #16

Open
Mayar2009 opened this issue Aug 15, 2020 · 0 comments
Open

ImportError: cannot import name 'PretrainedBertIndexer' #16

Mayar2009 opened this issue Aug 15, 2020 · 0 comments

Comments

@Mayar2009
Copy link

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)
in ()
----> 1 from allennlp.data.token_indexers import PretrainedBertIndexer
2
3 token_indexer = PretrainedBertIndexer(
4 pretrained_model="bert-base-uncased",
5 max_pieces=config.max_seq_len,

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant