trankit icon indicating copy to clipboard operation
trankit copied to clipboard

OSError: Can't load weights for 'xlm-roberta-base'.

Open xy1137030414 opened this issue 11 months ago • 4 comments

OSError: Can't load weights for 'xlm-roberta-base'. Make sure that:

  • 'xlm-roberta-base' is a correct model identifier listed on 'https://huggingface.co/models'

  • or 'xlm-roberta-base' is the correct path to a directory containing a file named one of pytorch_model.bin, tf_model.h5, model.ckpt.

i create a new folder under the"C:\Users\Name.cache",name it"xlm-roberta-base",and I download the pytorch_model.bin to the folder,but still have error

xy1137030414 avatar Mar 22 '24 14:03 xy1137030414

Did you solve this problem? I have the same question.

Jiahaohong avatar Mar 28 '24 03:03 Jiahaohong

I have not solved the problem yet, i use another nlptools for my study. If you fix it,could you tell me?thank you!


From: Jiahaohong @.> Sent: Thursday, March 28, 2024 11:06 AM To: nlp-uoregon/trankit @.> Cc: Xu Yue @.>; Author @.> Subject: Re: [nlp-uoregon/trankit] OSError: Can't load weights for 'xlm-roberta-base'. (Issue #83)

Did you solve this problem? I have the same question.

— Reply to this email directly, view it on GitHubhttps://github.com/nlp-uoregon/trankit/issues/83#issuecomment-2024315477, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARRIME2XZZDCCRTBCLHYHWDY2OCMZAVCNFSM6AAAAABFDMZDW6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRUGMYTKNBXG4. You are receiving this because you authored the thread.Message ID: @.***>

xy1137030414 avatar Mar 28 '24 04:03 xy1137030414

I solve the problm by repalcing the model path to my local model path.

# ./trankit-master/trankit/models/base_models.py
class Base_Model(nn.Module):  # currently assuming the pretrained transformer is XLM-Roberta
    def __init__(self, config, task_name):
        super().__init__()
        self.config = config
        self.task_name = task_name
        # xlmr encoder
        self.xlmr_dim = 768 if config.embedding_name == 'xlm-roberta-base' else 1024
        # self.xlmr = XLMRobertaModel.from_pretrained(config.embedding_name,
        #                                             cache_dir=os.path.join(config._cache_dir, config.embedding_name),
        #                                             output_hidden_states=True)
        self.xlmr = XLMRobertaModel.from_pretrained('./cache/xlm-roberta-base',
                                                    cache_dir=os.path.join(config._cache_dir, config.embedding_name),
                                                    output_hidden_states=True)

Jiahaohong avatar Mar 28 '24 07:03 Jiahaohong

thank you!谢谢你!


From: Jiahaohong @.> Sent: Thursday, March 28, 2024 3:08 PM To: nlp-uoregon/trankit @.> Cc: Xu Yue @.>; Author @.> Subject: Re: [nlp-uoregon/trankit] OSError: Can't load weights for 'xlm-roberta-base'. (Issue #83)

I solve the problm by repalcing the model path to my local model path.

./trankit-master/trankit/models/base_models.py

class Base_Model(nn.Module): # currently assuming the pretrained transformer is XLM-Roberta def init(self, config, task_name): super().init() self.config = config self.task_name = task_name # xlmr encoder self.xlmr_dim = 768 if config.embedding_name == 'xlm-roberta-base' else 1024 # self.xlmr = XLMRobertaModel.from_pretrained(config.embedding_name, # cache_dir=os.path.join(config._cache_dir, config.embedding_name), # output_hidden_states=True) self.xlmr = XLMRobertaModel.from_pretrained('./cache/xlm-roberta-base', cache_dir=os.path.join(config._cache_dir, config.embedding_name), output_hidden_states=True)

― Reply to this email directly, view it on GitHubhttps://github.com/nlp-uoregon/trankit/issues/83#issuecomment-2024545689, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARRIMEYPF4EOMGF5MOGB2ITY2O6WZAVCNFSM6AAAAABFDMZDW6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRUGU2DKNRYHE. You are receiving this because you authored the thread.Message ID: @.***>

xy1137030414 avatar Mar 28 '24 12:03 xy1137030414