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

TypeError while running data_reader.py #10

Open
CarolLi opened this issue Feb 24, 2021 · 0 comments
Open

TypeError while running data_reader.py #10

CarolLi opened this issue Feb 24, 2021 · 0 comments

Comments

@CarolLi
Copy link

CarolLi commented Feb 24, 2021

Environment
allennlp == 0.9.0
python == 3.6.12
torch == 1.5.0

I ran data_reader.py and it occurred an error as following,

Using backend: pytorch
Traceback (most recent call last):
File "data_reader.py", line 2, in
dataset_reader = data_reader.CNNDMDatasetReader()
File "/home/carol/DiscoBERT/model/data_reader.py", line 114, in init
self._token_indexers = token_indexers['bert'] or {"tokens": SingleIdTokenIndexer()}
TypeError: 'PretrainedBertIndexer' object is not subscriptable

And I found that there wasn't a key named 'bert' in token_indexers, that's why the problem occurred. I wonder If the bert model has been correctly obtained by the following code.
token_indexers: Dict[str, TokenIndexer] = PretrainedBertIndexer("bert-base-uncased")

And here is the content in token_indexers,

token_indexers: {'_token_min_padding_length': 0, 'vocab': OrderedDict([('[PAD]', 0), ... , ('##~', 30521)]), 'wordpiece_tokenizer': <bound method WordpieceTokenizer.tokenize of <pytorch_pretrained_bert.tokenization.WordpieceTokenizer object at 0x7f008d3d84a8>>, '_namespace': 'bert', '_added_to_vocabulary': False, 'max_pieces': 512, 'use_starting_offsets': False, '_do_lowercase': True, '_truncate_long_sequences': True, '_warned_about_truncation': False, '_never_lowercase': {'[SEP]', '[PAD]', '[UNK]', '[CLS]', '[MASK]'}, '_start_piece_ids': [101], '_end_piece_ids': [102], '_separator_ids': [102]}

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