File size: 518 Bytes
ae0a2b1
 
 
 
 
 
6bfcd55
ae0a2b1
 
 
 
 
6bfcd55
ae0a2b1
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
```python
from transformers import T5Tokenizer, MT5ForConditionalGeneration
model = "svjack/prompt-extend-chinese"
device = "cpu"
tokenizer = T5Tokenizer.from_pretrained(model)
model = MT5ForConditionalGeneration.from_pretrained(model).to(device).eval()
prompt = "护国公克伦威尔"
encode = tokenizer(prompt, return_tensors='pt').to(device)
answer = model.generate(encode.input_ids)[0]
decoded = tokenizer.decode(answer, skip_special_tokens=True)
decoded
'''
的肖像,由,和,制作,在艺术站上趋势
'''
```