Downloads · 30 days
16
27% of all-time downloads
callhub/koala-ai-text-moderation
koala-ai-text-moderation is a text classification model from callhub. Use it when you need a label for a piece of text. The card lists the license as openrail.
This model is a text classification model based on Deberta-v3 that predicts whether a text contains text that could be considered offensive. It is split up in the following labels:
Downloads · 30 days
16
27% of all-time downloads
All-time downloads
59
Public
Repo size
1.1 GB
Likes
2
Public
Click a slice to open those files.
.bin557 MB · 99%
From the Hugging Face model README
This model is a text classification model based on Deberta-v3 that predicts whether a text contains text that could be considered offensive. It is split up in the following labels:
| Category | Label | Definition |
|---|---|---|
| sexual | S | Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness). |
| hate | H | Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. |
| violence | V | Content that promotes or glorifies violence or celebrates the suffering or humiliation of others. |
| harassment | HR | Content that may be used to torment or annoy individuals in real life, or make harassment more likely to occur. |
| self-harm | SH | Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders. |
| sexual/minors | S3 | Sexual content that includes an individual who is under 18 years old. |
| hate/threatening | H2 | Hateful content that also includes violence or serious harm towards the targeted group. |
| violence/graphic | V2 | Violent content that depicts death, violence, or serious physical injury in extreme graphic detail. |
| OK | OK | Not offensive |
It's important to remember that this model was only trained on English texts, and may not perform well on non-English inputs.
This is a model that deals with sensitive and potentially harmful language. Users should consider the ethical implications and potential risks of using or deploying this model in their applications or contexts. Some of the ethical issues that may arise are:
Users should carefully consider the purpose, context, and impact of using this model, and take appropriate measures to prevent or mitigate any potential harm. Users should also respect the privacy and consent of the data subjects, and adhere to the relevant laws and regulations in their jurisdictions.
This model is licensed under the CodeML OpenRAIL-M 0.1 license, which is a variant of the BigCode OpenRAIL-M license. This license allows you to freely access, use, modify, and distribute this model and its derivatives, for research, commercial or non-commercial purposes, as long as you comply with the following conditions:
By accessing or using this model, you agree to be bound by the terms of this license. If you do not agree with the terms of this license, you must not access or use this model.
You can use cURL to access this model:
$ curl -X POST -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{"inputs": "I love AutoTrain"}' https://api-inference.huggingface.co/models/KoalaAI/Text-Moderation
Or Python API:
from transformers import AutoModelForSequenceClassification, AutoTokenizer
# Load the model and tokenizer
model = AutoModelForSequenceClassification.from_pretrained("KoalaAI/Text-Moderation")
tokenizer = AutoTokenizer.from_pretrained("KoalaAI/Text-Moderation")
# Run the model on your input
inputs = tokenizer("I love AutoTrain", return_tensors="pt")
outputs = model(**inputs)
# Get the predicted logits
logits = outputs.logits
# Apply softmax to get probabilities (scores)
probabilities = logits.softmax(dim=-1).squeeze()
# Retrieve the labels
id2label = model.config.id2label
labels = [id2label[idx] for idx in range(len(probabilities))]
# Combine labels and probabilities, then sort
label_prob_pairs = list(zip(labels, probabilities))
label_prob_pairs.sort(key=lambda item: item[1], reverse=True)
# Print the sorted results
for label, probability in label_prob_pairs:
print(f"Label: {label} - Probability: {probability:.4f}")
The output of the above Python code will look like this:
Label: OK - Probability: 0.9840
Label: H - Probability: 0.0043
Label: SH - Probability: 0.0039
Label: V - Probability: 0.0019
Label: S - Probability: 0.0018
Label: HR - Probability: 0.0015
Label: V2 - Probability: 0.0011
Label: S3 - Probability: 0.0010
Label: H2 - Probability: 0.0006