Giter Club home page Giter Club logo

curiousily / deploy-bert-for-sentiment-analysis-with-fastapi Goto Github PK

View Code? Open in Web Editor NEW
187.0 187.0 58.0 89 KB

Deploy BERT for Sentiment Analysis as REST API using FastAPI, Transformers by Hugging Face and PyTorch

Home Page: https://www.curiousily.com/posts/deploy-bert-for-sentiment-analysis-as-rest-api-using-pytorch-transformers-by-hugging-face-and-fastapi/

License: MIT License

Python 95.77% Shell 4.23%
bert deep-learning deploy-machine-learning deployment fastapi huggingface huggingface-transformer machine-learning python pytorch rest rest-api sentiment-analysis transformers uvicorn

deploy-bert-for-sentiment-analysis-with-fastapi's Introduction

Hi there ๐Ÿ‘‹

Hey, I am Venelin. Thanks for stopping by!

I am from an awesome little country called Bulgaria.

I work as a full-time Machine Learning engineer and write tutorials on basic and advanced topics (videos, posts, and code - lots of it).

You can:

Have an awesome day!

deploy-bert-for-sentiment-analysis-with-fastapi's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

deploy-bert-for-sentiment-analysis-with-fastapi's Issues

Pretrained model requires `assets` folder creation

bin/download_model
Downloading...
From: https://drive.google.com/uc?id=1V8itWtowCYnb2Bc9KlK9SxGff9WwmogA
To: /home/koerner/work/test/Deploy-BERT-for-Sentiment-Analysis-with-FastAPI/assets/model_state_dict.bin
Traceback (most recent call last):
  File "./bin/download_model", line 4, in <module>
    gdown.download(
  File "/home/koerner/work/test/Deploy-BERT-for-Sentiment-Analysis-with-FastAPI/venv/lib/python3.8/site-packages/gdown/download.py", line 153, in download
    f = open(tmp_file, "wb")
FileNotFoundError: [Errno 2] No such file or directory: 'assets/model_state_dict.bin09kxowvvtmp'

Solution, add this to the script, to just create the folder if it does not exist:

from pathlib import Path

Path("assets").mkdir(exist_ok=True)

RuntimeError: Error(s) in loading state_dict for SentimentClassifier: Missing key(s) in state_dict: "bert.embeddings.position_ids".

essentially i just git cloned the repository and ran "python3 bin/download_model".
then i just ran the "uvicorn sentiment_analyzer.api:app". I, however, installed all the dependencies individually as i was having issues to using the "pipenv install --dev" command as it was return errors

ksnip_20210211-204612
this is the entire error message.
ksnip_20210211-204850
this is whats in my assets
ksnip_20210211-204911
and this is the config.json that i did not change

How am i missing the keys from state_dict? is there a preferred enviorment where i deploy this tutorial api?

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.