allenai / allennlp

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

Cannot load example NER model #2276

Closed andreaferretti closed 5 years ago

andreaferretti commented 5 years ago

Describe the bug I am trying to run the included NER model, using the provided example code. I get the error

allennlp.common.checks.ConfigurationError: "Extra parameters passed to CrfTagger: {'constraint_type': 'BIOUL'}

To Reproduce

Run the example code

from allennlp.predictors.predictor import Predictor
predictor = Predictor.from_path("https://s3-us-west-2.amazonaws.com/allennlp/models/ner-model-2018.04.26.tar.gz")
predictor.predict(
  sentence="Did Uriah honestly think he could beat The Legend of Zelda in under three hours?"
)

Expected behavior Not to get an exception

System (please complete the following information):

Additional context

Full stacktrace:

Traceback (most recent call last):
  File "/Users/andrea/playground/nlp/main.py", line 2, in <module>
    from allen import allen
  File "/Users/andrea/playground/nlp/allen.py", line 4, in <module>
    ner_model = Predictor.from_path('https://s3-us-west-2.amazonaws.com/allennlp/models/ner-model-2018.04.26.tar.gz')
  File "/Users/andrea/.bin/miniconda3/envs/nlp/lib/python3.6/site-packages/allennlp/predictors/predictor.py", line 107, in from_path
    return Predictor.from_archive(load_archive(archive_path), predictor_name)
  File "/Users/andrea/.bin/miniconda3/envs/nlp/lib/python3.6/site-packages/allennlp/models/archival.py", line 156, in load_archive
    cuda_device=cuda_device)
  File "/Users/andrea/.bin/miniconda3/envs/nlp/lib/python3.6/site-packages/allennlp/models/model.py", line 321, in load
    return cls.by_name(model_type)._load(config, serialization_dir, weights_file, cuda_device)
  File "/Users/andrea/.bin/miniconda3/envs/nlp/lib/python3.6/site-packages/allennlp/models/model.py", line 268, in _load
    model = Model.from_params(vocab=vocab, params=model_params)
  File "/Users/andrea/.bin/miniconda3/envs/nlp/lib/python3.6/site-packages/allennlp/common/from_params.py", line 277, in from_params
    return subclass.from_params(params=params, **extras)
  File "/Users/andrea/.bin/miniconda3/envs/nlp/lib/python3.6/site-packages/allennlp/common/from_params.py", line 288, in from_params
    kwargs = create_kwargs(cls, params, **extras)
  File "/Users/andrea/.bin/miniconda3/envs/nlp/lib/python3.6/site-packages/allennlp/common/from_params.py", line 221, in create_kwargs
    params.assert_empty(cls.__name__)
  File "/Users/andrea/.bin/miniconda3/envs/nlp/lib/python3.6/site-packages/allennlp/common/params.py", line 322, in assert_empty
    raise ConfigurationError("Extra parameters passed to {}: {}".format(class_name, self.params))
matt-gardner commented 5 years ago

We've deprecated that parameter, so the old model doesn't work anymore. There's a new model that should work here: https://s3-us-west-2.amazonaws.com/allennlp/models/ner-model-2018.04.26.tar.gz.

One point in favor of @brendan-ai2's arguments about deprecating things...

andreaferretti commented 5 years ago

Apparently, you have given me the same URL I had in my example :-?

joelgrus commented 5 years ago

oops, should be https://s3-us-west-2.amazonaws.com/allennlp/models/ner-model-2018.12.18.tar.gz

joelgrus commented 5 years ago

we should probably direct people to allennlp.pretrained

andreaferretti commented 5 years ago

Thank you very much, that works! You may want to update the documentation on https://allennlp.org/models

matt-gardner commented 5 years ago

Thanks, I didn't realize the website was out of date. PR submitted.

tahseen09 commented 5 years ago

I am loading my own trained model and getting the same error. Can you please tell me to overcome it?

I am using python 3.6.7 conda environment and allennlp version of 0.7.2 @joelgrus @matt-gardner

joelgrus commented 5 years ago

in the 0.8.0 release, the CrfTagger constraint_type parameter was renamed to label_encoding. But I don't think you should be getting this error in 0.7.2, can you post the full stack trace?

fengliangwang commented 5 years ago

hi @joelgrus, when I use https://s3-us-west-2.amazonaws.com/allennlp/models/fine-grained-ner-model-elmo-2018.08.31.tar.gz, I get the same error , any model updated?

oops, should be https://s3-us-west-2.amazonaws.com/allennlp/models/ner-model-2018.12.18.tar.gz

joelgrus commented 5 years ago

sorry, use

https://s3-us-west-2.amazonaws.com/allennlp/models/fine-grained-ner-model-elmo-2018.12.21.tar.gz

fengliangwang commented 5 years ago

sorry, use

https://s3-us-west-2.amazonaws.com/allennlp/models/fine-grained-ner-model-elmo-2018.12.21.tar.gz

Thanks

dataminingLab-nlp commented 4 years ago

Hello. @joelgrus
For Semantic Role Labeling , I get the same error when I use : https://s3-us-west-2.amazonaws.com/allennlp/models/srl-model-2018.05.25.tar.gz

Please advice

"Extra parameters passed to {}: {}".format(class_name, self.params) allennlp.common.checks.ConfigurationError: Extra parameters passed to BasicTextFieldEmbedder: {'elmo': {'do_layer_norm': False, 'dropout': 0.1, 'options_file': '/tmp/tmps971tn46/fta/model.text_field_embedder.elmo.options_file', 'type': 'elmo_token_embedder', 'weight_file': '/tmp/tmps971tn46/fta/model.text_field_embedder.elmo.weight_file'}}

matt-gardner commented 4 years ago

@dataminingLab-nlp, we're in the process of making some breaking changes to the library, and our saved models aren't going to be compatible with the new code. For now, if you want to use that model, just use a released version (0.9). You can also use this model with current code: https://storage.googleapis.com/allennlp-public-models/srl-model-2018.05.25-allennlpv1.0.tar.gz, though it is likely that there will be more breaking changes before the 1.0 release that will also invalidate this model.

dataminingLab-nlp commented 4 years ago

@matt-gardner thank you for your prompt reply.