allenai / kb

KnowBert -- Knowledge Enhanced Contextual Word Representations
Apache License 2.0
371 stars 50 forks source link

Having trouble running the "Getting started" section (even the tests do not run) #35

Open devfoo-one opened 3 years ago

devfoo-one commented 3 years ago

Hi,

I am trying to run the KnowBert code but keep getting stuck with the following error when trying to run the tests or the "How to embed sentences or sentence pairs programmatically" snippet:

tests/evaluation/test_wic_reader.py:3: in <module>
    from kb.include_all import  WicDatasetReader
kb/include_all.py:2: in <module>
    from kb.kg_embedding import KGTupleReader, KGTupleModel
kb/kg_embedding.py:8: in <module>
    from allennlp.data import DatasetReader, Token, Vocabulary
/opt/conda/envs/knowbert/lib/python3.6/site-packages/allennlp/data/__init__.py:1: in <module>
    from allennlp.data.dataset_readers.dataset_reader import DatasetReader
/opt/conda/envs/knowbert/lib/python3.6/site-packages/allennlp/data/dataset_readers/__init__.py:10: in <module>
    from allennlp.data.dataset_readers.ccgbank import CcgBankDatasetReader
/opt/conda/envs/knowbert/lib/python3.6/site-packages/allennlp/data/dataset_readers/ccgbank.py:9: in <module>
    from allennlp.data.dataset_readers.dataset_reader import DatasetReader
/opt/conda/envs/knowbert/lib/python3.6/site-packages/allennlp/data/dataset_readers/dataset_reader.py:4: in <module>
    from allennlp.data.instance import Instance
/opt/conda/envs/knowbert/lib/python3.6/site-packages/allennlp/data/instance.py:4: in <module>
    from allennlp.data.fields import TextField, ListField, SpanField
/opt/conda/envs/knowbert/lib/python3.6/site-packages/allennlp/data/fields/__init__.py:7: in <module>
    from allennlp.data.fields.array_field import ArrayField
/opt/conda/envs/knowbert/lib/python3.6/site-packages/allennlp/data/fields/array_field.py:10: in <module>
    class ArrayField(Field[numpy.ndarray]):
/opt/conda/envs/knowbert/lib/python3.6/site-packages/allennlp/data/fields/array_field.py:45: in ArrayField
    @overrides
/opt/conda/envs/knowbert/lib/python3.6/site-packages/overrides/overrides.py:88: in overrides
    return _overrides(method, check_signature, check_at_runtime)
/opt/conda/envs/knowbert/lib/python3.6/site-packages/overrides/overrides.py:114: in _overrides
    _validate_method(method, super_class, check_signature)
/opt/conda/envs/knowbert/lib/python3.6/site-packages/overrides/overrides.py:135: in _validate_method
    ensure_signature_is_compatible(super_method, method, is_static)
/opt/conda/envs/knowbert/lib/python3.6/site-packages/overrides/signature.py:93: in ensure_signature_is_compatible
    ensure_return_type_compatibility(super_type_hints, sub_type_hints, method_name)
/opt/conda/envs/knowbert/lib/python3.6/site-packages/overrides/signature.py:288: in ensure_return_type_compatibility
    f"{method_name}: return type `{sub_return}` is not a `{super_return}`."
E   TypeError: ArrayField.empty_field: return type `None` is not a `allennlp.data.fields.field.Field`.

Steps to reproduce

  1. Enter a clean anaconda docker container docker run -it continuumio/anaconda3
  2. apt-get update && apt install -y g++ make
  3. git clone https://github.com/allenai/kb.git
  4. conda create -n knowbert python=3.6.7
  5. source activate knowbert
  6. pip install torch==1.2.0
  7. pip install -r requirements.txt
  8. python -c "import nltk; nltk.download('wordnet')"
  9. python -m spacy download en_core_web_sm
  10. pip install --editable .
  11. pytest -v tests
lunarie16 commented 3 years ago

Before running tests downgrading to overrides==3.1.0 and scikit-learn==0.22.2 solves the issue!

devfoo-one commented 3 years ago

@lunarie16 Thanks! I´ve changed my requirements to

torch==1.4.0
Flask
waitress
ujson
spacy==2.0.18
urllib3==1.25.10
click==7.1.2
overrides==3.1.0
scikit-learn==0.22.2

and it works as expected.

leonodelee commented 2 years ago

Hello, have you installed the allennlp? I can't install it with the official guide

gpiat commented 2 years ago

@leonodelee Hello, have you tried following the steps I give in my answers to issue #39 ? If so and you still have trouble, please provide error messages, or if there are none, a more detailed description of the abnormal behavior.

leonodelee commented 2 years ago

@leonodelee Hello, have you tried following the steps I give in my answers to issue #39 ? If so and you still have trouble, please provide error messages, or if there are none, a more detailed description of the abnormal behavior.

Thank you for your kindful help, I solved this problem by 'pip install allennlp==0.8.2' and other install instructions in https://github.com/allenai/kb/issues/39