- Installment and Local Service
- Model
- Manual Deployment On Google Kubernetes Engine
- Continuous Deployment On Google Kubernetes Engine with Jenkins
pip install -r requirements.txt
docker pull khoav1371999/classify_toxic_text:0.0.1
docker run -p 8081:30000 khoav1371999/classify_toxic_text:0.0.1
Run client.py to test local API.
python3 utils/client.py --save_dir toxic_classication.html --text_query your_text
Utilized pretrained DistilBERT and incorporated two linear layers for the task of toxic text classification.
I use Jigsaw Toxic Comment Classification Challenge dataset to train and evaluate model. You can find details of the contest here.
kaggle competitions download -c jigsaw-toxic-comment-classification-challenge -p classifier_model/data
unzip classifier_model/data/jigsaw-toxic-comment-classification-challenge.zip -d classifier_model/data- Total Parameters:
$68,728,321$ - Model Size:
$262$ MB - Optimizer: Adam
- Loss Function: Binary Cross Entropy
- Batch Size:
$64$ - Linear Layer 1 Learning Rate:
$5*10^{-4}$ - Linear Layer 2 Learning Rate:
$1*10^{-5}$
cd helm/nginx-ingress
kubectl create ns nginx-ingress
kubens nginx-ingress
helm upgrade --install nginx-ingress-controller .
cd helm/toxic_chart
kubectl create ns model-serving
kubens model-serving
helm upgrade --install classify-toxic-text .
Get the ingress IP address
kubectl get ingress -n model-serving
The service can be accessed via http://[INGRESS_IP_ADDRESS]/docs
This setup guide provides the steps to deploy Prometheus and Grafana for monitoring CPU and node metrics on Google Kubernetes Engine (GKE). Follow the steps in sequence to ensure correct deployment within the monitoring namespace using Helm charts.
kubectl create ns monitoring
Deploy Prometheus Operator CRDs
cd helm_charts/prometheus-operator-crds
kubens monitoring
helm upgrade --install prometheus-crds .
Deploy Prometheus
cd helm_charts/prometheus
kubens monitoring
helm upgrade --install prometheus .
Prometheus Service can be accessed via http://[Node_IP_ADDRESS]:30000
cd helm_charts/grafana
kubens monitoring
helm upgrade --install grafana .
Grafana Service can be accessed via http://[Node_IP_ADDRESS]:30001
Ensure you have the following prerequisites installed and set up:
- Ansible: Ansible must be installed on your local machine or a control machine that can access your Google Cloud resources.
- Google Cloud SDK: Install and configure the Google Cloud SDK (gcloud) for command-line access to your Google Cloud resources.
- Create a new project or select an existing project in the Google Cloud Console.
- Enable the Compute Engine API for your project.
- Create a service account with appropriate permissions (Compute Admin) and download the JSON key file.
- Insert the JSON key file into the
secretsdirectory.
cd ansible/playbook
ansible-playbook create_compute_instance.yaml
After your instance has been started as the folowing image, get the External IP (e.g., 34.102.7.69 as in the example) and replace it in the inventory file
Then, run the following commands:
cd ansible/playbook
ansible-playbook ansible-playbook -i ../inventory install_and_run_jenkins.yaml
- Jenkins UI can be accessed via
GCE_INSTANCE_EX_IP:8081
Password can be found:
docker logs jenkins
- Install the following plugins:
- Docker Pipeline
- Docker
- Kubernetes
- Google SDK
-
Add DockerHub credentials to Jenkins
- Create a new credential with the following information:
- Kind: Username with password
- Scope: Global
- Username: Your DockerHub username
- Password: DockerHub Access Token (Refer to DockerHub to create a new token
- ID: dockerhub
- Create a new credential with the following information:
- Add Google Cloud credentials to Jenkins via
Manage Jenkins/ Cloudwith the following information:- Kubernetes URL: YOUR GKE CLUSTER URL
- Kubernetes Namespace: model-serving
- Credentials: Kubernetes server certificate key
There are three stages in the Jenkins pipeline:
- Test: Run the test
- Build: Build the Docker image
- Deploy: Deploy the Docker image to GKE

The console output of the successful pipeline is shown below:

- Utilize BERT model for better performance & Explore/ Experiment fine-tuning embeddings layer
- Utilize more data for training (specifically for cases with syntax errors)
- Model Monitoring System over time











