Code Monkey home page Code Monkey logo

bert-sentimental-analysis's Introduction

Bert for Sentimental Analysis

Introduction

This repository is meant to be a personal exercise on MLOPS for the NLP task. The exercise covers many crucial steps of MLOPS. Here are the key points from this project.

  1. Use a SOTA model from huggingface, here I used BERT.
  2. Train on a NLP datasets using the dataset library, here we used iMDB.
  3. Make configuration and reproducibility easier with hydra.
  4. Use a modern ML library, I used Pytorch Lightning.
  5. Make the model trainable on Apple Silicon with Torch 1.12.
  6. Finetune model with logging and tracking using wandb.
  7. Find best hyper parameters by performing a sweep using wandb sweep.
  8. Deploy model on a REST API with Flask to perform HTML POST request on a server.
  9. Make the model sharable using Docker to build an image.
  10. Benchmark the Flask API using wrk.

Installation

git clone bert-sentimental-analysis
pip install -r requirements.txt

Usage

The model can be trained on CPU, GPU or Apple Silicon by running the command python train.py. The pre-trained BERT model and iMDB dataset should be downloaded. The best hyperparameters are already set in the config folder.

Once the ckpt checkpoint is obtained, simply put the path in app.py and start the flask server:

FLASK_APP=app.py flask run

One can then perform HTML request to the REST API, an example is given in test_app.py.

Docker

To build a docker image, simply run:

docker build -f Dockerfile -t bert:train .  

bert-sentimental-analysis's People

Contributors

raphaelattias avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.