单论对话机器人
调用方式

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]))

{"license": "apache-2.0"}
license:apache-2.0 region:us
TAGS
#license-apache-2.0 #region-us 

单论对话机器人
调用方式

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 = URL(generate_input(instruction= ”你想问的文本“), return_tensors="pt")


inputs = URL(URL)

print(inputs)

outputs = model.generate(inputs,num_beams=3,
                        max_new_tokens=1024,
                        penalty_alpha=0.9,
                        repetition_penalty=1.5)
                        
print(URL(outputs[0]))

### Instruction:\n{你想问的文本}\n\n### Response:'


inputs = URL(generate_input(instruction= ”你想问的文本“), return_tensors="pt")


inputs = URL(URL)

print(inputs)

outputs = model.generate(inputs,num_beams=3,
                        max_new_tokens=1024,
                        penalty_alpha=0.9,
                        repetition_penalty=1.5)
                        
print(URL(outputs[0]))
TAGS
#license-apache-2.0 #region-us 
 ### Instruction:\n{你想问的文本}\n\n### Response:'


inputs = URL(generate_input(instruction= ”你想问的文本“), return_tensors="pt")


inputs = URL(URL)

print(inputs)

outputs = model.generate(inputs,num_beams=3,
                        max_new_tokens=1024,
                        penalty_alpha=0.9,
                        repetition_penalty=1.5)
                        
print(URL(outputs[0]))