Update README.md
Browse files
README.md
CHANGED
@@ -1,27 +1,74 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
This model is intended for educational platforms, chat moderation tools, and student communication apps. Its purpose is to:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
-
|
27 |
-
|
|
|
|
|
|
1 |
+
# Student Chat Toxicity Classifier
|
2 |
+
|
3 |
+
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.
|
4 |
+
|
5 |
+
---
|
6 |
+
|
7 |
+
## Model Details
|
8 |
+
|
9 |
+
- **Language**: English (`en`)
|
10 |
+
- **Base Model**: `s-nlp/roberta_toxicity_classifier`
|
11 |
+
- **Task**: Text Classification (Binary)
|
12 |
+
- **Class 0**: Non-Toxic
|
13 |
+
- **Class 1**: Toxic
|
14 |
+
|
15 |
+
### Key Features
|
16 |
+
- Detects messages promoting cheating or malpractice.
|
17 |
+
- Flags harmful or unethical advice in student chats.
|
18 |
+
- Encourages ethical and constructive communication.
|
19 |
+
|
20 |
+
---
|
21 |
+
|
22 |
+
## Training Details
|
23 |
+
|
24 |
+
- **Dataset**: The model was fine-tuned on a custom dataset containing examples of student conversations labeled as toxic (malpractice suggestions, harmful advice) or non-toxic (positive and constructive communication).
|
25 |
+
- **Preprocessing**:
|
26 |
+
- Tokenization using `RobertaTokenizer`.
|
27 |
+
- Truncation and padding applied for consistent input length (`max_length=128`).
|
28 |
+
- **Framework**: Hugging Face's `transformers` library.
|
29 |
+
- **Optimizer**: `AdamW`
|
30 |
+
- **Loss Function**: `CrossEntropyLoss`
|
31 |
+
- **Epochs**: 3 (adjusted for convergence)
|
32 |
+
|
33 |
+
---
|
34 |
+
|
35 |
+
## Intended Use
|
36 |
+
|
37 |
This model is intended for educational platforms, chat moderation tools, and student communication apps. Its purpose is to:
|
38 |
+
1. Detect toxic messages, such as cheating suggestions, harmful advice, or unethical recommendations.
|
39 |
+
2. Promote a positive and respectful chat environment for students.
|
40 |
+
|
41 |
+
---
|
42 |
+
|
43 |
+
## Example Usage
|
44 |
+
|
45 |
+
```python
|
46 |
+
import torch
|
47 |
+
from transformers import RobertaTokenizer, RobertaForSequenceClassification
|
48 |
+
|
49 |
+
# Load the model and tokenizer
|
50 |
+
model_name = "path/to/your/model/directory"
|
51 |
+
tokenizer = RobertaTokenizer.from_pretrained(model_name)
|
52 |
+
model = RobertaForSequenceClassification.from_pretrained(model_name)
|
53 |
+
|
54 |
+
# Function for toxicity prediction
|
55 |
+
def predict_toxicity(text):
|
56 |
+
# Tokenize the input text
|
57 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=128)
|
58 |
+
|
59 |
+
# Run the text through the model
|
60 |
+
with torch.no_grad():
|
61 |
+
outputs = model(**inputs)
|
62 |
+
|
63 |
+
# Extract logits and apply softmax to get probabilities
|
64 |
+
logits = outputs.logits
|
65 |
+
probabilities = torch.nn.functional.softmax(logits, dim=-1)
|
66 |
+
|
67 |
+
# Get the predicted class (0 = Non-Toxic, 1 = Toxic)
|
68 |
+
predicted_class = torch.argmax(probabilities, dim=-1).item()
|
69 |
+
return "Non-Toxic" if predicted_class == 0 else "Toxic"
|
70 |
|
71 |
+
# Test the model
|
72 |
+
message = "You can copy answers during the exam."
|
73 |
+
prediction = predict_toxicity(message)
|
74 |
+
print(f"Message: {message}\nPrediction: {prediction}")
|