forked from SmartFlowAI/TheGodOfCookery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli_demo.py
18 lines (14 loc) · 843 Bytes
/
cli_demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import torch
from modelscope import AutoTokenizer, AutoModelForCausalLM
from web_demo import GenerationConfig, generate_interactive
model_name_or_path = "zhanghuiATchina/zhangxiaobai_shishen2_full" # 对于二代模型改为 zhangxiaobai_shishen2_full
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_name_or_path, trust_remote_code=True, torch_dtype=torch.bfloat16,
device_map='auto')
model = model.eval()
messages = []
generation_config = GenerationConfig(max_length=204, top_p=0.8, temperature=0.8, repetition_penalty=1.002)
response, history = model.chat(tokenizer, "你好", history=[])
print(response)
response, history = model.chat(tokenizer, "酸菜鱼怎么做", history=history)
print(response)