kaushikbar commited on
Commit
bb5868c
1 Parent(s): 066316e

added explain

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -7,7 +7,7 @@ from transformers import pipeline
7
  from transformers_interpret import ZeroShotClassificationExplainer
8
  import string, nltk
9
 
10
- models = {'en': 'joeddav/xlm-roberta-large-xnli', #'Narsil/deberta-large-mnli-zero-cls', #'facebook/bart-large-mnli', #'microsoft/deberta-xlarge-mnli', # English
11
  #'de': 'Sahajtomar/German_Zeroshot', # German
12
  #'es': 'Recognai/zeroshot_selectra_medium', # Spanish
13
  #'it': 'joeddav/xlm-roberta-large-xnli', # Italian
@@ -171,6 +171,7 @@ def sequence_to_classify(sequence, labels):
171
 
172
  model_expl = ZeroShotClassificationExplainer(classifier.model, classifier.tokenizer)
173
  response_expl = model_expl(sequence, label_clean, hypothesis_template="This passage talks about {}.")
 
174
 
175
  if len(predicted_labels) == 1:
176
  response_expl = response_expl[model_expl.predicted_label]
 
7
  from transformers_interpret import ZeroShotClassificationExplainer
8
  import string, nltk
9
 
10
+ models = {'en': 'facebook/bart-large-mnli', #'Narsil/deberta-large-mnli-zero-cls', #'microsoft/deberta-xlarge-mnli', # English
11
  #'de': 'Sahajtomar/German_Zeroshot', # German
12
  #'es': 'Recognai/zeroshot_selectra_medium', # Spanish
13
  #'it': 'joeddav/xlm-roberta-large-xnli', # Italian
 
171
 
172
  model_expl = ZeroShotClassificationExplainer(classifier.model, classifier.tokenizer)
173
  response_expl = model_expl(sequence, label_clean, hypothesis_template="This passage talks about {}.")
174
+ print(model_expl.predicted_label)
175
 
176
  if len(predicted_labels) == 1:
177
  response_expl = response_expl[model_expl.predicted_label]