单论对话机器人 调用方式
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]))