Views
No views yet
facebook/bart-large-cnn, a pre-trained BART (Bidirectional and Auto-Regressive Transformers) model that was fine-tuned on the CNN/DailyMail dataset for abstractive summarization.pipeline API, which provides a simple interface for:max_length: Maximum number of tokens in the summarymin_length: Minimum number of tokens in the summarydo_sample: Set to False for deterministic (greedy) decodingsummarization_pipeline.py: Main script demonstrating the pipeline APIREADME.md: This filepip install transformers torchpython simple_summarization.pypython summarization_pipeline.py1pip install requests
2python summarization_api.py1from transformers import pipeline
2
3# Load the summarization pipeline
4summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
5
6# Summarize text
7text = "Your long article or text here..."
8summary = summarizer(text, max_length=100, min_length=30)
9print(summary[0]['summary_text'])google/pegasus-xsum: Trained on XSum datasett5-small: General-purpose T5 modelsshleifer/distilbart-cnn-12-6: Smaller, faster versionmodel parameter in the pipeline:summarizer = pipeline("summarization", model="google/pegasus-xsum")device=-1 to device=0 in the pipeline