Tbruand
commited on
Commit
·
aac811b
1
Parent(s):
21b5c94
feat(handler): intégration du modèle Few-Shot dans le handler
Browse files- app/handler.py +13 -7
app/handler.py
CHANGED
@@ -1,10 +1,16 @@
|
|
1 |
from models.zero_shot import ZeroShotModel
|
|
|
2 |
|
3 |
-
|
|
|
4 |
|
5 |
-
def predict(text: str) -> str:
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
1 |
from models.zero_shot import ZeroShotModel
|
2 |
+
from models.few_shot import FewShotModel
|
3 |
|
4 |
+
zero_shot_model = ZeroShotModel()
|
5 |
+
few_shot_model = FewShotModel()
|
6 |
|
7 |
+
def predict(text: str, model_type: str = "zero-shot") -> str:
|
8 |
+
if model_type == "few-shot":
|
9 |
+
label = few_shot_model.predict(text)
|
10 |
+
return f"### Résultat de la classification (Few-Shot) :\n\n- **{label}**"
|
11 |
+
else:
|
12 |
+
results = zero_shot_model.predict(text)
|
13 |
+
output = "### Résultat de la classification (Zero-Shot) :\n\n"
|
14 |
+
for label, score in results:
|
15 |
+
output += f"- **{label}** : {score*100:.1f}%\n"
|
16 |
+
return output
|