Example Code

#4
by nabeel27 - opened

Can you add more example code in the usage? maybe a working example. Thank You.

yes please, a working example would be great.

from transformers import AutoTokenizer, T5ForConditionalGeneration

tokenizer = AutoTokenizer.from_pretrained("czearing/article-title-generator")
model = T5ForConditionalGeneration.from_pretrained("czearing/article-title-generator")

input_text = "summarize: Your text to be summarized here."
input_ids = tokenizer(input_text, return_tensors="pt").input_ids

outputs = model.generate(input_ids)
summary = tokenizer.decode(outputs[0], skip_special_tokens=True)

print(summary)

Sign up or log in to comment