Downloads · 30 days
17
4% of all-time downloads
Sk1306/student_chat_toxicity_classifier_model
student_chat_toxicity_classifier_model is a text classification model from Sk1306. Use it when you need a label for a piece of text. It is set up for transformers.
This model is a fine-tuned version of the s-nlp/robertatoxicityclassifier and is designed to classify text-based messages in student conversations as toxic or non-toxic. It is specifically tailored to detect and flag…
Downloads · 30 days
17
4% of all-time downloads
All-time downloads
449
Public
Parameters
125M
499 MB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors499 MB · 100%
From the Hugging Face model README
This model is a fine-tuned version of the s-nlp/roberta_toxicity_classifier and is designed to classify text-based messages in student conversations as toxic or non-toxic. It is specifically tailored to detect and flag malpractice suggestions, unethical advice, or any toxic communication while encouraging ethical and positive interactions among students.
🚀 Try the model live in this Hugging Face Space 🚀
en)s-nlp/roberta_toxicity_classifierRobertaTokenizer.max_length=128).transformers library.AdamWCrossEntropyLossThis model is intended for educational platforms, chat moderation tools, and student communication apps. Its purpose is to:
from gradio_client import Client
client = Client("Sk1306/Student_Ethics_Chat_Classifier")
result = client.predict(
text="you can copy in exam to pass!!",
api_name="/predict"
)
print(result)
import torch
from transformers import RobertaTokenizer, RobertaForSequenceClassification
# Load the model and tokenizer
model_name = "Sk1306/student_chat_toxicity_classifier_model"
tokenizer = RobertaTokenizer.from_pretrained(model_name)
model = RobertaForSequenceClassification.from_pretrained(model_name)
# Function for toxicity prediction
def predict_toxicity(text):
# Tokenize the input text
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=128)
# Run the text through the model
with torch.no_grad():
outputs = model(**inputs)
# Extract logits and apply softmax to get probabilities
logits = outputs.logits
probabilities = torch.nn.functional.softmax(logits, dim=-1)
# Get the predicted class (0 = Non-Toxic, 1 = Toxic)
predicted_class = torch.argmax(probabilities, dim=-1).item()
return "Non-Toxic" if predicted_class == 0 else "Toxic"
# Test the model
message = "You can copy answers during the exam."
prediction = predict_toxicity(message)
print(f"Message: {message}\nPrediction: {prediction}")