Welcome to the Reputation Monitoring System, an end-to-end MLOps project designed to analyze social media sentiment using state-of-the-art AI models. This repository demonstrates a Level 4 MLOps Maturity pipeline, featuring automated testing, continuous integration, drift detection, automated retraining triggers, and cloud deployment.
The system is built using a microservices architecture orchestrated by Docker.
| Component | Technology | Description |
|---|---|---|
| Model | Hugging Face (RoBERTa) | twitter-roberta-base-sentiment-latest for SOTA sentiment analysis |
| Serving | FastAPI | High-performance REST API for real-time inference |
| Containerization | Docker | Ensures reproducibility across environments |
| CI/CD | GitHub Actions | Automates Build, Test, and Deploy workflows |
| Monitoring | Prometheus & Grafana | Real-time metrics collection (Latency, Throughput) |
| Drift Detection | Python Script | Checks model accuracy and triggers retraining if performance drops |
| Deployment | Hugging Face Spaces | Docker-based deployment for public access |
reputation-monitoring/
├── .github/
│ └── workflows/ # CI/CD Pipelines (Build, Test, Deploy, Retrain)
├── monitoring/ # Configuration for Prometheus & Grafana
├── src/ # Source Code
│ ├── main.py # FastAPI Application Entry Point
│ ├── model.py # AI Model Logic (RoBERTa Wrapper)
│ └── drift_detector.py # Script for performance monitoring
├── tests/ # Integration & Load Tests
├── Dockerfile # Blueprint for the application container
├── docker-compose.yml # Orchestration of API + Monitoring Stack
└── requirements.txt # Python Dependencies
Every time code is pushed to the main branch, the MLOps End-to-End Pipeline executes the following steps:
- Build & Setup: Builds the Docker containers and installs dependencies (fixing PyTorch CPU versions to save space)
- Start Services: Launches the full stack (API, Prometheus, Grafana) using Docker Compose
- Integration Testing: Runs
pytestto verify API health and inference logic - Load Testing: Simulates real traffic (
tests/load_test.py) to generate live metrics in Prometheus - Drift Detection: The
drift_detector.pyscript analyzes performance. If accuracy < 0.80, it triggers the Automated Retraining Workflow via GitHub API - Deployment (CD): If all tests pass, the application is automatically deployed to Hugging Face Spaces
You can run the entire system on your machine using Docker.
- Docker & Docker Compose installed
-
Clone the repository:
git clone https://github.com/YOUR_USERNAME/YOUR_REPO_NAME.git cd reputation-monitoring -
Start the Stack:
docker compose up --build
-
Access the Services:
- API (Swagger UI): http://localhost:8000/docs
- Grafana Dashboard: http://localhost:3000 (User:
admin, Pass:admin) - Prometheus: http://localhost:9090
While the project prompt mentioned FastText, the specific requirement linked to the cardiffnlp/twitter-roberta-base-sentiment-latest model. We chose RoBERTa (a Transformer model) because it significantly outperforms FastText on social media text by understanding context, sarcasm, and slang.
Instead of using heavy orchestrators like Airflow (which consume excessive resources for a single pipeline), we implemented an Event-Driven Architecture. The monitoring script uses the GitHub API to trigger a repository_dispatch event, launching a dedicated GitHub Action workflow for retraining. This "Serverless MLOps" approach saves resources and is cost-effective.
Project developed for the ProfessionAI MLOps Course.