From 7de8833e3f7a295c4169384d01f4053d0378999a Mon Sep 17 00:00:00 2001 From: Moritz Laurer Date: Tue, 8 Feb 2022 21:40:12 +0000 Subject: [PATCH] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 6750273..ed5deb3 100644 --- a/README.md +++ b/README.md @@ -42,16 +42,21 @@ As of December 2021, mDeBERTa-base is the best performing multilingual transform ```python from transformers import AutoTokenizer, AutoModelForSequenceClassification import torch + model_name = "MoritzLaurer/mDeBERTa-v3-base-mnli-xnli" tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForSequenceClassification.from_pretrained(model_name) + premise = "Angela Merkel ist eine Politikerin in Deutschland und Vorsitzende der CDU" hypothesis = "Emmanuel Macron is the President of France" + input = tokenizer(premise, hypothesis, truncation=True, return_tensors="pt") output = model(input["input_ids"].to(device)) # device = "cuda:0" or "cpu" prediction = torch.softmax(output["logits"][0], -1).tolist() + label_names = ["entailment", "neutral", "contradiction"] prediction = {name: round(float(pred) * 100, 1) for pred, name in zip(prediction, label_names)} + print(prediction) ```