Downloads · 30 days
0
yangliu/chatbotV1
chatbotV1 is a machine learning model from yangliu. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
Downloads · 30 days
0
Access
Public
Updated Jun 14, 2023
Repo size
—
Likes
3
Public
Click a slice to open those files.
Other1.5 KB · 64%
From the Hugging Face model README
单论对话机器人 调用方式
from transformers import AutoModelForCausalLM, AutoTokenizer
checkpoint = "model"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForCausalLM.from_pretrained(checkpoint).cuda()
text = 'Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n### Instruction:\n{你想问的文本}\n\n### Response:'
inputs = tokenizer.encode(generate_input(instruction= ”你想问的文本“), return_tensors="pt")
inputs = inputs.to(model.device)
print(inputs)
outputs = model.generate(inputs,num_beams=3, max_new_tokens=1024, penalty_alpha=0.9, repetition_penalty=1.5)
print(tokenizer.decode(outputs[0]))