EdinburghNLP/xsum
Viewer • Updated • 227k • 34.1k • 145
How to use PavanNeerudu/t5-base-finetuned-xsum with Transformers:
# Load model directly
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("PavanNeerudu/t5-base-finetuned-xsum")
model = AutoModelForSeq2SeqLM.from_pretrained("PavanNeerudu/t5-base-finetuned-xsum")This model is t5-base fine-tuned on Xsum dataset for text summarization.
T5 is an encoder-decoder model pre-trained on a multi-task mixture of unsupervised and supervised tasks and for which each task is converted into a text-to-text format.
To train the T5 model for text-summarization, I have used "summarize" prefix before every sentence and gave the encoding of this sentence as input ids and attention mask. For the labels, I used the encoding of the summaries as the decoder input ids and decoder attention mask.
For generating summaries on a example use:
predictions = []
tokenised_dataset = tokenizer(documents, truncation=True, padding='max_length', max_length=1024, return_tensors='pt')
source_ids = tokenised_dataset['input_ids']
source_mask = tokenised_dataset['attention_mask']
output = model.generate(input_ids=source_ids, attention_mask=source_mask, max_length=256)
print(tokenizer.decode(output[0], skip_special_tokens=True))
We report the ROUGE-1, ROUGE-2 and ROUGE-L on the test datasets.
| ROUGE-1 | ROUGE-2 | ROUGE-L |
|---|---|---|
| 0.3414 | 0.1260 | 0.2832 |