rachith commited on
Commit
4a0738f
1 Parent(s): f83d80f

ent, neut, and contra

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -9,16 +9,14 @@ tokenizer_bart = BartTokenizer.from_pretrained('facebook/bart-large-mnli')
9
  model_bart_sq = BartForSequenceClassification.from_pretrained('facebook/bart-large-mnli')
10
 
11
 
12
- # def predict(prompt):
13
- # completion = model(prompt)[0]["generated_text"]
14
- # return completion
15
-
16
  def zs(premise,hypothesis):
17
  input_ids = tokenizer_bart.encode(premise, hypothesis, return_tensors='pt')
18
  logits = model_bart_sq(input_ids)[0]
19
- entail_contradiction_logits = logits[:,[0,2]]
20
  probs = entail_contradiction_logits.softmax(dim=1)
21
- true_prob = probs[:,1].item() * 100
22
- return true_prob
 
 
23
 
24
  gr.Interface(fn=zs, inputs=["text", "text"], outputs="text").launch()
 
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')
14
  logits = model_bart_sq(input_ids)[0]
15
+ entail_contradiction_logits = logits[:,[0,1,2]]
16
  probs = entail_contradiction_logits.softmax(dim=1)
17
+ contra_prob = round(probs[:,0].item() * 100,2)
18
+ neut_prob = round(probs[:,1].item() * 100,2)
19
+ entail_prob = round(probs[:,2].item() * 100,2)
20
+ return contra_prob, neut_prob, entail_prob
21
 
22
  gr.Interface(fn=zs, inputs=["text", "text"], outputs="text").launch()