Giter VIP home page Giter VIP logo

moderaitor's Introduction

ModerAItor

An automatic moderator for public forums. Created for the https://databricks-hackathon-2023.devpost.com/ hackaton.

Introduction

ModerAItor is an AI powered moderator for public forums. Given a post's URL, it will parse all the comments and flag them according to whether or not they comply with some user established rules. Unlike existing bots, that use heuristic rules for moderation, ModerAItor uses Large Language Models (LLMs), which makes it able to intelligently flag comments given some rules.

Getting Started

To use moderaitor, you must have docker and docker compose installed in your system. To deploy the application, you have to set a set of secrets first:

  • docker/HUGGINGFACEHUB_API_TOKEN.secret: file containing HUGGINGFACEHUB_API_TOKEN
  • docker/praw_client_id.secret: file containing praw's praw_client_id
  • docker/praw_client_secret.secret: file containing praw's praw_client_secret

For the hackaton, a public bucket has been created to saved the moderated comments. If you want to use this repository after the hackaton, you have to create an AWS S3 Bucket to save the flagged comments.

You also need to set your AWS secret access key and access key id on a AWS.env file inside the docker folder that would look like this:

AWS_ACCESS_KEY_ID=<key-id>
AWS_SECRET_ACCESS_KEY=<access-id>

Finally, execute this command:

make run-app

Or this command if you have created a new S3 bucket:

COMMENTS_BUCKET="name-of-bucket" make run-app

After the app is running (you should see Uvicorn running on http://0.0.0.0:8000), you can send queries to it. For example:

curl -X POST -H "Content-Type: application/json" -d '{
  "url": "https://www.reddit.com/r/news/comments/148lkof/trump_surrenders_to_federal_custody_in_classified/",
  "rules": "It is not allowed to use offensive words.",
  "max_comments": 10
}' http://54.147.130.67/api/moderate_post/

You will can see on the logs the results of the moderation. In addition, all these labeled comments are saved on the S3 bucket mentioned previously.

Now we know that ModerAItor works. However, you may be interested in having a human in the loop to check whether the moderation process was good and potentially make ModerAItor more intelligent. To do this, you can use label-studio, a powerful app to annotate data.

Before using it, you have to install label_studio_sdk:

python -m pip install label-studio
python -m pip install label-studio-sdk

Set the following environment variables in the LABEL_STUDIO.env file:

  • LABEL_STUDIO_USERNAME
  • LABEL_STUDIO_PASSWORD
  • LABEL_STUDIO_USER_TOKEN

These variables contain the credentials for a new user, which will be used to set up the project in label studio.

Additionally, you will need an AWS S3 bucket for the human-annotated comments. For the hackaton, a public bucket is already available.

Finally, execute the following command:

make run-annotator

Or, alternatively, this one if you created your own S3 buckets:

COMMENTS_BUCKET="name-of-bucket" ANNOTATION_BUCKET="name-of-bucket" make run-app

Now, visit http://0.0.0.0:8080/, where you can create a new user and start annotating the AI moderated comments!

moderaitor's People

Contributors

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