GithubHelp home page GithubHelp logo

esceptico / toxic Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 1.0 3.21 MB

End-to-end toxic Russian comment classification

Home Page: https://share.streamlit.io/esceptico/toxic/app.py

License: MIT License

Python 100.00%
nlp captum pytorch hydra streamlit deep-learning text-classification convolutional-neural-networks visualization

toxic's Introduction

Toxic Comment Classification

Fullstack end-to-end toxic comment classification with result interpretation

You can visit the online demo on this page

Data

The dataset is available at kaggle and contains labelled comments from the popular Russian social network ok.ru

Train

python run_training.py

Inference

from src.toxic.inference import Toxic

model = Toxic.from_checkpoint('path_to_model_or_name')
model.infer('привет, придурок')

Result:

{
    'predicted': [
        {'class': 'insult', 'confidence': 0.99324},
        {'class': 'threat', 'confidence': 0.002},
        {'class': 'obscenity', 'confidence': 0.00225}
    ],
    'interpretation': {
        'spans': [(0, 7), (7, 16)],
        'weights': {
            'insult': [-0.34299, 0.93934],
            'threat': [-0.97362, 0.22819],
            'obscenity': [-0.99579, 0.09168]
        }
    }
}

Pretrained model

We provide pretrained model at release page

To download the model execute:

wget https://github.com/esceptico/toxic/releases/download/v0.1.0/model.pth.zip
unzip model.pth.zip

You can download and cache pretrained model by model name as well:

model = Toxic.from_checkpoint('cnn')

List of supported pretrained models:

  • cnn: Wide CNN encoder with Feed Forward classification head

Serving

Streamlit

streamlit run ui/app.py -- --model=models/model.pth

Example

Powered By

License

The code is released under MIT license.

The models are distributed under CC BY-NC-SA 4.0 according to the dataset license.

toxic's People

Contributors

esceptico avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

dronnikovigor

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.