This commit is contained in:
nreimers 2021-06-21 11:41:16 +02:00
parent 23111f3256
commit ced69de5b6
1 changed files with 14 additions and 1 deletions

View File

@ -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)
```
```
## 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)
```