#allennlp
Вопрос:
Я новичок в AllenNLP. Пожалуйста, помогите мне узнать, как загрузить модель из Huggingface в предиктор.
Я пытаюсь позволить AllenNLP загрузить модель трансформаторов HuggingFace.
Когда я пробую следующий пример кода, я сталкиваюсь с ошибкой после загрузки:
from allennlp.predictors.predictor import Predictor
predictor = Predictor.from_path("hf://bert-large-uncased-whole-word-masking-finetuned-squad")
2021-08-28 15:48:44,371 - INFO - allennlp.models.archival - loading archive file hf://bert-large-uncased-whole-word-masking-finetuned-squad from cache at /home/user/.allennlp/cache/bert-large-uncased-whole-word-masking-finetuned-squad.242d9dbb66bb5033025196d5678907307f8fb098
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/tmp/ipykernel_20988/3906614977.py in <module>
2
3
----> 4 predictor = Predictor.from_path("hf://bert-large-uncased-whole-word-masking-finetuned-squad")
~/data/anaconda3/envs/py37/lib/python3.7/site-packages/allennlp/predictors/predictor.py in from_path(cls, archive_path, predictor_name, cuda_device, dataset_reader_to_load, frozen, import_plugins, overrides, **kwargs)
364 plugins.import_plugins()
365 return Predictor.from_archive(
--> 366 load_archive(archive_path, cuda_device=cuda_device, overrides=overrides),
367 predictor_name,
368 dataset_reader_to_load=dataset_reader_to_load,
~/data/anaconda3/envs/py37/lib/python3.7/site-packages/allennlp/models/archival.py in load_archive(archive_file, cuda_device, overrides, weights_file)
223 # Instantiate model and dataset readers. Use a duplicate of the config, as it will get consumed.
224 dataset_reader, validation_dataset_reader = _load_dataset_readers(
--> 225 config.duplicate(), serialization_dir
226 )
227 model = _load_model(config.duplicate(), weights_path, serialization_dir, cuda_device)
~/data/anaconda3/envs/py37/lib/python3.7/site-packages/allennlp/models/archival.py in _load_dataset_readers(config, serialization_dir)
255 # to the default dataset_reader used for both training and validation.
256 validation_dataset_reader_params = config.get(
--> 257 "validation_dataset_reader", dataset_reader_params.duplicate()
258 )
259
AttributeError: 'NoneType' object has no attribute 'duplicate'