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.
Try the application live at: https://text-summarizer-ai.onrender.com
- Overview
- Features
- Model Details
- Project Structure
- Installation
- Usage
- API Documentation
- Training Pipeline
- Evaluation Metrics
- Technologies Used
- Deployment
- Contributing
- License
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.
- 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
- π― 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: google/pegasus-cnn_dailymail
- Architecture: PEGASUS (Pre-training with Extracted Gap-sentences for Abstractive SUmmarization Sequence-to-sequence)
- Developer: Google Research
- 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
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
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
- Python 3.10+
- Git
- 4GB+ RAM (for model training)
- CUDA-compatible GPU (optional, for faster training)
-
Clone the repository
git clone https://github.com/yourusername/Text_Summarizer_AI.git cd Text_Summarizer_AI -
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Install the package
pip install -e .
-
Build the Docker image
docker build -t text-summarizer-ai . -
Run the container
docker run -p 8080:8080 text-summarizer-ai
-
Start the application
python app.py
-
Open your browser and navigate to
http://localhost:8080orhttp://127.0.0.1:8080/ -
Enter your text in the input area and click "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)import requests
url = "http://localhost:8080/train"
response = requests.get(url)
print(response.text)Run the complete training pipeline:
python main.pyFastAPI provides automatic API documentation:
- Swagger UI:
http://localhost:8080/docs - ReDoc:
http://localhost:8080/redoc
Generate text summary
- Request Body:
{"text": "string"} - Response:
{"prediction": "summary"}
Generate summary via query parameter
- Query Parameter:
text=your_text_here - Response:
{"prediction": "summary"}
Trigger model training
- Response: Training status message
The training pipeline consists of four main stages:
- Downloads the SAMSum dataset
- Extracts and organizes data files
- Validates data integrity
- Tokenizes dialogue and summary pairs
- Creates train/validation/test splits
- Prepares data for model training
- Loads pre-trained PEGASUS model
- Fine-tunes on dialogue summarization task
- Saves trained model and tokenizer
- Evaluates model performance
- Calculates ROUGE metrics
- Generates evaluation report
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: 16The 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
- π€ 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
- FastAPI: Modern, fast web framework
- Uvicorn: ASGI server
- Jinja2: Template engine
- Pydantic: Data validation
- Pandas: Data manipulation and analysis
- NumPy: Numerical computing
- PyYAML: YAML configuration files
- python-box: Advanced dictionary access
- Docker: Containerization
- Render: Cloud deployment platform
- Git: Version control
The application runs on http://localhost:8080 by default.
Deployed on Render cloud platform with automatic CI/CD:
- Live URL: https://text-summarizer-ai.onrender.com
- Container: Docker-based deployment
- Auto-scaling: Handles variable traffic loads
# Build
docker build -t text-summarizer .
# Run
docker run -p 8080:8080 text-summarizerContributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow PEP 8 style guidelines
- Add docstrings to all functions and classes
- Include unit tests for new features
- Update documentation as needed
This project is licensed under the MIT License - see the LICENSE file for details.
π Star this repo if you found it helpful!
