Video_dataset / llama_test.py
yihaocs's picture
Upload folder using huggingface_hub
2638901
raw
history blame contribute delete
417 Bytes
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("/export/share/txie/llama2/Llama-2-7b-hf")
model = AutoModelForCausalLM.from_pretrained("/export/share/txie/llama2/Llama-2-7b-hf", torch_dtype=torch.bfloat16)
inputs = tokenizer("The world is", return_tensors="pt")
sample = model.generate(**inputs, max_length=128)
print(tokenizer.decode(sample[0]))