cooelf / SemBERT

Semantics-aware BERT for Language Understanding (AAAI 2020)
https://arxiv.org/abs/1909.02209
MIT License
285 stars 55 forks source link

Missing key(s) in state_dict: "bert_model.embeddings.position_ids". #19

Closed Sajemiur closed 3 years ago

Sajemiur commented 3 years ago

Hello! Trying to run run_snli_predict.py with parameters as suggested on your main page, with real-time semantic role labeling. I downloaded all neccesary models provided on the main page. Yet I received following error. I'll apreciate any help.

Traceback (most recent call last):
  File "C:/Users/Sajemiur/SemBERT/run_snli_predict.py", line 598, in <module>
    main()
  File "C:/Users/Sajemiur/SemBERT/run_snli_predict.py", line 464, in main
    srl_predictor = SRLPredictor(args.tagger_path)
  File "C:\Users\Sajemiur\SemBERT\tag_model\tagging.py", line 7, in __init__
    self.predictor = Predictor.from_path(SRL_MODEL_PATH)
  File "C:\Users\Sajemiur\anaconda3\envs\transformers\lib\site-packages\allennlp\predictors\predictor.py", line 275, in from_path
    load_archive(archive_path, cuda_device=cuda_device),
  File "C:\Users\Sajemiur\anaconda3\envs\transformers\lib\site-packages\allennlp\models\archival.py", line 192, in load_archive
    model = Model.load(
  File "C:\Users\Sajemiur\anaconda3\envs\transformers\lib\site-packages\allennlp\models\model.py", line 398, in load
    return model_class._load(config, serialization_dir, weights_file, cuda_device, opt_level)
  File "C:\Users\Sajemiur\anaconda3\envs\transformers\lib\site-packages\allennlp\models\model.py", line 337, in _load
    model.load_state_dict(model_state)
  File "C:\Users\Sajemiur\anaconda3\envs\transformers\lib\site-packages\torch\nn\modules\module.py", line 846, in load_state_dict
    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for SrlBert:
    Missing key(s) in state_dict: "bert_model.embeddings.position_ids". 

Process finished with exit code 1

Python 3.8 Tranformers | 3.2 allennlp | 1.0.0 allennlp-models | 1.1.0rc4

cooelf commented 3 years ago

Please try a lower version of AllenNLP.

Our experiment environment for reference:

Python 3.6+ PyTorch (1.0.0) AllenNLP (0.8.1)