From ced69de5b67d567e0e71f3c787f1485038c33726 Mon Sep 17 00:00:00 2001 From: nreimers Date: Mon, 21 Jun 2021 11:41:16 +0200 Subject: [PATCH] up --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7df34e5..72776c6 100755 --- a/README.md +++ b/README.md @@ -49,4 +49,17 @@ with torch.no_grad(): label_mapping = ['contradiction', 'entailment', 'neutral'] labels = [label_mapping[score_max] for score_max in scores.argmax(dim=1)] print(labels) -``` \ No newline at end of file +``` + +## Zero-Shot Classification +This model can also be used for zero-shot-classification: +``` +from transformers import pipeline + +classifier = pipeline("zero-shot-classification", model='cross-encoder/nli-roberta-base') + +sent = "Apple just announced the newest iPhone X" +candidate_labels = ["technology", "sports", "politics"] +res = classifier(sent, candidate_labels) +print(res) +``` \ No newline at end of file