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

KeyError: "'' not found in vocab namespace 'scierc__ner_labels #59

Closed
yelmankhan008 opened this issue Mar 17, 2021 · 2 comments
Closed

Comments

@yelmankhan008
Copy link

I am trying to run pretrained sciERC model on preprocessed sciERC dataset. I run the following command to do so:

allennlp predict pretrained/scierc.tar.gz \ data/processed_data/json/test.json \ --predictor dygie \ --include-package dygie \ --use-dataset-reader \ --output-file predictions/scierc-test.jsonl \ --cuda-device -1 \ --silent

I run into the following error:

Traceback (most recent call last):
File "/home/yelman/anaconda3/envs/dygiepp/lib/python3.7/site-packages/allennlp/data/vocabulary.py", line 724, in get_token_index
return self._token_to_index[namespace][token]
KeyError: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/yelman/anaconda3/envs/dygiepp/lib/python3.7/site-packages/allennlp/data/vocabulary.py", line 727, in get_token_index
return self._token_to_index[namespace][self._oov_token]
KeyError: '@@unknown@@'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/yelman/anaconda3/envs/dygiepp/bin/allennlp", line 8, in
sys.exit(run())
File "/home/yelman/anaconda3/envs/dygiepp/lib/python3.7/site-packages/allennlp/main.py", line 34, in run
main(prog="allennlp")
File "/home/yelman/anaconda3/envs/dygiepp/lib/python3.7/site-packages/allennlp/commands/init.py", line 119, in main
args.func(args)
File "/home/yelman/anaconda3/envs/dygiepp/lib/python3.7/site-packages/allennlp/commands/predict.py", line 224, in _predict
predictor = _get_predictor(args)
File "/home/yelman/anaconda3/envs/dygiepp/lib/python3.7/site-packages/allennlp/commands/predict.py", line 119, in _get_predictor
overrides=args.overrides,
File "/home/yelman/anaconda3/envs/dygiepp/lib/python3.7/site-packages/allennlp/models/archival.py", line 208, in load_archive
model = _load_model(config.duplicate(), weights_path, serialization_dir, cuda_device)
File "/home/yelman/anaconda3/envs/dygiepp/lib/python3.7/site-packages/allennlp/models/archival.py", line 246, in _load_model
cuda_device=cuda_device,
File "/home/yelman/anaconda3/envs/dygiepp/lib/python3.7/site-packages/allennlp/models/model.py", line 406, in load
return model_class._load(config, serialization_dir, weights_file, cuda_device)
File "/home/yelman/anaconda3/envs/dygiepp/lib/python3.7/site-packages/allennlp/models/model.py", line 305, in _load
vocab=vocab, params=model_params, serialization_dir=serialization_dir
File "/home/yelman/anaconda3/envs/dygiepp/lib/python3.7/site-packages/allennlp/common/from_params.py", line 604, in from_params
**extras,
File "/home/yelman/anaconda3/envs/dygiepp/lib/python3.7/site-packages/allennlp/common/from_params.py", line 634, in from_params
return constructor_to_call(**kwargs) # type: ignore
File "/home/yelman/Desktop/dygiepp-master/dygie/models/dygie.py", line 111, in init
params=modules.pop("ner"))
File "/home/yelman/anaconda3/envs/dygiepp/lib/python3.7/site-packages/allennlp/common/from_params.py", line 634, in from_params
return constructor_to_call(**kwargs) # type: ignore
File "/home/yelman/Desktop/dygiepp-master/dygie/models/ner.py", line 50, in init
null_label = vocab.get_token_index("", namespace)
File "/home/yelman/anaconda3/envs/dygiepp/lib/python3.7/site-packages/allennlp/data/vocabulary.py", line 732, in get_token_index
f"'{token}' not found in vocab namespace '{namespace}', and namespace "
KeyError: "'' not found in vocab namespace 'scierc__ner_labels', and namespace does not contain the default OOV token ('@@unknown@@')"

@dwadden
Copy link
Owner

dwadden commented Mar 18, 2021

Hi,

It's possible that AllenNLP 2.0+ breaks things. I changed requirements.txt to require allennlp==1.1.0. Try reinstalling allennlp and allennlp_models and see if that fixes it.

@dwadden
Copy link
Owner

dwadden commented Apr 1, 2021

I'm going to close this for lack of activity, feel free to reopen if not resolved.

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

2 participants