Search code examples
huggingface-transformersbart

BART loading from HuggingFace requires logging in


I'm trying to use pretrained model from HuggingFace. However, I get the following error,

OSError: bart-large is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'
If this is a private repository, make sure to pass a token having permission to this repo with `use_auth_token` or log in with `huggingface-cli login` and pass `use_auth_token=True`.

The code I'm using is a little dated, and I have not found definite solution, and I'm not sure if it is a bug, or I really need to somehow log in to use this model.


Solution

  • The correct model identifier is facebook/bart-large and not bart-large:

    from transformers import BartTokenizer, BartModel
    
    tokenizer = BartTokenizer.from_pretrained('facebook/bart-large')
    model = BartModel.from_pretrained('facebook/bart-large')