Skip to content

Fine-tuned BERT binary language classifier. Lightweight Docker env for inference with backend DB for storing/retraining

Notifications You must be signed in to change notification settings

CMaxK/mood_master

Repository files navigation

BERT for Sentiment Analysis

Features:

  • Fine-tuned BERT model weights exported in a lightweight Flask API within Docker container ready for inference.
  • Front-end app to accept text input from user. This input is sent to the model for classification.
  • Backend MYSQL DB (separate Docker container) to store correctly classified texts with option to further fine-tune the BERT model with new data.
  • Complete logging infrastructure to track inputs and performance of APP
  • Incorrect predictions are not stored in DB as it would negatively imapct model performance

Using airline review data, I compared the performance of a Naive Bayes Classifier with a fine-tuned BERT model. The task is ultimately a binary classification with reviews being either negative or not-negative. The aim is to accurately classify any input text into either 'negative' or 'not-negative' categories.

Checkout the notebooks for the model training and comparison process. It includes lots of comments to follow my thought process.


To run:

  1. Git clone this repo
  2. re-run bert-training.ipynb to obtain model weights and save in a model_weights directory.
  3. Create a .env file with MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, MYSQL_TABLE variables to store your specific DB credentials
  4. run docker-compose build && docker-compose up
  5. the app is hosted on port 5001 (enter http://localhost:5001 into your browser)

Homepage of App:

image

Correct Positive App prediction:

image

Returning Home once Feedback submitted:

image

Negative Prediction:

image image

Log outputs from within Docker container (docker exec -it {CONTAINER_ID} /bin/sh && cat app.log):

image

DB available for retraining BERT classifier:

image

About

Fine-tuned BERT binary language classifier. Lightweight Docker env for inference with backend DB for storing/retraining

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published