Views
No views yet
1from transformers import AutoTokenizer, AutoModel, AutoModelForCausalLM
2tokenizer = AutoTokenizer.from_pretrained("silk-road/Chat-Haruhi_qwen_1_8", trust_remote_code=True)
3model = AutoModelForCausalLM.from_pretrained("silk-road/Chat-Haruhi_qwen_1_8", trust_remote_code=True).half().cuda()
4model = model.eval()1from ChatHaruhi import ChatHaruhi
2
3chatbot = ChatHaruhi( role_name = 'haruhi', max_len_story = 1000 )
4
5prompt = chatbot.generate_prompt(role='阿虚', text = '我看新一年的棒球比赛要开始了!我们要去参加吗?')
6
7response, history = model.chat(tokenizer, prompt, history=[])
8print(response)
9
10chatbot.append_response(response)