Skip to content

aadarsh-af/sentiment-analysis-prod-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sentiment Analysis

This project utilizes Python FastAPI and transformers to return sentiment to the input sentence provided by a user. I have used docker to deploy this API. The docker container uses python-3.11-slim version of Python. The API will deploy distilbert/distilbert-base-uncased-finetuned-sst-2-english model from HuggingFace. This model is used to reduce latency in the application with great accuracy of results. This API is secured with

Ubuntu Installation Steps

Clone this repository

git clone https://github.com/aadarsh-af/sentiment-analysis-prod-api && cd sentiment-analysis-prod-api

Install docker and docker-compose

sudo apt install -y docker.io
sudo systemctl start docker
sudo systemctl enable docker
sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d'"' -f4)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/bin/docker-compose
clear
docker-compose --version

Configure AUTH_TOKEN in example.env

A client can access the API only if they provide correct AUTH_TOKEN

AUTH_TOKEN=your_auth_token

Then, change the filename to .env using command: mv example.env .env

Build the Sentiment Analysis API

Takes around 350 seconds to build.

sudo docker-compose --build

Start the API with Docker Container (in background with detached mode)

sudo docker-compose up -d

Access the API

curl http://0.0.0.0:8000/

Access Docker Container

sudo docker ps --filter name=sentiment-analysis-api

Stop the API Docker Container

sudo docker stop $(sudo docker ps -aq --filter name=sentiment-analysis-api)

About

I have built a sentiment analysis API that can be easily deployed with just one command!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published