Skip to content

About

An intelligent text summarization application powered by Google's PEGASUS model and fine-tuned for dialogue summarization. This MLOps project demonstrates end-to-end machine learning pipeline implementation with modern deployment practices.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

15 Commits

Folders and files

Repository files navigation

πŸ€– AI Text Summarizer

An intelligent text summarization application powered by Google's PEGASUS model and fine-tuned for dialogue summarization. This MLOps project demonstrates end-to-end machine learning pipeline implementation with modern deployment practices.

Python FastAPI Transformers License

image

🌟 Live Demo

Try the application live at: https://text-summarizer-ai.onrender.com

⚠️ Note: The live demo is deployed on a free hosting platform and may experience errors or downtime. For the best experience and full functionality, we recommend running the application locally following the installation instructions below.

πŸ“‹ Table of Contents

🎯 Overview

This project implements a complete MLOps pipeline for text summarization using state-of-the-art transformer models. The application takes lengthy text inputs and generates concise, coherent summaries while maintaining the essential information and context.

Key Highlights:

  • Fine-tuned PEGASUS Model: Specialized for dialogue summarization
  • End-to-End MLOps Pipeline: From data ingestion to deployment
  • Modern Web Interface: Beautiful, responsive UI for easy interaction
  • RESTful API: FastAPI-based backend for integration
  • Docker Containerized: Ready for cloud deployment
  • Comprehensive Evaluation: ROUGE metrics for model performance

✨ Features

  • 🎯 Intelligent Summarization: Advanced NLP model for high-quality summaries
  • 🌐 Web Interface: User-friendly interface with real-time character counting
  • πŸš€ Fast API: High-performance backend with automatic documentation
  • πŸ“Š Model Evaluation: Comprehensive metrics using ROUGE scores
  • πŸ”„ Training Pipeline: Automated ML pipeline with configurable parameters
  • 🐳 Containerized: Docker support for easy deployment
  • πŸ“± Responsive Design: Works seamlessly across devices
  • πŸ”§ Modular Architecture: Clean, maintainable codebase

🧠 Model Details

Base Model

  • Model: google/pegasus-cnn_dailymail
  • Architecture: PEGASUS (Pre-training with Extracted Gap-sentences for Abstractive SUmmarization Sequence-to-sequence)
  • Developer: Google Research

Fine-tuning Details

  • Dataset: SAMSum Corpus (Samsung conversation dataset)
  • Task: Dialogue summarization
  • Training Epochs: 1 (optimized for efficiency)
  • Batch Size: 1 per device
  • Learning Rate: Adaptive with warmup
  • Evaluation Strategy: Step-based evaluation every 500 steps

Model Performance

The model is evaluated using ROUGE metrics:

  • ROUGE-1: Measures unigram overlap
  • ROUGE-2: Measures bigram overlap
  • ROUGE-L: Measures longest common subsequence
  • ROUGE-Lsum: Summary-level ROUGE-L

πŸ“ Project Structure

Text_Summarizer_AI/
β”œβ”€β”€ πŸ“Š artifacts/                      # Training artifacts and model outputs
β”‚   β”œβ”€β”€ data_ingestion/               # Raw and processed datasets
β”‚   β”œβ”€β”€ data_transformation/          # Tokenized datasets
β”‚   β”œβ”€β”€ model_trainer/               # Trained models and tokenizers
β”‚   └── model_evaluation/            # Evaluation metrics and results
β”œβ”€β”€ 🐳 app.py                         # FastAPI application entry point
β”œβ”€β”€ πŸ”§ config/
β”‚   └── config.yaml                  # Configuration parameters
β”œβ”€β”€ 🐳 Dockerfile                     # Container configuration
β”œβ”€β”€ πŸ“„ LICENSE                       # Project license
β”œβ”€β”€ πŸš€ main.py                       # Training pipeline orchestrator
β”œβ”€β”€ βš™οΈ params.yaml                    # Training hyperparameters
β”œβ”€β”€ πŸ“š requirements.txt              # Python dependencies
β”œβ”€β”€ πŸ”§ setup.py                      # Package installation script
β”œβ”€β”€ πŸ”„ template.py                   # Project structure generator
β”œβ”€β”€ πŸ“” research/                     # Jupyter notebooks for experimentation
β”‚   β”œβ”€β”€ 1_data_ingestion.ipynb      # Data loading and preprocessing
β”‚   β”œβ”€β”€ 2_data_transformation.ipynb  # Data tokenization experiments
β”‚   β”œβ”€β”€ 3_model_trainer.ipynb       # Model training experiments
β”‚   β”œβ”€β”€ 4_model_evaluation.ipynb    # Model evaluation experiments
β”‚   └── research.ipynb              # General research notebook
β”œβ”€β”€ πŸ“¦ src/textSummarizer/           # Main source code package
β”‚   β”œβ”€β”€ components/                  # Core ML components
β”‚   β”‚   β”œβ”€β”€ data_ingestion.py       # Data download and extraction
β”‚   β”‚   β”œβ”€β”€ data_transformation.py   # Data preprocessing and tokenization
β”‚   β”‚   β”œβ”€β”€ model_trainer.py        # Model fine-tuning logic
β”‚   β”‚   └── model_evaluation.py     # Model evaluation and metrics
β”‚   β”œβ”€β”€ config/                     # Configuration management
β”‚   β”‚   └── configuration.py        # Config loading and validation
β”‚   β”œβ”€β”€ entity/                     # Data classes and entities
β”‚   β”‚   └── __init__.py             # Configuration entities
β”‚   β”œβ”€β”€ pipeline/                   # ML pipelines
β”‚   β”‚   β”œβ”€β”€ stage_1_data_ingestion_pipeline.py
β”‚   β”‚   β”œβ”€β”€ stage_2_data_transformation_pipeline.py
β”‚   β”‚   β”œβ”€β”€ stage_3_model_trainer_pipeline.py
β”‚   β”‚   β”œβ”€β”€ stage_4_model_evaluation.py
β”‚   β”‚   └── prediction_pipeline.py   # Inference pipeline
β”‚   β”œβ”€β”€ logging.py                  # Logging configuration
β”‚   └── utils/                      # Utility functions
β”œβ”€β”€ 🎨 static/                       # Frontend assets
β”‚   β”œβ”€β”€ css/                        # Stylesheets
β”‚   └── js/                         # JavaScript files
└── πŸ–₯️ templates/                    # HTML templates
    └── index.html                  # Main web interface

