Deploy-BERT-for-Sentiment-Analysis-with-FastAPI icon indicating copy to clipboard operation
Deploy-BERT-for-Sentiment-Analysis-with-FastAPI copied to clipboard

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

Open Tony363 opened this issue 4 years ago • 2 comments

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?

Tony363 avatar Feb 11 '21 13:02 Tony363

Hey, I ran into same error today. But I could solve it. This SentimentClassifier was trained by transformers version 2.8.0, but Now if you install transformers without not designating version, you will get transformers==4.3.3. So if you want to execute this project, you should try following command.

pip install transformers==2.8.0

if you use mac os, maybe you will also encounter building error. You will solve it wit following command.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env

after that, you will install transformers==2.8.0

softmurata avatar Mar 15 '21 08:03 softmurata

image

Ran into the same error. The pipenv install --dev had locking issues. But since it can function without locking the dependencies, I moved on to pipenv shell and so on.

Not able to resolve the error in the image with either- pip install transformers==2.8.0

or

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source $HOME/.cargo/env

SidtheKidx avatar Mar 28 '21 21:03 SidtheKidx