I am trying to run the AllenNLP demo https://demo.allennlp.org/semantic-role-labeling. When I run the command line or the Python version via Juptyer I get the error mentioned below.
I have installed the required libraries? pip install allennlp==1.0.0 allennlp-models==1.0.0
Running this gives me an error:
from allennlp.predictors.predictor import Predictor
predictor = Predictor.from_path("https://storage.googleapis.com/allennlp-public-models/bert-base-srl-2020.11.19.tar.gz")
predictor.predict(
sentence="Did Uriah honestly think he could beat the game in under three hours?"
)
Update: If I use an older gz download I do not get the error I grabbed this one from their public models site bert-base-srl-2020.09.03.tar.gz
from allennlp.predictors.predictor import Predictor
predictor = Predictor.from_path("https://storage.googleapis.com/allennlp-public-models/bert-base-srl-2020.09.03.tar.gz")
text = "Did Uriah honestly think he could beat the game in under three hours?"
predictor.predict(sentence=text)
Error:
RuntimeError: Error(s) in loading state_dict for SrlBert:
Unexpected key(s) in state_dict: "bert_model.embeddings.position_ids".
OS & versions:
Python: 3.8.6
pip: 20.2.1
Mac OS: Catalina 10.15.7
Are there some dependencies I am maybe missing for BERT? I haven't had any issues with the other AllenNLP examples.
I added an answer but they deleted it. This is how you resolve this:
After posting on github, found out from the AllenNLP folks that it is a version issue. I needed to be using allennlp=1.3.0 and the latest model. Now it works as expected.
This should be fixed in the latest allennlp 1.3 release. Also, the latest archive file is structured-prediction-srl-bert.2020.12.15.tar.gz.