Views
No views yet
sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 under license: apache-2.0.1from moderation import * #From files this project
2
3# Load model
4moderation = ModerationModel()
5moderation.load_state_dict(torch.load('moderation_model.pth'))
6
7# Test text
8text = "I want to kill them."
9
10embeddings_for_prediction = getEmb(text)
11prediction = predict(moderation, embeddings_for_prediction)
12print(json.dumps(prediction,indent=4))1{
2 "category_scores": {
3 "harassment": 0.039179909974336624,
4 "harassment-threatening": 0.5689294338226318,
5 "hate": 0.0096114631742239,
6 "hate-threatening": 0.00895680021494627,
7 "self-harm": 0.0008832099265418947,
8 "self-harm-instructions": 2.1136918803676963e-05,
9 "self-harm-intent": 0.00033596932189539075,
10 "sexual": 5.425313793239184e-05,
11 "sexual-minors": 5.160131422599079e-06,
12 "violence": 0.9684166312217712,
13 "violence-graphic": 0.0015151903498917818
14 },
15 "detect": {
16 "harassment": false,
17 "harassment-threatening": true,
18 "hate": false,
19 "hate-threatening": false,
20 "self-harm": false,
21 "self-harm-instructions": false,
22 "self-harm-intent": false,
23 "sexual": false,
24 "sexual-minors": false,
25 "violence": true,
26 "violence-graphic": false
27 },
28 "detected": true
29}