πŸš€ Installation

Prerequisites

  • Python 3.10+
  • Git
  • 4GB+ RAM (for model training)
  • CUDA-compatible GPU (optional, for faster training)

Local Setup

  1. Clone the repository

    git clone https://github.com/yourusername/Text_Summarizer_AI.git
    cd Text_Summarizer_AI
  2. Create virtual environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Install the package

    pip install -e .

Docker Setup

  1. Build the Docker image

    docker build -t text-summarizer-ai .
  2. Run the container

    docker run -p 8080:8080 text-summarizer-ai

πŸ’» Usage

Web Interface

  1. Start the application

    python app.py
  2. Open your browser and navigate to http://localhost:8080 or http://127.0.0.1:8080/

  3. Enter your text in the input area and click "Generate Summary"

API Usage

Generate Summary

import requests

url = "http://localhost:8080/predict"
data = {"text": "Your long text here..."}

response = requests.post(url, json=data)
summary = response.json()["prediction"]
print(summary)

Training the Model

import requests

url = "http://localhost:8080/train"
response = requests.get(url)
print(response.text)

Command Line Training

Run the complete training pipeline:

python main.py

πŸ“– API Documentation

FastAPI provides automatic API documentation:

  • Swagger UI: http://localhost:8080/docs
  • ReDoc: http://localhost:8080/redoc

Endpoints

POST /predict

Generate text summary

  • Request Body: {"text": "string"}
  • Response: {"prediction": "summary"}

GET /predict

Generate summary via query parameter

  • Query Parameter: text=your_text_here
  • Response: {"prediction": "summary"}

GET /train

Trigger model training

  • Response: Training status message

πŸ”„ Training Pipeline

The training pipeline consists of four main stages:

Stage 1: Data Ingestion

  • Downloads the SAMSum dataset
  • Extracts and organizes data files
  • Validates data integrity

Stage 2: Data Transformation

  • Tokenizes dialogue and summary pairs
  • Creates train/validation/test splits
  • Prepares data for model training

Stage 3: Model Training

  • Loads pre-trained PEGASUS model
  • Fine-tunes on dialogue summarization task
  • Saves trained model and tokenizer

Stage 4: Model Evaluation

  • Evaluates model performance
  • Calculates ROUGE metrics
  • Generates evaluation report

Configuration

Training parameters can be modified in params.yaml:

TrainingArguments:
  num_train_epochs: 1
  warmup_steps: 500
  per_device_train_batch_size: 1
  weight_decay: 0.01
  logging_steps: 10
  evaluation_strategy: steps
  eval_steps: 500
  save_steps: 1e6
  gradient_accumulation_steps: 16

πŸ“Š Evaluation Metrics

The model is evaluated using standard summarization metrics:

  • ROUGE-1: Measures the overlap of unigrams (single words)
  • ROUGE-2: Measures the overlap of bigrams (two consecutive words)
  • ROUGE-L: Measures the longest common subsequence
  • ROUGE-Lsum: Summary-level ROUGE-L score

Results are saved in artifacts/model_evaluation/metrics.csv

πŸ› οΈ Technologies Used

Machine Learning & NLP

  • πŸ€— Transformers: State-of-the-art NLP models
  • PyTorch: Deep learning framework
  • Datasets: Efficient data loading and processing
  • Evaluate: Model evaluation metrics
  • NLTK: Natural language processing utilities

Web Framework & API

  • FastAPI: Modern, fast web framework
  • Uvicorn: ASGI server
  • Jinja2: Template engine
  • Pydantic: Data validation

Data Processing

  • Pandas: Data manipulation and analysis
  • NumPy: Numerical computing
  • PyYAML: YAML configuration files
  • python-box: Advanced dictionary access

DevOps & Deployment

  • Docker: Containerization
  • Render: Cloud deployment platform
  • Git: Version control

πŸš€ Deployment

Local Deployment

The application runs on http://localhost:8080 by default.

Cloud Deployment

Deployed on Render cloud platform with automatic CI/CD:

Docker Deployment

# Build
docker build -t text-summarizer .

# Run
docker run -p 8080:8080 text-summarizer

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Setup

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Coding Standards

  • Follow PEP 8 style guidelines
  • Add docstrings to all functions and classes
  • Include unit tests for new features
  • Update documentation as needed

πŸ“„ License

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


🌟 Star this repo if you found it helpful!

About

An intelligent text summarization application powered by Google's PEGASUS model and fine-tuned for dialogue summarization. This MLOps project demonstrates end-to-end machine learning pipeline implementation with modern deployment practices.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages