Views
No views yet
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3model_name = "MoritzLaurer/DeBERTa-v3-base-mnli"
4tokenizer = AutoTokenizer.from_pretrained(model_name)
5model = AutoModelForSequenceClassification.from_pretrained(model_name)
6premise = "I first thought that I liked the movie, but upon second thought it was actually disappointing."
7hypothesis = "The movie was good."
8input = tokenizer(premise, hypothesis, truncation=True, return_tensors="pt")
9output = model(input["input_ids"].to(device)) # device = "cuda:0" or "cpu"
10prediction = torch.softmax(output["logits"][0], -1).tolist()
11label_names = ["entailment", "neutral", "contradiction"]
12prediction = {name: round(float(pred) * 100, 1) for pred, name in zip(prediction, label_names)}
13print(prediction)training_args = TrainingArguments(
num_train_epochs=5, # total number of training epochs
learning_rate=2e-05,
per_device_train_batch_size=32, # batch size per device during training
per_device_eval_batch_size=32, # batch size for evaluation
warmup_ratio=0.1, # number of warmup steps for learning rate scheduler
weight_decay=0.06, # strength of weight decay
fp16=True # mixed precision training
)| 20_newsgroup | ag_news | amazon_reviews_multi | anli | boolq | cb | cola | copa | dbpedia | esnli | financial_phrasebank | imdb | isear | mnli | mrpc | multirc | poem_sentiment | qnli | qqp | rotten_tomatoes | rte | sst2 | sst_5bins | stsb | trec_coarse | trec_fine | tweet_ev_emoji | tweet_ev_emotion | tweet_ev_hate | tweet_ev_irony | tweet_ev_offensive | tweet_ev_sentiment | wic | wnli | wsc | yahoo_answers |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 86.0196 | 90.6333 | 66.96 | 60.0938 | 83.792 | 83.9286 | 86.5772 | 72 | 79.2 | 91.419 | 85.1 | 94.232 | 71.5124 | 89.4426 | 90.4412 | 63.7583 | 86.5385 | 93.8129 | 91.9144 | 89.8687 | 85.9206 | 95.4128 | 57.3756 | 91.377 | 97.4 | 91 | 47.302 | 83.6031 | 57.6431 | 77.1684 | 83.3721 | 70.2947 | 71.7868 | 67.6056 | 74.0385 | 71.7 |