svjack's picture
Update README.md
6bfcd55
|
raw
history blame
518 Bytes
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
'''
的肖像,由,和,制作,在艺术站上趋势
'''