Giter Site home page Giter Site logo

sentiment-analysis's Introduction

Prerequisites

  • Conda
  • Python >=3.10.12
  • MacOS Apple Silicon Chip (M1/M2/M3) or Ubuntu 16.04+

Setup

Clone the repository to working directory.

git clone [email protected]:kndrxl/Sentiment-Analysis.git

cd Sentiment-Analysis

Download models --> here and extract the zip file to the root directory of the repo.

unzip models.zip -d models/

The final folder structure should be like this:

.
├── app
│   ├── __init__.py
│   ├── model
│   │   ├── eval.py
│   │   └── model.py
│   ├── src
│   │   ├── handler.py
│   │   └── main.py
│   └── utilities
│       ├── utils.py
│       └── validator.py
├── data
│   ├── AI Technical Task.docx
│   └── sentiment_test_cases.csv
├── models
│   └── cardiffnlp
│       ├── twitter-roberta-base-sentiment
│       │   ├── config.json
│       │   └── pytorch_model.bin
│       ├── twitter-roberta-base-sentiment-latest
│       │   ├── config.json
│       │   └── pytorch_model.bin
│       └── twitter-xlm-roberta-base-sentiment
│           ├── config.json
│           └── pytorch_model.bin
├── notebooks
│   ├── twitter-roberta-base-sentiment-latest.ipynb
│   ├── twitter-roberta-base-sentiment.ipynb
│   └── twitter-xlm-roberta-base-sentiment.ipynb
├── output
│   └── <DATETIME>
│       ├── output_sentiment_test.csv
│       ├── results.txt
│       └── sentiment_test_cases.csv
├── README.md
├── requirements.txt
├── run.sh
├── .gitignore
├── .env

Local Installation (MacOS)

  • Create a conda environment.

    conda create --name <ENV_NAME> python=3.10.12
  • Activate the environment.

    conda activate <ENV_NAME>
  • Install packages and dependencies.

    pip install -r requirements.txt --no-cache-dir

Initialization

Run via FastAPI:

Either run the shell script

./run.sh

or

uvicorn app.src.main:app --port 8080     

Once app is running, open the OpenAPI Swagger UI here --> http://127.0.0.1:8080/docs

Choose and initialize a model first via this endpoint: /model_initialize. So far, the best model is the default cardiffnlp/twitter-roberta-base-sentiment-latest.

The initialization is an asynchronous process so monitor the logs via terminal.

Testing

  • Once Model is ready, we can now test /infer (single inference) and /batch_eval (batch evaluation) endpoints.

  • For single inference, the required parameters are:

    • text: str - Input Tweet/Text
    • preprocess: bool - Option for preprocessing input.
  • For batch evaluation, the required parameters are:

    • file: UploadFile - CSV file to be uploaded via user-interface.
    • preprocess: bool - Option for preprocessing input texts.
  • The results of batch evaluation will be saved under the output folder.

sentiment-analysis's People

Watchers

kndrxl 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.