Giter Club home page Giter Club logo

moderation-by-embeddings_-alpha-version-'s Introduction

moderation by embeddings

This is a simple multilingual model for text moderation using embeddings.

PS: Although this model itself is MIT, it uses sentence sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 under license: apache-2.0.

exaple usage:

from moderation import * #From files this project

# Load model
moderation = ModerationModel()
moderation.load_state_dict(torch.load('moderation_model.pth'))

# Test text
text = "I want to kill them."

embeddings_for_prediction = getEmb(text)
prediction = predict(moderation, embeddings_for_prediction)
print(json.dumps(prediction,indent=4))

Output:

{
    "category_scores": {
        "harassment": 0.039179909974336624,
        "harassment-threatening": 0.5689294338226318,
        "hate": 0.0096114631742239,
        "hate-threatening": 0.00895680021494627,
        "self-harm": 0.0008832099265418947,
        "self-harm-instructions": 2.1136918803676963e-05,
        "self-harm-intent": 0.00033596932189539075,
        "sexual": 5.425313793239184e-05,
        "sexual-minors": 5.160131422599079e-06,
        "violence": 0.9684166312217712,
        "violence-graphic": 0.0015151903498917818
    },
    "detect": {
        "harassment": false,
        "harassment-threatening": true,
        "hate": false,
        "hate-threatening": false,
        "self-harm": false,
        "self-harm-instructions": false,
        "self-harm-intent": false,
        "sexual": false,
        "sexual-minors": false,
        "violence": true,
        "violence-graphic": false
    },
    "detected": true
}

This model covert embedings to moderaton score The dataset helped with normalizing the model output, but the model does not include rows from the dataset

Contributing

Contributions are welcome! If you have suggestions for improving this project, feel free to open an issue or a pull request.

License

This project is licensed under the Apache License Version 2.0. For more information, see the LICENSE file in this repository.

Links

HuggingFace: ifmain/moderation_by_embeddings

moderation-by-embeddings_-alpha-version-'s People

Contributors

ifmain avatar

Watchers

 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.