Skip to content

SentiStock/SentiTweetSentimentAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SentiTweetSentimentAPI

How to use

Create Virtual Environment

python -m venv .venv
source .venv/bin/activate

Create Azure Function

func init SentiTweetSentimentAPILocalProject --python
func new --name SentiTweetSentimentAPI --template "HTTP trigger" --authlevel "function"

It will automatically provide some useful bolierplate.

Login to Azure

az login --use-device-code

If you don't have az installed run

curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

Publish the app

Either with: Remote build:

func azure functionapp publish SentiTweetSentimentAPI --build remote

Local build:

pip install  --target="./.python_packages/lib/site-packages"  -r requirements.txt
func azure functionapp publish SentiTweetSentimentAPI --no-build

Recommendations

We recommend installing the Azure Extension (with Functions) for the VSC.

It is also recommended to use the onnx runtime instead of the standard huggingface pytorch version. Read the documentation first.

The useful commands are either:

Just hidden state as last layer

python -m transformers.onnx --model=cardiffnlp/twitter-roberta-base-sentiment-latest onnx/ 

Normal task-specific logits

python -m transformers.onnx --model=cardiffnlp/twitter-roberta-base-sentiment-latest --feature=sequence-classification onnx/

We used the following (cause we had already downloaded model):

python3 -m transformers.onnx --model=twitter-roberta-base-sentiment.bin onnx

Helpful resources:

ML inference on Azure- dev.to

Serverless deployment of PyTorch on Azure- medium.com

- Youtube

Credits to the model used.

About

Azure Function that calculates sentiment for tweets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages