How vikashishere/mlops-proj2---nlp-usecase works
1. This repository is an end-to-end NLP project for hate-speech classification, organized as a small production-style ML system rather than a single notebook. The core architecture separates offline training, online/offline prediction, artifact management, and deployment.
2. The main runtime entry points are app.py and the pipeline modules under hate/pipeline/. app.py is the top-level launch point referenced by the README, while train_pipeline.py and prediction_pipeline.py represent the two primary execution paths: model building and model inference.
3. The training flow is staged through the hate/components/ package:
- data_ingestion.py handles loading the dataset from local files or synced cloud storage.
- data_transforamation.py performs preprocessing/tokenization/vectorization steps for text data.
- model_trainer.py fits the NLP model.
- model_evaluation.py compares the trained model against a baseline or acceptance criterion.
- model_pusher.py publishes the approved artifacts to the target storage location.
4. The hate/entity/ package defines the contracts between stages:
- config_entity.py captures configuration for each pipeline step.
- artifact_entity.py captures outputs passed between steps.
This is the main boundary that keeps pipeline stages decoupled and makes the architecture diagram easier to reason about.
5. The hate/configuration/gcloud_syncer.py module is the cloud-integration boundary. The README explicitly mentions GCloud CLI and downloading a toolkit to pull data from GCP, so the repo expects dataset/artifact synchronization with Google Cloud storage as part of the data or model lifecycle.
6. The data flow is centered on the data/ and download/ directories, which both contain dataset.zip. That suggests a packaged dataset source for ingestion, with a local download/cache area separate from the source-controlled project code.
7. The model artifacts appear to include a saved tokenizer and serialized model assets. There is a tokenizer.pickle at the repo root and notebook outputs such as model.h5 and tokenizer.pickle, indicating the NLP pipeline depends on persisted preprocessing state as well as the trained model.
8. hate/ml/model.py is the model abstraction layer. This is likely where the trained model and tokenizer are loaded for inference, keeping prediction logic separate from the training pipeline and reducing coupling between serving and training code.
9. hate/exception/ and hate/logger/ are cross-cutting support layers. They provide centralized error handling and logging across components, which is important in a staged pipeline where failures can occur at ingestion, transformation, training, or cloud sync boundaries.
10. The repo includes CI/CD and containerization infrastructure: .circleci/config.yml, Dockerfile, .dockerignore, and circleci_setup_template.sh. The README also mentions EC2 and self-hosted runners, so deployment is likely container-based with CircleCI orchestrating builds and delivery to an EC2-hosted runtime.
11. requirements.txt, setup.py, and template.py indicate the project is packaged as a Python application, not just an ad hoc notebook. The notebook/ directory is clearly the experimentation zone, while hate/ is the production-oriented codepath.
12. For an architecture diagram, the main boundaries are:
- experimentation vs production code,
- training pipeline vs prediction pipeline,
- local filesystem vs GCP-synced artifacts,
- reusable pipeline contracts vs stage implementations,
- application runtime vs CI/CD/deployment infrastructure.
Main entry points: train_pipeline.py Train pipeline · prediction_pipeline.py Prediction pipeline · data_ingestion.py Ingestion · app.py App
Components 20
Runtime
Entry points and execution paths
- App · Top-level launch point for the application
app.py - Train pipeline · Orchestrates offline model building
hate/pipeline/train_pipeline.py - Prediction pipeline · Runs inference using saved artifacts
hate/pipeline/prediction_pipeline.py
ML Pipeline
Training stages and prediction path
- Ingestion · Loads dataset from local or synced storage
hate/components/data_ingestion.py - Transform · Preprocesses and vectorizes text data
hate/components/data_transforamation.py - Trainer · Fits the NLP model
hate/components/model_trainer.py - Evaluation · Checks trained model against acceptance criteria
hate/components/model_evaluation.py - Pusher · Publishes approved model artifacts
hate/components/model_pusher.py
Support
Shared contracts and cross-cutting helpers
- Config · Pipeline configuration contracts
hate/entity/config_entity.py - Artifacts · Typed outputs passed between stages
hate/entity/artifact_entity.py - GCloud sync · Synchronizes data and artifacts with cloud storage
hate/configuration/gcloud_syncer.py - Model API · Loads and serves trained model/tokenizer state
hate/ml/model.py - Logger · Shared logging utility across the pipeline
hate/logger - Exception · Centralized error handling for pipeline failures
hate/exception
Ops
Packaging, container, and CI/CD
- CircleCI · Build and delivery automation
.circleci/config.yml - Docker · Container build and runtime packaging
Dockerfile - Python app · Project packaging and dependency definition
setup.py - Notebook · Exploration and model prototyping workspace
notebook/expriement.ipynb - Dataset · Packaged source data used by ingestion
data/dataset.zip - Download cache · Local synced copy of dataset artifacts
download/dataset.zip
Connections 23
- App → Train pipeline: launches · Application starts the training flow
- App → Prediction pipeline: launches · Application starts the inference flow
- Train pipeline → Config: reads · Training pipeline builds step configuration
- Train pipeline → Artifacts: passes · Stages exchange typed artifacts
- Train pipeline → Ingestion: orchestrates · Begins with data ingestion
- Ingestion → GCloud sync: syncs · Pulls or pushes data via cloud storage
- Ingestion → Dataset: reads · Loads packaged dataset source
- Ingestion → Download cache: writes · Stores local synced copy
- Ingestion → Transform: outputs · Hands off ingested data for preprocessing
- Transform → Trainer: feeds · Prepared features go to model training
- Trainer → Evaluation: produces · Trained model is evaluated
- Evaluation → Pusher: approves · Accepted models are pushed onward
- Pusher → GCloud sync: syncs · Publishes approved artifacts to cloud storage
- Prediction pipeline → Model API: loads · Inference uses persisted model and tokenizer
- Prediction pipeline → Artifacts: consumes · Reads saved pipeline artifacts
- Model API → Prediction pipeline: serves · Provides prediction-time abstraction
- Logger → Train pipeline: supports · Shared logging for pipeline execution
- Exception → Train pipeline: supports · Shared failure handling for pipeline execution
- Logger → Prediction pipeline: supports · Shared logging for inference execution
- Exception → Prediction pipeline: supports · Shared failure handling for inference execution
- CircleCI → Docker: builds · CI drives containerized builds and delivery
- Docker → Python app: packages · Container image includes the Python application
- Notebook → Dataset: experiments with · Notebook uses raw and packaged data for prototyping