rachith commited on
Commit
1a06981
1 Parent(s): f89b0a7

description and probabilities

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -8,6 +8,10 @@ from transformers import BartForSequenceClassification, BartTokenizer
8
  tokenizer_bart = BartTokenizer.from_pretrained('facebook/bart-large-mnli')
9
  model_bart_sq = BartForSequenceClassification.from_pretrained('facebook/bart-large-mnli')
10
 
 
 
 
 
11
 
12
  def zs(premise,hypothesis):
13
  input_ids = tokenizer_bart.encode(premise, hypothesis, return_tensors='pt')
@@ -15,9 +19,9 @@ def zs(premise,hypothesis):
15
  # entail_contradiction_logits = logits[:,[0,1,2]]
16
  entail_contradiction_logits = logits[:,[0,2]]
17
  probs = entail_contradiction_logits.softmax(dim=1)
18
- contra_prob = round(probs[:,0].item() * 100,2)
19
- # neut_prob = round(probs[:,1].item() * 100,2)
20
- entail_prob = round(probs[:,1].item() * 100,2)
21
  # return contra_prob, neut_prob, entail_prob
22
  return contra_prob, entail_prob
23
 
 
8
  tokenizer_bart = BartTokenizer.from_pretrained('facebook/bart-large-mnli')
9
  model_bart_sq = BartForSequenceClassification.from_pretrained('facebook/bart-large-mnli')
10
 
11
+ title="Stance Detection using Zero Shot"
12
+
13
+ description="Welcome to the side where the grass is greener. This is a simple tool which was created with an aim to stance towards a given entity in a sentence. However, this is not the only use case of it!"
14
+
15
 
16
  def zs(premise,hypothesis):
17
  input_ids = tokenizer_bart.encode(premise, hypothesis, return_tensors='pt')
 
19
  # entail_contradiction_logits = logits[:,[0,1,2]]
20
  entail_contradiction_logits = logits[:,[0,2]]
21
  probs = entail_contradiction_logits.softmax(dim=1)
22
+ contra_prob = round(probs[:,0].item(),4)
23
+ # neut_prob = round(probs[:,1].item(),4)
24
+ entail_prob = round(probs[:,1].item(),4)
25
  # return contra_prob, neut_prob, entail_prob
26
  return contra_prob, entail_prob
27