Skip to content

ananthakr1shnan/SummarizeIt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ SummarizeIt β€” AI-Powered Summarization App

A full-stack AI app that summarizes long conversations and articles using a fine-tuned Pegasus transformer. Includes chat vs. paragraph detection, summary length control, REST API, and clean responsive UI.

Live Demo Model Python License

Tech Stack: Python β€’ FastAPI β€’ Transformers β€’ PyTorch β€’ Bootstrap β€’ Docker

🎯 Try it Live β€’ πŸ€– Model β€’ πŸ› Report Bug

πŸ“– Inspired by recent research on fine-tuning Pegasus for dialogue summarization
(see this paper)


✨ Features

  • 🧠 Fine-tuned Pegasus Model - Trained on SAMSum for summarizing dialogue and paragraphs
  • πŸ€— Hugging Face Integration - Model deployed on Hugging Face Hub, app hosted on Spaces
  • 🎯 Smart Input Detection - Automatically detects chat vs. paragraph format
  • πŸ“ Multiple Summary Lengths - Short, medium, and long summary options
  • 🌐 Modern Web Interface - Clean, responsive design with real-time processing
  • πŸ“ File Upload Support - Handle .txt and .md files up to 10MB
  • πŸ”Œ RESTful API - Complete API with OpenAPI documentation
  • πŸ“Š ROUGE Evaluation - Comprehensive model performance metrics

πŸ”„ How It Works

πŸ“Š Complete Workflow

graph TD
    A[πŸ“š SAMSum Dataset] --> B[πŸ”§ Data Preprocessing]
    B --> C[🧠 Fine-tune Pegasus Model]
    C --> D[πŸ“ˆ Model Evaluation]
    D --> E[πŸ’Ύ Save Fine-tuned Model]
    E --> F[πŸ€— Upload to Hugging Face Hub]
    F --> G[πŸš€ Deploy FastAPI App]
    G --> H[🌐 Hugging Face Spaces]
    
    I[πŸ‘€ User Input] --> J{πŸ“ Input Type Detection}
    J -->|Chat| K[πŸ’¬ Chat Processing]
    J -->|Article| L[πŸ“„ Article Processing]
    K --> M[πŸ€– Pegasus Model]
    L --> M
    M --> N[πŸ“‹ Generate Summary]
    N --> O[πŸ“Š Calculate Metrics]
    O --> P[βœ… Return Results]
Loading

🎯 Processing Pipeline

  1. πŸ“₯ Input Processing

    • Detect input type (chat conversation vs. article)
    • Clean and preprocess text
    • Handle file uploads (.txt, .md)
  2. 🧠 AI Summarization

    • Load fine-tuned Pegasus model from Hugging Face Hub
    • Tokenize input text (max 1024 tokens)
    • Generate summary based on selected length
    • Apply post-processing filters
  3. πŸ“Š Output Generation

    • Calculate compression ratio
    • Compute summary statistics
    • Format response with metadata
    • Return JSON response or web interface

πŸ”§ Model Training Pipeline

graph LR
    A[πŸ“š SAMSum Dataset<br/>16k+ conversations] --> B[πŸ”§ Tokenization<br/>Max 1024 tokens]
    B --> C[🎯 Fine-tuning<br/>4 epochs]
    C --> D[πŸ“ˆ ROUGE Evaluation<br/>R-1, R-2, R-L]
    D --> E[πŸ’Ύ Model Export<br/>HuggingFace format]
Loading

Training Stats:

  • Dataset: 16,000+ chat conversations
  • Training Time: 2-4 hours (GPU) / 8-12 hours (CPU)
  • Model Size: ~2.3GB
  • Performance: 11.9% improvement in ROUGE-1 score

πŸš€ Quick Start

🎯 Try Online (No Installation Required)

Open in Hugging Face

πŸ’» Local Setup

Option 1: Manual Setup

git clone https://github.com/ananthakr1shnan/SummarizeIt.git
cd SummarizeIt
python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows
pip install -r requirements.txt
python main.py setup
python main.py serve

Option 2: Docker

git clone https://github.com/ananthakr1shnan/SummarizeIt.git
cd SummarizeIt
docker-compose up --build

🌐 Access the app at: http://localhost:8000


πŸ“‹ Requirements

Tech Stack:

  • Backend: Python 3.11+, FastAPI, Uvicorn
  • AI/ML: Transformers, PyTorch, Datasets
  • Frontend: Bootstrap, HTML/CSS/JavaScript
  • Deployment: Docker, Hugging Face Spaces
  • Model: Fine-tuned Pegasus (google/pegasus-cnn_dailymail)

System Requirements:

  • 8GB+ RAM (for model training)
  • CUDA GPU (optional, for faster training)
  • Docker (optional)

🎯 Usage

Web Interface

  1. Open http://localhost:8000
  2. Paste text or upload a file
  3. Select summary length and content type
  4. Click "Generate Summary"
  5. Copy and share your summary

API Usage

import requests

response = requests.post("http://localhost:8000/summarize", json={
    "text": "Your long text here...",
    "summary_length": "medium",
    "input_type": "auto"
})

result = response.json()
print(result["summary"])

CLI Commands

python main.py setup      # Setup environment
python main.py train      # Train model (2-4 hours)
python main.py serve      # Start web server
python main.py evaluate   # Evaluate model

🧠 Model Performance

ROUGE Scores (Fine-tuned vs Base)

Metric Base Model Fine-tuned Improvement
ROUGE-1 0.42 0.47 +11.9%
ROUGE-2 0.19 0.23 +21.1%
ROUGE-L 0.34 0.39 +14.7%

⚠️ Note: Due to hardware constraints, the model was trained for 1 epoch.
Full training with 4 epochs and a high-performance GPU would significantly improve results.

Performance Stats

  • Processing Speed: ~2-3 seconds per summary
  • Memory Usage: ~2GB GPU / ~4GB CPU
  • Batch Processing: ~1 second per text in batch

πŸ”Œ API Endpoints

Method Endpoint Description
POST /summarize Summarize single text
POST /summarize/batch Summarize multiple texts
POST /summarize/file Upload and summarize file
GET /health API health check
GET /docs Interactive API documentation

Request Format

{
  "text": "Your text here...",
  "summary_length": "medium",  // "short", "medium", "long"
  "input_type": "auto"         // "auto", "chat", "paragraph"
}

Response Format

{
  "summary": "Generated summary text...",
  "original_length": 450,
  "summary_length": 89,
  "compression_ratio": 0.2,
  "summary_type": "medium",
  "input_type": "paragraph"
}

πŸŽ“ Training

Train your own model with custom data:

# Quick training with default settings
python main.py train

# Custom configuration in config/settings.py
NUM_EPOCHS = 4 # Use 4 for full training. Set to 1 if you're working with limited hardware
BATCH_SIZE = 2
LEARNING_RATE = 5e-5

The training process includes:

  1. Download SAMSum dataset
  2. Preprocessing and tokenization
  3. Model training
  4. ROUGE evaluation
  5. Model saving

πŸš€ Deployment

πŸ€— Hugging Face Deployment


πŸ“š Reference

This project draws inspiration from:

Fine-tuning the Large Language Pegasus Model for Dialogue Summarization


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™‹β€β™‚οΈ About Me

Hi, I'm Ananthakrishnan K β€” a B.Tech CS student passionate about Machine Learning and AI.
This project is part of my journey to master NLP and build real-world AI tools.

πŸ“« Email β€’ LinkedIn β€’

About

Text summarization web app with fine-tuned Pegasus model. Transform articles & chats into concise summaries via web interface or API.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors