YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

Summarization Pipeline Project

This project demonstrates how to use the Hugging Face Pipeline API to load a pre-trained summarization model and generate summaries from example text.

What Was Done

  1. Model Selection: Used 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.

  2. Pipeline API: Leveraged Hugging Face's pipeline API, which provides a simple interface for:

    • Loading pre-trained models
    • Handling tokenization automatically
    • Running inference with minimal code
  3. Examples: Tested the model on multiple example texts covering different topics:

    • Artificial intelligence and machine learning
    • Climate change
    • The Renaissance period
    • A longer article-style text
  4. Configuration: Used parameters to control summary length:

    • max_length: Maximum number of tokens in the summary
    • min_length: Minimum number of tokens in the summary
    • do_sample: Set to False for deterministic (greedy) decoding

Files

  • summarization_pipeline.py: Main script demonstrating the pipeline API
  • README.md: This file

Usage

Installation

pip install transformers torch

Running the Scripts

Option 1: Simple version (recommended, avoids dependency issues)

python simple_summarization.py

Option 2: Pipeline API version

python summarization_pipeline.py

Note: May have dependency issues in some environments. See SETUP_GUIDE.md

Option 3: Using Inference API

pip install requests
python summarization_api.py

Using in Your Own Code

from transformers import pipeline

# Load the summarization pipeline
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")

# Summarize text
text = "Your long article or text here..."
summary = summarizer(text, max_length=100, min_length=30)
print(summary[0]['summary_text'])

Model Information

  • Model: facebook/bart-large-cnn
  • Task: Abstractive Summarization
  • Training Data: CNN/DailyMail dataset
  • Architecture: BART (Bidirectional and Auto-Regressive Transformers)

Alternative Models

You can easily switch to other pre-trained summarization models:

  • google/pegasus-xsum: Trained on XSum dataset
  • t5-small: General-purpose T5 model
  • sshleifer/distilbart-cnn-12-6: Smaller, faster version

Simply change the model parameter in the pipeline:

summarizer = pipeline("summarization", model="google/pegasus-xsum")

Notes

  • The model requires significant memory (the large BART model is ~1.6GB)
  • For GPU acceleration, change device=-1 to device=0 in the pipeline
  • The first run will download the model, which may take some time
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support