OSError: Can't load tokenizer for 'meta-llama/CodeLlama-7b-hf'

I’m following the official doc for codeLlama in hf to do code infilling task. I have tried to log in via:

>  huggingface-cli login

And here is my code:

from transformers import LlamaForCausalLM, CodeLlamaTokenizer

tokenizer = CodeLlamaTokenizer.from_pretrained("meta-llama/CodeLlama-7b-hf")
model = LlamaForCausalLM.from_pretrained("meta-llama/CodeLlama-7b-hf")
PROMPT = '''def remove_non_ascii(s: str) -> str:
    """ <FILL_ME>
    return result
'''
input_ids = tokenizer(PROMPT, return_tensors="pt")["input_ids"]
generated_ids = model.generate(input_ids, max_new_tokens=128)

filling = tokenizer.batch_decode(generated_ids[:, input_ids.shape[1]:], skip_special_tokens = True)[0]
print(PROMPT.replace("<FILL_ME>", filling))

But I have the following error. Can anyone see what’s wrong here?

OSError: Can't load tokenizer for 'meta-llama/CodeLlama-7b-hf'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'meta-llama/CodeLlama-7b-hf' is the correct path to a directory containing all relevant files for a CodeLlamaTokenizer tokenizer.
1 Like

The model is a gated model. The document may be out of date.:sweat_smile: