hackerbyhobby commited on
Commit
30e53ac
·
unverified ·
1 Parent(s): f2177b1

more updates

Browse files
Files changed (1) hide show
  1. app.py +8 -4
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
- # Patch shap to use np.bool_ instead of np.bool
30
- shap.maskers._text.Text.mask_invariants = (
31
- lambda self, *args: np.zeros(len(self._tokenized_s), dtype=np.bool_)
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)