EdinburghNLP/xsum
Viewer • Updated • 227k • 28.7k • 146
How to use Eymeee/xsum-bart-summarizer with Transformers:
# Use a pipeline as a high-level helper
# Warning: Pipeline type "summarization" is no longer supported in transformers v5.
# You must load the model directly (see below) or downgrade to v4.x with:
# 'pip install "transformers<5.0.0'
from transformers import pipeline
pipe = pipeline("summarization", model="Eymeee/xsum-bart-summarizer") # Load model directly
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("Eymeee/xsum-bart-summarizer")
model = AutoModelForSeq2SeqLM.from_pretrained("Eymeee/xsum-bart-summarizer")This model is facebook/bart-base fine-tuned on the XSum dataset for abstractive
single-sentence news summarization. It is intended to summarize BBC-style news
articles into concise summaries.
facebook/bart-baseEdinburghNLP/xsumThe checkpoint was evaluated on all 11,334 XSum test examples.
| Metric | Value |
|---|---|
| ROUGE-1 | 0.3938 |
| ROUGE-2 | 0.1696 |
| ROUGE-L | 0.3197 |
| ROUGE-Lsum | 0.3196 |
| BERTScore precision mean | 0.9136 |
| BERTScore recall mean | 0.9000 |
| BERTScore F1 mean | 0.9066 |
ROUGE was computed with stemming enabled. BERTScore was computed with
roberta-base.
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
repo_id = "Eymeee/xsum-bart-summarizer"
tokenizer = AutoTokenizer.from_pretrained(repo_id)
model = AutoModelForSeq2SeqLM.from_pretrained(repo_id)
article = """
The government announced a new transport plan after months of consultation with
local councils and passenger groups. Ministers said the proposal would improve
bus and rail services, reduce delays, and give local authorities more control
over routes and fares.
"""
inputs = tokenizer(
article,
return_tensors="pt",
max_length=512,
truncation=True,
)
output_ids = model.generate(
**inputs,
num_beams=4,
length_penalty=2.0,
max_length=64,
no_repeat_ngram_size=3,
early_stopping=True,
)
summary = tokenizer.decode(output_ids[0], skip_special_tokens=True)
print(summary)
This model is part of an end-to-end portfolio project covering dataset exploration, preprocessing, fine-tuning, evaluation, and a local Gradio demo. See the GitHub repository for the full code and evaluation report.
Base model
facebook/bart-base