I'm new to Allennlp, and this is my first time trying it out. I already installed all the required libraries !pip install allennlp !pip install --pre allennlp-models
and my code should be fine too, but I still get this error message saying: ConfigurationError: key "matrix_attention" is required at location "model."
Here's my code:
import sys
from allennlp.predictors.predictor import Predictor
import allennlp_models
predictor = Predictor.from_path(
"https://storage.googleapis.com/allennlp-public-models/bidaf-elmo-model-2018.11.30-charpad.tar.gz"
)
prediction = predictor.predict(
passage="Life expectancy in Asia is at 68 years", question="What is the life expectancy in Asia"
)
print(prediction["best_span_str"])
Do you have any idea how to fix this error? I'm using macOS Catalina and Python 3.6. I really don't know what to do now, so I really need your help. Thanks in advance!
Problem solved: It seemed like my code was outdated, so I updated it. First, I needed to install the following dependencies:
!pip install allennlp
!pip install --pre allennlp-models
And this is my code:
from allennlp.predictors.predictor import Predictor
import allennlp_models.rc
predictor = Predictor.from_path("https://storage.googleapis.com/allennlp-public-models/bidaf-elmo-model-2020.03.19.tar.gz")
result = predictor.predict(
passage="Apple was founded by Steve Jobs, Steve Wozniak, and Ronald Wayne in April 1976 to develop and sell Wozniak\'s Apple I personal computer, though Wayne sold his share back within 12 days. It was incorporated as Apple Computer, Inc., in January 1977, and sales of its computers, including the Apple II, grew quickly.",
question="Who founded Apple?"
)
result['best_span_str']
Also, I used this code on Google Colab if anyone's interested, although this should work elsewhere just fine as well.