nlp-uoregon / trankit

Trankit is a Light-Weight Transformer-based Python Toolkit for Multilingual Natural Language Processing
Apache License 2.0
721 stars 99 forks source link

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

Open xy1137030414 opened 4 months ago

xy1137030414 commented 4 months ago

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

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

Jiahaohong commented 4 months ago

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

xy1137030414 commented 4 months ago

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: @.***>

Jiahaohong commented 4 months ago

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)
xy1137030414 commented 4 months ago

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: @.***>