Skip to content

Cannot load model from the hugging face checkpoint #8

@karynaur

Description

@karynaur

Hey, I am unable to load the model from the huggingface checkpoint. Here is the code and the error:

from DictMatching.moco import MoCo
from utilsWord.test_args import getArgs
from transformers import AutoConfig, AutoTokenizer
import torch

args = getArgs()

tokenizer = AutoTokenizer.from_pretrained('cwszz/XPR')
config = AutoConfig.from_pretrained("cwszz/XPR")
model = MoCo(config=config,args=args,K=0,T=0.06)
model.load_state_dict(torch.load('model/pytorch_model.bin'))

The error im getting:

Traceback (most recent call last):
  File "analysis.py", line 19, in <module>
    model.load_state_dict(torch.load('model/pytorch_model.bin'))
  File "/home/adityas/.local/lib/python3.8/site-packages/torch/serialization.py", line 1026, in load
    return _load(opened_zipfile,
  File "/home/adityas/.local/lib/python3.8/site-packages/torch/serialization.py", line 1438, in _load
    result = unpickler.load()
  File "/home/adityas/.local/lib/python3.8/site-packages/transformers/models/xlm_roberta/tokenization_xlm_roberta.py", line 198, in __setstate__
    self.sp_model.LoadFromSerializedProto(self.sp_model_proto)
AttributeError: 'XLMRobertaTokenizer' object has no attribute 'sp_model_proto'

@cwszz can you help me with this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions