dwadden / dygiepp

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

Error in event predict model #80

Closed unlimit11 closed 2 years ago

unlimit11 commented 2 years ago

Hi, i want use ACE event evaluate model by pip. but apparently there is a problem in the code. please help, thank you.

(dygiepp) ➜ dygiepp allennlp evaluate \
ace05-event.tar.gz \ dygie/tests/fixtures/collate/ace-event/test.json \ --cuda-device -1 \ --include-package dygie 2021-11-20 17:58:27,812 - INFO - allennlp.common.plugins - Plugin allennlp_models available Traceback (most recent call last): File "/home/mohammad/PycharmProjects/venv/dygiepp/bin/allennlp", line 8, in sys.exit(run()) File "/home/mohammad/PycharmProjects/venv/dygiepp/lib/python3.9/site-packages/allennlp/main.py", line 46, in run main(prog="allennlp") File "/home/mohammad/PycharmProjects/venv/dygiepp/lib/python3.9/site-packages/allennlp/commands/init.py", line 122, in main import_module_and_submodules(package_name) File "/home/mohammad/PycharmProjects/venv/dygiepp/lib/python3.9/site-packages/allennlp/common/util.py", line 362, in import_module_and_submodules import_module_and_submodules(subpackage, exclude=exclude) File "/home/mohammad/PycharmProjects/venv/dygiepp/lib/python3.9/site-packages/allennlp/common/util.py", line 351, in import_module_and_submodules module = importlib.import_module(package_name) File "/usr/lib/python3.9/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "", line 855, in exec_module File "", line 228, in _call_with_frames_removed File "/home/mohammad/PycharmProjects/dygiepp/dygie/data/init.py", line 1, in from dygie.data.dataset_readers.dygie import DyGIEReader File "/home/mohammad/PycharmProjects/dygiepp/dygie/data/dataset_readers/dygie.py", line 29, in class DyGIEReader(DatasetReader): File "/home/mohammad/PycharmProjects/dygiepp/dygie/data/dataset_readers/dygie.py", line 203, in DyGIEReader def _instances_from_cache_file(self, cache_filename): File "/home/mohammad/PycharmProjects/venv/dygiepp/lib/python3.9/site-packages/overrides/overrides.py", line 67, in overrides raise AssertionError('No super class method found for "%s"' % method.name) AssertionError: No super class method found for "_instances_from_cache_file"

dwadden commented 2 years ago

Hi,

Can you confirm that you've created a conda environment as in the dependencies section of the README? It looks like you're using Python 3.9, and I've only tested DyGIE on Python 3.7.

Also, please revise the issue to meet the guidelines listed here. I just made these, so there's no way you could have known about them when you posted, but it will make my life a little easier.

unlimit11 commented 2 years ago

solved with python3.7.4. thank you.

unlimit11 commented 2 years ago

I use this model and dataset below to predict.

allennlp predict ace05-event.tar.gz \
    dygie/tests/fixtures/collate/ace-event/test.json  \
    --predictor dygie \
    --include-package dygie \
    --use-dataset-reader \
    --output-file dygie/tests/fixtures/collate/dg.json \
    --cuda-device -1

The required models were loaded correctly. but i have error, apparently the problem is in dataset.


  File "/venv/dygiepp/lib/python3.7/site-packages/allennlp/data/fields/list_field.py", line 55, in index
    field.index(vocab)
  File "/venv/dygiepp/lib/python3.7/site-packages/allennlp/data/fields/label_field.py", line 91, in index
    self.label, self._label_namespace  # type: ignore
  File "//venv/dygiepp/lib/python3.7/site-packages/allennlp/data/vocabulary.py", line 695, in get_token_index
    f"'{token}' not found in vocab namespace '{namespace}', and namespace "
**KeyError: "'' not found in vocab namespace 'None__ner_labels', and namespace does not contain the default OOV token ('@@UNKNOWN@@')"**

Please advise what the input data format to evaluate the model and how can this error be fixed? thanks

dwadden commented 2 years ago

See the README for info on label namespaces. The test fixture doesn't have a dataset field. If you add one, things should work.

unlimit11 commented 2 years ago

Thank you very much.

A workable example for others: {"dataset": "ace-event","doc_key": "0", "sentences": [["Coronavirus", "Thwarts", "Rescue", "of", "Endangered", "Albatrosses", "Menaced", "by", "Giant", "Mice"], ["The", "covid-19", "pandemic", "has", "forced", "a", "delay", "to", "an", "effort", "to", "protect", "vulnerable", "seabirds", "from", "large", "invasive", "mice", "on", "an", "island", "in", "the", "South", "Atlantic", "Ocean."]]}

dwadden commented 2 years ago

Thanks for posting this!