Update README.md
Browse files
README.md
CHANGED
@@ -7,3 +7,54 @@ license: mit
|
|
7 |
This is a simple multilingual model for text moderation using embeddings.
|
8 |
|
9 |
exaple usage:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
This is a simple multilingual model for text moderation using embeddings.
|
8 |
|
9 |
exaple usage:
|
10 |
+
|
11 |
+
```python
|
12 |
+
import moderation #From files this project
|
13 |
+
|
14 |
+
|
15 |
+
# Load model
|
16 |
+
|
17 |
+
moderation = ModerationModel()
|
18 |
+
moderation.load_state_dict(torch.load('moderation_model.pth'))
|
19 |
+
|
20 |
+
# Test text
|
21 |
+
|
22 |
+
text = "I want to kill them."
|
23 |
+
|
24 |
+
embeddings_for_prediction = getEmb(text)
|
25 |
+
prediction = predict(moderation, embeddings_for_prediction)
|
26 |
+
print(json.dumps(prediction,indent=4))
|
27 |
+
```
|
28 |
+
|
29 |
+
Output:
|
30 |
+
```json
|
31 |
+
{
|
32 |
+
"category_scores": {
|
33 |
+
"harassment": 0.039179909974336624,
|
34 |
+
"harassment-threatening": 0.5689294338226318,
|
35 |
+
"hate": 0.0096114631742239,
|
36 |
+
"hate-threatening": 0.00895680021494627,
|
37 |
+
"self-harm": 0.0008832099265418947,
|
38 |
+
"self-harm-instructions": 2.1136918803676963e-05,
|
39 |
+
"self-harm-intent": 0.00033596932189539075,
|
40 |
+
"sexual": 5.425313793239184e-05,
|
41 |
+
"sexual-minors": 5.160131422599079e-06,
|
42 |
+
"violence": 0.9684166312217712,
|
43 |
+
"violence-graphic": 0.0015151903498917818
|
44 |
+
},
|
45 |
+
"detect": {
|
46 |
+
"harassment": false,
|
47 |
+
"harassment-threatening": true,
|
48 |
+
"hate": false,
|
49 |
+
"hate-threatening": false,
|
50 |
+
"self-harm": false,
|
51 |
+
"self-harm-instructions": false,
|
52 |
+
"self-harm-intent": false,
|
53 |
+
"sexual": false,
|
54 |
+
"sexual-minors": false,
|
55 |
+
"violence": true,
|
56 |
+
"violence-graphic": false
|
57 |
+
},
|
58 |
+
"detected": true
|
59 |
+
}
|
60 |
+
```
|