Slide 30
Slide 30 text
͘͞ΒͷΫϥυͰେنݴޠϞσϧΛಈ͔ͨ͢Ίͷखॱ̔
• αϯϓϧίʔυͷ࣮ߦ
• Hugging FaceͰެ։͞Ε͍ͯΔɺOpenCALMͷαϯϓϧίʔυΛಈ͔͠·͢
• https://huggingface.co/cyberagent/open-calm-7b
30
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("cyberagent/open-calm-7b", device_map="auto", torch_dtype=torch.
fl
oat16)
tokenizer = AutoTokenizer.from_pretrained("cyberagent/open-calm-7b")
inputs = tokenizer("AIʹΑͬͯࢲୡͷΒ͠ɺ", return_tensors="pt").to(model.device)
with torch.no_grad():
tokens = model.generate(
**inputs,
max_new_tokens=64,
do_sample=True,
temperature=0.7,
top_p=0.9,
repetition_penalty=1.05,
pad_token_id=tokenizer.pad_token_id,
)
output = tokenizer.decode(tokens[0], skip_special_tokens=True)
print(output)