allenai / allennlp

An open-source NLP research library, built on PyTorch.
http://www.allennlp.org
Apache License 2.0
11.76k stars 2.25k forks source link

Not able to reproduce steps from usage section #4215

Closed JaveedSpritle closed 4 years ago

JaveedSpritle commented 4 years ago

Hi, I'm trying to use pre-trained allennlp model. I was following https://demo.allennlp.org/reading-comprehension/. installed following packages. pip install allennlp==1.0.0rc1 allennlp-models==1.0.0rc1 after running the sample cmd I'm getting the following error. I have been trying to get it to work, tried different versions also. please let me know if I'm missing something. Thanks

Traceback (most recent call last): File "/home/spritle/Desktop/allenNLP/venv3/bin/allennlp", line 8, in sys.exit(run()) File "/home/spritle/Desktop/allenNLP/venv3/lib/python3.6/site-packages/allennlp/main.py", line 19, in run main(prog="allennlp") File "/home/spritle/Desktop/allenNLP/venv3/lib/python3.6/site-packages/allennlp/commands/init.py", line 93, in main args.func(args) File "/home/spritle/Desktop/allenNLP/venv3/lib/python3.6/site-packages/allennlp/commands/predict.py", line 255, in _predict manager.run() File "/home/spritle/Desktop/allenNLP/venv3/lib/python3.6/site-packages/allennlp/commands/predict.py", line 229, in run for model_input_json, result in zip(batch_json, self._predict_json(batch_json)): File "/home/spritle/Desktop/allenNLP/venv3/lib/python3.6/site-packages/allennlp/commands/predict.py", line 175, in _predict_json results = [self._predictor.predict_json(batch_data[0])] File "/home/spritle/Desktop/allenNLP/venv3/lib/python3.6/site-packages/allennlp/predictors/predictor.py", line 65, in predict_json instance = self._json_to_instance(inputs) File "/home/spritle/Desktop/allenNLP/venv3/lib/python3.6/site-packages/allennlp/predictors/predictor.py", line 213, in _json_to_instance raise NotImplementedError NotImplementedError

matt-gardner commented 4 years ago

I'm pretty sure this was fixed here: https://github.com/allenai/allennlp/pull/4154. Basically, updating to master (on this repo and allennlp_models) should fix the issue. Looks like the fix hasn't made it into a release yet.

JaveedSpritle commented 4 years ago

Thanks! i'll try updating to master

JaveedSpritle commented 4 years ago

@matt-gardner I have tried updating to master and I ran following cmd

echo '{"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?"}' | \ allennlp predict https://storage.googleapis.com/allennlp-public-models/bidaf-elmo-model-2020.03.19.tar.gz -

I'm getting following error:


File "/home/spritle/Desktop/allenNLP2/allennlp/allennlp/common/registrable.py", line 185, in resolve_class_name
    f"{name} is not a registered name for {cls.__name__}. "
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.

Any idea what's the issue?

matt-gardner commented 4 years ago

Did you do pip install allennlp-models?

JaveedSpritle commented 4 years ago

found the issue. I was installing allennlp and allennlp-models on different env. it's working now. thanks!!