Spaces:
Build error
Build error
ent, neut, and contra
Browse files
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 |
-
|
22 |
-
|
|
|
|
|
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()
|