Sk1306 commited on
Commit
1b15921
·
verified ·
1 Parent(s): 45fd2d9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +72 -25
README.md CHANGED
@@ -1,27 +1,74 @@
1
- '''Student Chat Toxicity Classifier
2
- 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.
3
-
4
- Model Details
5
- Language: English (en)
6
- Base Model: s-nlp/roberta_toxicity_classifier
7
- Task: Text Classification (Binary)
8
- Class 0: Non-Toxic
9
- Class 1: Toxic
10
- Key Features:
11
- Detects messages promoting cheating or malpractice.
12
- Flags harmful or unethical advice in student chats.
13
- Encourages ethical and constructive communication.
14
- Training Details
15
- 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).
16
- Preprocessing:
17
- Tokenization using RobertaTokenizer.
18
- Truncation and padding applied for consistent input length (max_length=128).
19
- Framework: Hugging Face's transformers library.
20
- Optimizer: AdamW
21
- Loss Function: CrossEntropyLoss
22
- Epochs: 3 (adjusted for convergence)
23
- Intended Use
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  This model is intended for educational platforms, chat moderation tools, and student communication apps. Its purpose is to:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
- Detect toxic messages, such as cheating suggestions, harmful advice, or unethical recommendations.
27
- Promote a positive and respectful chat environment for students.
 
 
 
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}")