Skip to content

LLM-inspired BiLSTM pipeline for real-time, multi-label toxicity inference across adversarial discourse modalities.

License

Notifications You must be signed in to change notification settings

Tripp01/Comment-Toxicity-Detection-and-Classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Comment Toxicity Detection and Classification

License Python Version Keras Version TensorFlow Version

Overview

Welcome to the Comment Toxicity Detection and Classification repository. This project implements a BiLSTM (Bidirectional Long Short-Term Memory) pipeline inspired by large language models (LLMs) for real-time, multi-label toxicity inference. Our focus is on analyzing adversarial discourse across various modalities.

The goal of this repository is to provide an efficient tool for detecting and classifying toxic comments in online discussions. By utilizing deep learning techniques, we aim to enhance the understanding of user interactions and promote healthier communication in digital spaces.

Table of Contents

Introduction

Online platforms often host discussions that can turn toxic. Identifying these toxic comments is crucial for maintaining a healthy online environment. This repository offers a solution through a robust machine learning pipeline that processes text data and provides insights into the nature of comments.

Features

  • Real-Time Inference: Analyze comments as they are posted, ensuring timely detection of toxicity.
  • Multi-Label Classification: Classify comments into multiple toxicity categories simultaneously.
  • Contextual Understanding: Leverage BiLSTM to capture context and nuances in language.
  • User-Friendly Interface: Easy to integrate and use in various applications.
  • Open Source: Free to use and modify, fostering collaboration and improvement.

Technologies Used

This project incorporates a variety of technologies to achieve its goals:

  • Python: The primary programming language for development.
  • Keras: For building and training the deep learning model.
  • TensorFlow: As the backend for Keras, providing powerful computation capabilities.
  • Scikit-learn: For preprocessing and evaluation metrics.
  • Subword Tokenization: To handle rare words and improve the model's understanding of text.
  • Deep Learning Frameworks: BiLSTM for sequential data processing.

Installation

To get started with this project, follow these steps:

  1. Clone the repository:

    git clone https://github.com/Tripp01/Comment-Toxicity-Detection-and-Classification.git
  2. Navigate to the project directory:

    cd Comment-Toxicity-Detection-and-Classification
  3. Install the required packages:

    pip install -r requirements.txt

Usage

After installing the necessary packages, you can run the model. Here’s a simple example of how to use the toxicity detection pipeline:

from toxicity_model import ToxicityModel

# Initialize the model
model = ToxicityModel()

# Sample comment
comment = "I hate you!"

# Predict toxicity
toxicity_scores = model.predict(comment)
print(toxicity_scores)

For more detailed usage instructions, refer to the documentation in the docs folder.

Data

The model requires a dataset of comments labeled for toxicity. You can find various datasets online, such as the Jigsaw Toxic Comment Classification Challenge dataset. Ensure that your data is formatted correctly for the model to process.

Model Architecture

The core of this project is a BiLSTM model. Here’s a brief overview of its architecture:

  • Input Layer: Accepts tokenized text data.
  • Embedding Layer: Converts words into dense vectors.
  • BiLSTM Layer: Processes the sequence in both directions, capturing context.
  • Dense Layer: Applies activation functions to produce final classification scores.

This architecture allows the model to understand the context and nuances of comments effectively.

Evaluation Metrics

To evaluate the model's performance, we use several metrics:

  • Accuracy: The percentage of correctly predicted labels.
  • Precision: The ratio of true positive predictions to the total predicted positives.
  • Recall: The ratio of true positive predictions to the total actual positives.
  • F1 Score: The harmonic mean of precision and recall, providing a balance between the two.

Contributing

We welcome contributions from the community. If you want to improve the project, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and commit them.
  4. Push to your branch.
  5. Open a pull request.

Please ensure that your code follows the style guidelines and is well-documented.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For questions or feedback, please reach out to the project maintainer:

Releases

For the latest releases and updates, please visit our Releases page. Here, you can download the latest versions of the model and any updates to the code.

If you encounter issues or need specific versions, check the Releases section for more details.


Thank you for your interest in the Comment Toxicity Detection and Classification project. Together, we can help create a safer online environment.