Views
No views yet
text = "<s>[INST] What is your favourite condiment? [/INST]"
"Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!</s> "
"[INST] Do you have mayonnaise recipes? [/INST]"1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4model_name = "jovyan/Swallow-MS-7b-v0.1-ChatVector"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForCausalLM.from_pretrained(
7 model_name,
8 torch_dtype=torch.bfloat16,
9 device_map="auto",
10)
11
12prompt = "<s>[INST] 東京工業大学のキャンパスの特色を元気よく説明してください。 [/INST]"
13input_ids = tokenizer.encode(
14 prompt,
15 add_special_tokens=False,
16 return_tensors="pt"
17)
18tokens = model.generate(
19 input_ids.to(device=model.device),
20 max_new_tokens=128,
21 temperature=0.99,
22 top_p=0.95,
23 do_sample=True,
24)
25
26out = tokenizer.decode(tokens[0], skip_special_tokens=True)
27print(out)