Views
No views yet
| Accuracy | |
|---|---|
| dev | 89.44 |
| test | 91.22 |
| verified_test | 95.36 |
1
2import torch
3import numpy as np
4from transformers import AutoTokenizer, AutoModelForSequenceClassification
5
6device = "cuda"
7
8model_path = "zayn1111/deberta-v3-dnli"
9tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False, model_max_length=512)
10model = AutoModelForSequenceClassification.from_pretrained(model_path).to(device)
11
12premise = "i work with a lot of kids in the healthcare industry ."
13hypothesis = "i work in the healthcare industry ."
14
15input = tokenizer(premise, hypothesis, truncation=True, return_tensors="pt")
16
17output = model(input["input_ids"].to(device))
18prediction = torch.softmax(output["logits"][0], -1).tolist()
19label_names = ["entailment", "neutral", "contradiction"]
20prediction = {name: round(float(pred) * 100, 1) for pred, name in zip(prediction, label_names)}
21print(prediction)
22