hackerbyhobby
commited on
more updates
Browse files
app.py
CHANGED
@@ -26,10 +26,14 @@ model_name = "joeddav/xlm-roberta-large-xnli"
|
|
26 |
classifier = pipeline("zero-shot-classification", model=model_name)
|
27 |
CANDIDATE_LABELS = ["SMiShing", "Other Scam", "Legitimate"]
|
28 |
|
29 |
-
#
|
30 |
-
shap.maskers._text.Text
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
33 |
|
34 |
# SHAP explainer setup
|
35 |
explainer = shap.Explainer(classifier)
|
|
|
26 |
classifier = pipeline("zero-shot-classification", model=model_name)
|
27 |
CANDIDATE_LABELS = ["SMiShing", "Other Scam", "Legitimate"]
|
28 |
|
29 |
+
# 3. SHAP Patch for Text Masking
|
30 |
+
if hasattr(shap.maskers._text.Text, "invariants"):
|
31 |
+
original_invariants = shap.maskers._text.Text.invariants
|
32 |
+
|
33 |
+
def patched_invariants(self, *args):
|
34 |
+
return np.zeros(len(self._tokenized_s), dtype=np.bool_) # Use np.bool_ instead
|
35 |
+
|
36 |
+
shap.maskers._text.Text.invariants = patched_invariants
|
37 |
|
38 |
# SHAP explainer setup
|
39 |
explainer = shap.Explainer(classifier)
|