File size: 820 Bytes
39dcbb5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
from models.base import BaseModel
class FewShotModel(BaseModel):
def __init__(self):
self.examples = [
("Tu es un abruti", "toxique"),
("Je vais te tuer", "toxique"),
("Merci pour ton aide", "non-toxique"),
("J'apprécie ton soutien", "non-toxique")
]
def predict(self, text: str) -> str:
text = text.lower()
# Score simple basé sur correspondance de mots-clés
toxic_score = sum(any(word in example.lower() for word in text.split()) for example, label in self.examples if label == "toxique")
non_toxic_score = sum(any(word in example.lower() for word in text.split()) for example, label in self.examples if label == "non-toxique")
return "toxique" if toxic_score >= non_toxic_score else "non-toxique" |