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.
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)
- π§ 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
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]
-
π₯ Input Processing
- Detect input type (chat conversation vs. article)
- Clean and preprocess text
- Handle file uploads (.txt, .md)
-
π§ 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
-
π Output Generation
- Calculate compression ratio
- Compute summary statistics
- Format response with metadata
- Return JSON response or web interface
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]
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
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 serveOption 2: Docker
git clone https://github.com/ananthakr1shnan/SummarizeIt.git
cd SummarizeIt
docker-compose up --buildπ Access the app at: http://localhost:8000
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)
- Open
http://localhost:8000 - Paste text or upload a file
- Select summary length and content type
- Click "Generate Summary"
- Copy and share your summary
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"])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| 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% |
Full training with 4 epochs and a high-performance GPU would significantly improve results.
- Processing Speed: ~2-3 seconds per summary
- Memory Usage: ~2GB GPU / ~4GB CPU
- Batch Processing: ~1 second per text in batch
| 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 |
{
"text": "Your text here...",
"summary_length": "medium", // "short", "medium", "long"
"input_type": "auto" // "auto", "chat", "paragraph"
}{
"summary": "Generated summary text...",
"original_length": 450,
"summary_length": 89,
"compression_ratio": 0.2,
"summary_type": "medium",
"input_type": "paragraph"
}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-5The training process includes:
- Download SAMSum dataset
- Preprocessing and tokenization
- Model training
- ROUGE evaluation
- Model saving
- Live App: Deployed on Hugging Face Spaces
- Model Hub: Fine-tuned model available at Hugging Face Hub
- Zero Setup: No installation required, just click and use!
This project draws inspiration from:
Fine-tuning the Large Language Pegasus Model for Dialogue Summarization
This project is licensed under the MIT License - see the LICENSE file for details.
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.