liveBook · Manning

Zero-shot learning

As explained in Hugging Face in Action

Zero-shot classification is the assignment of labels to inputs without task-specific labeled examples during model adaptation or inference.

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.

How Hugging Face in Action covers it

How deep it goes
Explains the distinction from one-shot learning and demonstrates high-level pipeline calls, stopping short of model internals.
Examples
Demonstrates politics-oriented paragraph classification and airplane recognition using candidate labels.
What it assumes
Assumes Python and basic pipeline usage, while supplying installation and Hugging Face authentication steps.
What you can do after
Apply zero-shot text or image classification through Hugging Face Transformers pipelines and inspect returned scores.
How it connects
Connects zero-shot classification with Natural Language Inference, one-shot classification, Transformers pipelines, and image classification.

Also explained in

Compare how 10 books explain zero-shot learning →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Hugging Face in Action. The section links point to the parts of the book it draws on.