Views
No views yet
yasserrmd/nsfk-detection)suitable_for_kidsnot_suitable_for_kidsuncertain (confidence-based)Fine-tuned on 60K examples and evaluated on a 1000-sample test set with high accuracy and safety guarantees, this model is ideal for content moderation in educational platforms, video platforms, and chatbot systems.
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3import json
4
5model_name = "yasserrmd/nsfk-detection"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForSequenceClassification.from_pretrained(model_name)
8
9label_map = {"True": 0, "False": 1}
10
11id_to_label = {i: label for label, i in label_map.items()}
12
13threshold = 0.7 # Confidence threshold for classification
14
15def classify(text):
16 inputs = tokenizer(text, return_tensors="pt")
17 with torch.no_grad():
18 outputs = model(**inputs)
19 probs = torch.softmax(outputs.logits, dim=1)[0]
20 pred_id = torch.argmax(probs).item()
21 confidence = probs[pred_id].item()
22 return (id_to_label[pred_id] if confidence >= threshold else "uncertain", confidence)
23
24text = "The movie contained graphic violence."
25label, confidence = classify(text)
26print(f"Label: {label}, Confidence: {confidence:.2f}")0.7| Metric | Value |
|---|---|
| Accuracy (excluding uncertain) | 92.91% |
| Precision (NSFK) | 99.00% |
| Recall (NSFK) | 85.00% |
| F1 Score (NSFK) | 92.00% |
| Uncertain Predictions | 11.20% |
0.75 for children-only platforms)