Zero-shot classification assigns inputs to labels without labeled examples for those categories during training or model adaptation. It is useful when new categories, such as Home Appliances or Electronics, are not included among a pretrained model’s fixed labels. Text models commonly use Natural Language Inference (NLI), and the approach also applies to images, audio, video, and graphs. section 3.3.5 section 3.4
Classify text with candidate labels
from transformers import pipeline classifier = pipeline("zero-shot-classification", model="joeddav/xlm-roberta-large-xnli") labels = ["technology", "politics", "business", "romance"] prediction = classifier(text1, labels, multi_label=True) The returned scores rank how well the paragraph matches each candidate label. Passing multiple paragraphs returns predictions for each input.









