Closed alikabeer32 closed 4 years ago
@alikabeer32 it looks like you're using AllenNLP on master, rather than the latest release (v0.9.0). You will need to install https://github.com/allenai/allennlp-models as well to run your code.
You should also import allennlp_models
to get the Bidaf model.
Thanks guys. Moving to latest release fixed it for me.
I just tried your code from above to try allennlp out, I also installed all required libraries and followed your instructions from above, but I still got this error: ConfigurationError: key "matrix_attention" is required at location "model." I first installed those libraries:
!pip install allennlp
!pip install --pre allennlp-models` 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 ideas on how to fix that? I'm also new to Allennlp.
@Unterbelichtet please open a new issue if you have additional problems. I'm not sure what version of AllenNLP you are using, but your code snippet looks out of date. For example, you are using a version of the model that was uploaded in 2018, but we had some breaking changes before the 1.0 release.
I just copied this usage snippet from our demo, and it worked fine:
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")
predictor.predict(
passage="The Matrix is a 1999 science fiction action film written and directed by The Wachowskis, starring Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, Hugo Weaving, and Joe Pantoliano.",
question="Who stars in The Matrix?"
)
Thanks, that worked!
Idid the same as you,but have the" AttributeError: 'Predictor' object has no attribute 'predict'" ,how to solve it @schmmd
@GuanNiPiShi123, same for you. AllenNLP has changed quite a bit since this issue was current. Can you make a new issue with our exact problem?
my code -
The complete error : ConfigurationError( allennlp.common.checks.ConfigurationError: bidaf is not a registered name for Model. You probably need to use the --include-package flag to load your custom code. Alternatively, you can specify your choices using fully-qualified paths, e.g. {"model": "my_module.models.MyModel"} in which case they will be automatically imported correctly.
Sorry I'm quite new to allennlp