--- license: mit --- ### Usage In Transformers ```python from transformers import AutoTokenizer, AutoModelForSequenceClassification import torch from scipy.special import softmax, expit device = "cuda" if torch.cuda.is_available() else "cpu" model_name="ragarwal/deberta-v3-base-nli-mixer" tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForSequenceClassification.from_pretrained(model_name) sentence = "During its monthly call, the National Oceanic and Atmospheric Administration warned of \ increased temperatures and low precipitation" labels = ["Computer", "Climate Change", "Tablet", "Football", "Artificial Intelligence", "Global Warming"] features = tokenizer([[sentence, l] for l in labels], padding=True, truncation=True, return_tensors="pt") model.eval() with torch.no_grad(): scores = model(**features).logits print(expit(scores)) #Multi-Label Classification print(softmax(scores)) #Single-Label Classification ``` In [Sentence-Transformers](https://www.sbert.net/) ```python from sentence_transformers import CrossEncoder model_name="ragarwal/deberta-v3-base-nli-mixer" model = CrossEncoder(model_name, max_length=256) sentence = "During its monthly call, the National Oceanic and Atmospheric Administration warned of \ increased temperatures and low precipitation" labels = ["Computer", "Climate Change", "Tablet", "Football", "Artificial Intelligence", "Global Warming"] scores = model.predict([[sentence, l] for l in labels]) print(scores) #array([0.04118565, 0.2435827 , 0.03941465, 0.00203637, 0.00501176, 0.1423797], dtype=float32) ```