from transformers import T5ForConditionalGeneration
from transformers import T5TokenizerFast as T5Tokenizer
model = "svjack/summary-dialogue-eng"
device = "cpu"
tokenizer = T5Tokenizer.from_pretrained(model)
model = T5ForConditionalGeneration.from_pretrained(model).to(device).eval()
prompt = "The Wisconsin Territorial Centennial half dollar was designed by David Parsons and Benjamin Hawkins and minted by the United States Bureau of the Mint in 1936. The obverse (pictured) depicts a pick axe and lead ore, referring to the lead mining in early Wisconsin"
prompt = "{}\nCandidates:Tom Jack".format(prompt)
encode = tokenizer(prompt, return_tensors='pt').to(device)
answer = model.generate(encode.input_ids,
max_length = 128,
num_beams=2,
top_p = 0.95,
top_k = 50,
repetition_penalty = 2.5,
length_penalty=1.0,
early_stopping=True,
)[0]
decoded = tokenizer.decode(answer, skip_special_tokens=True)
decoded.replace("Tom:", "\n").replace("Jack:", "\n").split("\n")
</br>
['',
' Have you seen the Wisconsin Territorial Centennial half dollar? ',
' Yeah, it was designed by David Parsons and Benjamin Hawkins. ',
' What is it? ',
" It's a half dollar with a pick axe and lead ore. ",
" That's great!"]