allenai / kb

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

what is the version of packages in requirements.txt #39

Closed lshowway closed 2 years ago

lshowway commented 2 years ago

hi, when i run python -m pip install --upgrade pip, I fail to install the packages, could you tell us the version of the required packages ?

gpiat commented 2 years ago

python -m pip install --upgrade pip will upgrade your installation of pip, not install packages from requirements.txt. You want to run pip install -r requirements.txt for that. If you have trouble:

Create a virtual (or prefarably conda) environment with python 3.6.7.
Replace the second line in the requirements.txt file with: git+https://github.com/matt-peters/allennlp.git@2d7ba1cb108428aaffe2dce875648253b44cb5ba try pip install -r requirements.txt, I expect that should work. If it doesn't, you can try specifying the versions of the packages:

pytest==6.2.2
nltk==3.5
ipython==7.16.1
spacy==2.0.18

Hope this helps

lshowway commented 2 years ago

@gpiat firstly, i run pip install torch==1.2.0, but when I install allennlp (version is not specified), torch 1.9.1 is then installed. So what is the version of allnlp. I recommend more detailed package versions are provided, because when I install allennlp==2.7.0, some file doesn't exist. For example, from allennlp.data import Instance, DataIterator, Vocabulary, DataIterator does not exist.

gpiat commented 2 years ago

1.2.0 is the correct version of torch. The version of AllenNLP that is required is 0.8.2 fp16_e_s3. This is specified in the two first lines of the requirements.txt file:

# this is the fp16_e_s3 branch
git+git://github.com/matt-peters/allennlp.git@2d7ba1cb108428aaffe2dce875648253b44cb5ba

You cannot install this version from PyPI, hence the git+git:// requirement which builds the library from source.
Some versions of git won't resolve this type of dependency, and if you are unable to update git (for instance if you're working on a shared computing cluster), this method of installation may fail. That is why I suggest changing to git+https://, which works more consistently.
My version of git is 1.8.3.1. Unless your version of git is older than this, provided you have created your conda environment properly, pip install -r requirements.txt should install all the correct versions of all the dependencies you need.
If that fails, you can exit the kb directory, clone the AllenNLP 0.8.2 fp16_e_s3 repo and install it from source using

git clone https://github.com/matt-peters/allennlp.git
cd allennlp
git checkout fp16_e_s3
pip install -e .

The . is important, it refers to the working directory. Once that's done (if it succeeded), you can comment out the second line of the requirements.txt file and run pip install -r requirements.txt.

This project will not work out-of-the-box with any version of AllenNLP you can get from PyPI. Matthew Peters' fp16_e_s3 branch of AllenNLP implements support for half-precision floats, better support for resource path caching, and better support for querying AWS. If all else fails you may be able to get away with using vanilla AllenNLP 0.8.2 (pip install allennlp==0.8.2) if you replace most references to online resources with local paths in the JSONNET config files for the models. However, I would only recommend this as a last resort.

lshowway commented 2 years ago

@gpiat Thank you very much! It helps me solve problems.

gpiat commented 2 years ago

My pleasure. Is your problem entirely solved? If so, would you be willing to close the issue, please?