An end-to-end Text Summarization Application built using Hugging Face Transformers, FastAPI, and MLflow, and containerized using Docker for seamless deployment on AWS EC2.
This project leverages the T5-base model fine-tuned on a custom dataset to generate concise, human-like summaries for long pieces of text.
- 🔍 Model Training: Fine-tuned
t5-basetransformer model using the Hugging FaceTrainerAPI on the SAMSum dataset. - 📊 Experiment Tracking: Integrated MLflow to log parameters, metrics (ROUGE scores), and model artifacts.
- ⚡ FastAPI Web App: Built an interactive web interface for text summarization with dynamic, word-by-word output.
- 🐳 Dockerized Deployment: Fully containerized the application and deployed it on AWS EC2.
- 🔄 Model Checkpointing: Implemented multiple training checkpoints for resuming interrupted training sessions.
- 🧾 Evaluation Metrics:
- ROUGE-1:
0.0358 - ROUGE-2:
0.0000 - ROUGE-L:
0.0356 - ROUGE-Lsum:
0.0354
- ROUGE-1:
| Category | Tools/Frameworks |
|---|---|
| Language | Python |
| Model | Hugging Face t5-base |
| Libraries | Transformers, Datasets, Torch, MLflow |
| Web Framework | FastAPI, Jinja2 |
| Containerization | Docker |
| Deployment | AWS EC2 |
| Version Control | Git, GitHub |
| Experiment Tracking | MLflow |
| Evaluation | ROUGE Metrics |
text-summarizer/ │ ├── src/ │ ├── textSummarizer/ │ │ ├── pipeline/ │ │ │ ├── prediction_pipeline.py │ │ │ └── training_pipeline.py │ │ ├── components/ │ │ ├── entity/ │ │ └── utils/ │ └── main.py │ ├── templates/ │ └── index.html ├── static/ │ └── style.css │ ├── Dockerfile ├── app.py ├── requirements.txt └── README.md
git clone https://github.com/MAbdullah005/Text-Summrizer.git
cd Text-Summrizer
2️⃣ Create a Virtual Environment
bash
Copy code
python -m venv myenv
myenv\Scripts\activate # On Windows
source myenv/bin/activate # On Linux/Mac
3️⃣ Install Dependencies
bash
Copy code
pip install -r requirements.txt
4️⃣ Run FastAPI App
bash
Copy code
python app.py
Visit the app in your browser: 👉 http://localhost:8080
🐳 Run with Docker
Build Docker Image
bash
Copy code
docker build -t text-summarization:0.1 .
Run Docker Container
bash
Copy code
docker run -d -p 8080:8080 text-summarization:0.1
App will be available at:
👉 http://0.0.0.0:8080
📦 Docker Hub Image
You can also pull the pre-built image directly from Docker Hub:
🔗 https://hub.docker.com/repository/docker/abdullahali005/text-summarization/general
bash
Copy code
docker pull abdullahali005/text-summarization:latest
🧠 Model Summary
Model Used: t5-base
Framework: Hugging Face Transformers
Training Duration: ~2 hours on GPU
Evaluation: ROUGE metrics for text summarization
Fine-tuned On: SAMSum dataset (dialogue summarization)
📈 MLflow Tracking Example
All experiments were logged and tracked with MLflow, including:
Training and validation loss
ROUGE metrics
Model artifacts and parameters
Versioned checkpoints for resuming training
🌐 Deployment
Deployed the containerized FastAPI app on AWS EC2, allowing users to summarize large text inputs directly through the browser interface.
🧑💻 Author
Muhammad Abdullah Ali
💼 Machine Learning Engineer | MLOps Enthusiast
📍 AWS Certified | Hugging Face | Docker | FastAPI
🔗 GitHub
🔗 Docker Hub
⭐ Acknowledgments
Special thanks to the Hugging Face Transformers team for their incredible open-source tools and to MLflow for providing seamless experiment tracking.