Spaces:
Sleeping
Sleeping
paragon-analytics
commited on
Commit
•
2888c51
1
Parent(s):
8fb9551
Update app.py
Browse files
app.py
CHANGED
@@ -22,9 +22,9 @@ model = AutoModelForSequenceClassification.from_pretrained("paragon-analytics/AD
|
|
22 |
pred = transformers.pipeline("text-classification", model=model,
|
23 |
tokenizer=tokenizer, return_all_scores=True)
|
24 |
|
|
|
25 |
|
26 |
def interpretation_function(text):
|
27 |
-
explainer = shap.Explainer(pred)
|
28 |
shap_values = explainer([text])
|
29 |
scores = list(zip(shap_values.data[0], shap_values.values[0, :, 1]))
|
30 |
return scores
|
@@ -46,7 +46,7 @@ def interpretation_function(text):
|
|
46 |
# return val
|
47 |
|
48 |
def adr_predict(x):
|
49 |
-
encoded_input = tokenizer(x, return_tensors='pt')
|
50 |
output = model(**encoded_input)
|
51 |
scores = output[0][0].detach().numpy()
|
52 |
scores = tf.nn.softmax(scores)
|
@@ -93,7 +93,6 @@ def adr_predict(x):
|
|
93 |
# , word_attributions ,scores
|
94 |
|
95 |
def main(text):
|
96 |
-
text = str(text).lower()
|
97 |
obj = adr_predict(text)
|
98 |
return obj[0],obj[1]
|
99 |
# ,obj[2]
|
|
|
22 |
pred = transformers.pipeline("text-classification", model=model,
|
23 |
tokenizer=tokenizer, return_all_scores=True)
|
24 |
|
25 |
+
explainer = shap.Explainer(pred)
|
26 |
|
27 |
def interpretation_function(text):
|
|
|
28 |
shap_values = explainer([text])
|
29 |
scores = list(zip(shap_values.data[0], shap_values.values[0, :, 1]))
|
30 |
return scores
|
|
|
46 |
# return val
|
47 |
|
48 |
def adr_predict(x):
|
49 |
+
encoded_input = tokenizer(str(x), return_tensors='pt')
|
50 |
output = model(**encoded_input)
|
51 |
scores = output[0][0].detach().numpy()
|
52 |
scores = tf.nn.softmax(scores)
|
|
|
93 |
# , word_attributions ,scores
|
94 |
|
95 |
def main(text):
|
|
|
96 |
obj = adr_predict(text)
|
97 |
return obj[0],obj[1]
|
98 |
# ,obj[2]
|