File size: 691 Bytes
8baf7bb
dbc9005
76e2ddc
8baf7bb
 
76e2ddc
8baf7bb
76e2ddc
8baf7bb
 
dbc9005
8baf7bb
76e2ddc
8baf7bb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
import torch

tokenizer = AutoTokenizer.from_pretrained("lightblue/ao-karasu-72B")
model = AutoModelForCausalLM.from_pretrained("lightblue/ao-karasu-72B", device_map="auto")

pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)

messages = [{"role": "system", "content": "あなたはAIアシスタントです。"}]
messages.append({"role": "user", "content": "イギリスの首相は誰ですか?"})

prompt = tokenizer.apply_chat_template(conversation=messages, add_generation_prompt=True, tokenize=False)

pipe(prompt, max_new_tokens=100, do_sample=False, temperature=0.0, return_full_text=False)