Views
No views yet
| Label | Description |
|---|---|
toxicity | Contenu toxique general |
insult | Insultes directes ou indirectes |
hate | Discours de haine (racisme, xenophobie) |
sexual | Contenu sexiste / a caractere sexuel |
threat | Menaces de violence |
identity_attack | Attaques basees sur l'identite (homophobie, transphobie, etc.) |
| Categorie | F1 Score |
|---|---|
| toxicity | 0.981 |
| insult | 0.974 |
| hate | 0.949 |
| sexual | 1.000 |
| threat | 0.966 |
| identity_attack | 0.945 |
| F1 Micro | 0.970 |
| F1 Macro | 0.969 |
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4model_name = "Loule/egide-toxicity-model"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForSequenceClassification.from_pretrained(model_name)
7model.eval()
8
9LABELS = ["toxicity", "insult", "hate", "sexual", "threat", "identity_attack"]
10
11def predict(text):
12 inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
13 with torch.no_grad():
14 logits = model(**inputs).logits
15 probs = torch.sigmoid(logits).squeeze().tolist()
16 return {label: round(prob, 4) for label, prob in zip(LABELS, probs)}
17
18# Exemples
19print(predict("Tu es un connard"))
20# -> toxicity: 0.98, insult: 0.95, ...
21
22print(predict("ntm fdp"))
23# -> toxicity: 0.97, insult: 0.93, ...
24
25print(predict("GG bien joue le stream !"))
26# -> toxicity: 0.01, insult: 0.01, ... (PAS toxique)
27
28print(predict("Ca tue ce jeu"))
29# -> toxicity: 0.03, insult: 0.02, ... (PAS flag comme toxique)1cd apps/ai-service
2pip install -r requirements.txt
3python main.py # Lance le service sur le port 80001curl -X POST http://localhost:8000/analyze \
2 -H "Content-Type: application/json" \
3 -d '{"text": "ntm sale race"}'Twitch Chat -> Node.js Bot (tmi.js) -> HTTP -> Python AI Service (FastAPI) -> Moderation1@misc{egide-toxicity-model,
2 author = {Loule},
3 title = {Egide Toxicity Model - Multilingual Toxicity Detection for Twitch Chat},
4 year = {2025},
5 publisher = {HuggingFace},
6 url = {https://huggingface.co/Loule/egide-toxicity-model}
7}