allenai / allennlp-hub

A collection of selected of models built with AllenNLP.
Apache License 2.0
25 stars 9 forks source link

Error loading pretrained models #19

Closed mcneela closed 4 years ago

mcneela commented 4 years ago

I'm getting the following error when trying to load the pretrained NER model

  File "<stdin>", line 1, in <module>
  File "utils.py", line 111, in fine_grained_ner_model
    "sentence-tagger",
  File "utils.py", line 17, in _load_predictor
    archive = load_archive(archive_file)
  File "/home/ubuntu/anaconda3/envs/test-env/lib/python3.7/site-packages/allennlp/models/archival.py", line 230, in load_archive
    cuda_device=cuda_device)
  File "/home/ubuntu/anaconda3/envs/test-env/lib/python3.7/site-packages/allennlp/models/model.py", line 327, in load
    return cls.by_name(model_type)._load(config, serialization_dir, weights_file, cuda_device)
  File "/home/ubuntu/anaconda3/envs/test-env/lib/python3.7/site-packages/allennlp/models/model.py", line 265, in _load
    model = Model.from_params(vocab=vocab, params=model_params)
  File "/home/ubuntu/anaconda3/envs/test-env/lib/python3.7/site-packages/allennlp/common/from_params.py", line 365, in from_params
    return subclass.from_params(params=params, **extras)
  File "/home/ubuntu/anaconda3/envs/test-env/lib/python3.7/site-packages/allennlp/common/from_params.py", line 386, in from_params
    kwargs = create_kwargs(cls, params, **extras)
  File "/home/ubuntu/anaconda3/envs/test-env/lib/python3.7/site-packages/allennlp/common/from_params.py", line 133, in create_kwargs
    kwargs[name] = construct_arg(cls, name, annotation, param.default, params, **extras)
  File "/home/ubuntu/anaconda3/envs/test-env/lib/python3.7/site-packages/allennlp/common/from_params.py", line 229, in construct_arg
    return annotation.from_params(params=subparams, **subextras)
  File "/home/ubuntu/anaconda3/envs/test-env/lib/python3.7/site-packages/allennlp/common/from_params.py", line 365, in from_params
    return subclass.from_params(params=params, **extras)
  File "/home/ubuntu/anaconda3/envs/test-env/lib/python3.7/site-packages/allennlp/modules/text_field_embedders/basic_text_field_embedder.py", line 160, in from_params
    for name, subparams in token_embedder_params.items()
  File "/home/ubuntu/anaconda3/envs/test-env/lib/python3.7/site-packages/allennlp/modules/text_field_embedders/basic_text_field_embedder.py", line 160, in <dictcomp>
    for name, subparams in token_embedder_params.items()
  File "/home/ubuntu/anaconda3/envs/test-env/lib/python3.7/site-packages/allennlp/common/from_params.py", line 365, in from_params
    return subclass.from_params(params=params, **extras)
  File "/home/ubuntu/anaconda3/envs/test-env/lib/python3.7/site-packages/allennlp/modules/token_embedders/elmo_token_embedder.py", line 110, in from_params
    options_file = params.pop('options_file')
  File "/home/ubuntu/anaconda3/envs/test-env/lib/python3.7/site-packages/allennlp/common/params.py", line 260, in pop
    raise ConfigurationError("key \"{}\" is required at location \"{}\"".format(key, self.history))
allennlp.common.checks.ConfigurationError: 'key "options_file" is required at location "model.text_field_embedder.token_embedders.elmo."'

How do I pass the options_file to the ELMO model? I tried passing it as a json key in the overrides argument of the load_archive method, but to no avail.

IRNLPCoder commented 4 years ago

allennlp.common.checks.ConfigurationError: 'key "options_file" is required at location "model.text_field_embedder.token_embedders.elmo."' when load predictor = Predictor.from_path("https://s3-us-west-2.amazonaws.com/allennlp/models/fine-grained-ner-model-elmo-2020.02.10.tar.gz")

ghost commented 4 years ago

Understood, but is there a solution to it, passing options file like an argument or saving in a specific location for the predictor to detect it?

Older models have no problem when loaded in the predictor.

matt-gardner commented 4 years ago

Solution: use a released version of allennlp. We are currently moving things around and making breaking changes, in preparation for a major new release (hopefully we'll have a release candidate out within a couple of weeks).

This repository is going to be deleted soon, as we decided on a different solution to the problem this repo was trying to solve. The new solution is this repo: https://github.com/allenai/allennlp-models. I would warn you, though, to not rely on anything you see in any of these repos until a release candidate is out, as things are still in flux. The released version is stable, and it will be stable again once we have another release out.