File size: 503 Bytes
4d5aebb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
from transformers import AutoModelForCausalLM, AutoTokenizer
import sys
import os
model_id = os.getcwd()
if len(sys.argv) > 1:
model_id = sys.argv[1]
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id).cuda().bfloat16()
prompt = "Lily picked up a flower."
inputs = tokenizer(prompt, return_tensors="pt", return_token_type_ids=False).to('cuda')
out = model.generate(**inputs, max_new_tokens=80).ravel()
out = tokenizer.decode(out)
print(out)
|