dwadden / dygiepp

Span-based system for named entity, relation, and event extraction.
MIT License
571 stars 120 forks source link

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

Closed yelmankhan008 closed 3 years ago

yelmankhan008 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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