Tbruand
commited on
Commit
·
7301ed6
1
Parent(s):
9d951ff
feat(models): modifie ZeroShotModel pour retourner le label et le score de confiance
Browse files- models/zero_shot.py +4 -2
models/zero_shot.py
CHANGED
@@ -5,7 +5,9 @@ class ZeroShotModel(BaseModel):
|
|
5 |
def __init__(self):
|
6 |
self.classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
|
7 |
|
8 |
-
def predict(self, text: str) -> str:
|
9 |
labels = ["toxique", "non-toxique"]
|
10 |
result = self.classifier(text, candidate_labels=labels)
|
11 |
-
|
|
|
|
|
|
5 |
def __init__(self):
|
6 |
self.classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
|
7 |
|
8 |
+
def predict(self, text: str) -> tuple[str, float]:
|
9 |
labels = ["toxique", "non-toxique"]
|
10 |
result = self.classifier(text, candidate_labels=labels)
|
11 |
+
label = result["labels"][0]
|
12 |
+
score = result["scores"][0]
|
13 |
+
return label, score
|