Hope the below snippet help. I use NousResearch/Llama-2-7b-hf as the model_checkpoint to make all the license agreement easier.
pip install -U torch==2.0.1
accelerate==0.22.0 # needed for low_cpu_mem_usage parameter
from transformers import LlamaTokenizer
model_checkpoint = “NousResearch/Llama-2-7b-hf”
tokenizer = LlamaTokenizer.from_pretrained(model_checkpoint)
I learn a lot from the below book. The authors are the instructor for the Generative AI for LLM specialization in DeepLearning.ai. It is a very good complement to the course in my own opinion