File size: 841 Bytes
57ce5d3
 
 
a98b648
 
 
ee0eb23
a98b648
 
 
c66bb6c
 
ee0eb23
c66bb6c
ee0eb23
a98b648
 
24961c0
 
a98b648
24961c0
 
a98b648
24961c0
a98b648
24961c0
a98b648
 
 
 
24961c0
a98b648
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
---
license: apache-2.0
---
单论对话机器人
调用方式

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