Skip to content

Sentiment analysis on Amazon reviews for the MLOps course

License

Notifications You must be signed in to change notification settings

MLOps-essi-upc/MLOps-SentiBites

Repository files navigation

MLOPS-SentiBites

Static Badge Static Badge

logo

The goal of this project is to deploy a sentiment analysis model by using the best practices in MLOPS. The base model is a Roberta which will be finetuned on an Amazon reviews dataset.

Cards

You can find the cards here :

Installation

  1. Cloning the repository
git clone https://github.com/MLOps-essi-upc/MLOps-SentiBites.git
  1. Install requirements
pip install -r requirements.txt
  1. Pull data from Dagshub
dvc pull -r origin
  1. Launch the tests
pytest tests/

Deployment with Docker

You have two possibilities :

Pull the latest container from our DockerHub repo (recommended):

  1. Pull the container
docker pull rudiio/sentibites:latest
  1. Run the container
docker run -p 5000:5000 -p 8000:8000 rudiio/sentibites:latest

Build a new docker image on your machine.

  1. Build the project with the instruction given in the previous section

  2. Create the docker image

docker build -t sentibites:x.x .
  1. Run the container
docker run -p 5000:5000 -p 8000:8000 sentibites:x.x

Usage

Usage without App

For training :

python3 src/models/train_model.py --model "roberta-base" --dataset data/processed --output_dir run1 --logging_dir logs --epochs 1 --learning_rate 0.001 --weight_decay 0.005

For inference :

python3 src/models/predict_model.py --model "models/SentiBites" --input "text"

For evaluation :

python3 src/models/evaluate_model.py

 Running the App

You can run the app on local with the following command :

python3 run_servers

that will run the backend on locahost:8000 and the frontend on localhost:5000.

Here is a preview of the our application :

logo

 DVC repro and stages

Data processing stage:

dvc stage add -n data-processing \
    -d src/data/make_dataset.py \
    -d data/raw/Reviews.csv \
    -o data/processed/train.csv \
    -o data/processed/test.csv \
    python3 src/data/make_dataset.py

Training stage:

dvc stage add -n training \
    -d src/data/train_model.py \
    -d data/processed/train.csv \
    -d data/processed/test.csv \
    -o models/SentiBites \
    -o metrics/emissions.csv \
    python3 python3 src/models/train_model.py --model "roberta-base" --dataset data/processed \
    --output_dir SentiBites1 --logging_dir logs --epochs 1 --learning_rate 0.001 --weight_decay 0.005

Evaluation stage:

dvc stage add -n evaluation \
    -d src/models/evaluate_model.py \
    -d data/processed/test.csv \
    -d models/SentiBites \
    -m metrics/evaluation_scores.csv \
    python3 src/models/evaluate.py --model models/SentiBites --dataset data/processed \

About

Sentiment analysis on Amazon reviews for the MLOps course

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published