Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xy1137030414 opened this issue Mar 22, 2024 · 4 comments
Open

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

xy1137030414 opened this issue Mar 22, 2024 · 4 comments

Comments

@xy1137030414
Copy link

xy1137030414 commented Mar 22, 2024

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

@Jiahaohong
Copy link

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

@xy1137030414
Copy link
Author

xy1137030414 commented Mar 28, 2024 via email

@Jiahaohong
Copy link

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
Copy link
Author

xy1137030414 commented Mar 28, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants