Code Monkey home page Code Monkey logo

sa-transformers's Introduction

Sentiment Analysis with Transformers

Python 3.7

Classification Results

~4000 comments

Model Type Model Name Accuracy
XLNet xlnet-base-cased 0.784
RoBERTa roberta-base 0.802
RoBERTa distilroberta-base 0.763
BERT bert-base-cased 0.780
BERT bert-base-uncased 0.680
BERT bert-large-cased 0.772
FLAIR LSTM 0.701
FLAIR GRU 0.706
ALBERT albert-base-v1 0.668
DistilBERT distilbert-base-cased 0.742

~6000 comments

Model Type Model Name Accuracy
XLNet xlnet-base-cased 0.822
RoBERTa roberta-base 0.844

Hence, a pre-trained RoBERTa (base) transformer language model was used to train this classifier. Final model accuracy was 84.4%.

Docker

  1. Build the image: docker build -t dso/sa-transformers:v1.0 ..
  2. Run the container: docker run -d -p 5128:80 --name sa-transformers-container dso/sa-transformers:v1.0.
  3. Export the image for distribution: docker image save -o sa-transformers-v1.0.tar dso/sa-transformers:v1.0.
    • For archiving, a gzip image is recommended: docker save dso/sa-transformers:v1.0 | gzip -c > sa-transformers-v1.0.tar.gz.
  4. To load an image from a gzip archive: docker load < sa-transformers-v1.0.tar.gz.

RESTful API

  • URL /sentiment

  • Method POST

  • URL Params None

  • Data Params

    • Format: application/json

    Example Input

    A JSON array list of input text to analyse:

    ["Text to analyse for sentiment #1", 
    "Text to analyse for sentiment #1"]
    
  • Success Response

    • Code: 200

    Example Results

    A JSON array list of sentiment outputs, order is that of the input array order. Negative: -1, Positive: 1, Neutral: 0.

    [0,
    -1]
    
  • Invalid JSON Input

    • Code: 400

    Example Results

    {
        "ERROR": "Please provide a valid JSON. "
    }
    

sa-transformers's People

Watchers

Eugene Siow avatar Desmond avatar  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.