Zero-shot learning
Zero-shot learning is a setting in which a model performs a task or predicts categories without task-specific examples during training, adaptation, or inference, relying on learned knowledge and available task information.
Introduction to Generative AI, Second Edition
Zero-shot learning is performing a task without task-specific labeled examples or demonstrations.
- How it is used
- Uses zero-shot prompting to request a task through direct instructions without supplying demonstrations.
- How deep it goes
- Defines zero-shot by the number of supplied examples and contrasts it with few-shot prompting without detailing model internals.
- Examples
- Illustrates it with meat-free menu labeling, direct translation instructions, and DetectGPT’s detection of machine-generated text.
- What you can do after
- Practice/perform it by giving a direct instruction, then add examples if the response needs clearer guidance.
Read how Introduction to Generative AI, Second Edition explains zero-shot learning →
Starting Data Analytics with Generative AI and Python
A zero-shot learning model performs a task or makes predictions for categories without task-specific examples for those categories during inference.
- How it is used
- Classifies Portuguese reviews by sentiment when task-specific labeled training data is scarce or unavailable.
- How deep it goes
- Works through a classification pipeline, candidate labels, filtering, and evaluation; does not develop model internals.
- Examples
- Uses Portuguese customer reviews, an AI-generated Python workflow, and sensitivity and specificity results from 500 reviews.
- What you can do after
- Apply it via Hugging Face Transformers to filter positive reviews, then evaluate results against review scores before selecting a method.
Read how Starting Data Analytics with Generative AI and Python explains zero-shot learning →
Sutskever's List
A zero-shot setting evaluates a model on a task or query without providing task-specific examples in the input.
- How it is used
- Tests what a language model can do without task-specific training or examples, while exposing failures on unfamiliar query forms.
- How deep it goes
- Illustrates the setting through GPT-2 tasks and a GPT-4 reversal probe, without specifying metrics or a formal evaluation protocol.
- Examples
- Uses headline-to-article generation, reading comprehension, and opposite-direction questions about Tom Cruise’s mother.
- What you can do after
- Evaluate/understand zero-shot claims by separating an answer given without a prompt demonstration from one enabled by a supplied fact.
LLMs in Production
A learning or inference setting in which a model performs a task without being given task-specific examples.
- How it is used
- Deploys large language models for specialized tasks through simple prompts instead of task-specific fine-tuning.
- How deep it goes
- Defines zero-shot prompting and contrasts it with one-shot and few-shot prompting, but does not detail implementation procedures.
- Examples
- Uses specialized tasks performed through simple prompts and highlights unintended outputs from generative models.
- What you can do after
- Evaluate/understand when a language model can attempt a novel task without labeled examples or fine-tuning.
Knowledge Graphs and LLMs in Action
Zero-shot learning is performing a task without task-specific examples, relying on a task description and pretrained knowledge.
- How it is used
- Uses task descriptions to extract domain-specific knowledge from unstructured data without supplying task examples.
- How deep it goes
- Defines the technique and gives an iterative validation workflow, but stops short of implementation details or formal analysis.
- Examples
- Uses contextual interpretation of titles and organizations, plus mini-knowledge-graph inspection, as practical extraction examples.
- What you can do after
- Apply it via prompt engineering, inspect intermediate knowledge graphs, and recognize when fine-tuning is preferable.
Read how Knowledge Graphs and LLMs in Action explains zero-shot learning →
Generative AI in Action
Zero-shot learning is the ability to perform a task or recognize classes not directly represented in task-specific training examples by relying on broader learned associations or descriptions.
- How it is used
- Adapts language and vision models to new tasks through instructions, semantic associations, or text-image representations without task-specific examples.
- How deep it goes
- Explains generalization mechanisms, contrasts few-shot and transfer learning, and demonstrates an API call without mathematical derivation or model internals.
- Examples
- Uses English-to-German translation, Spanish translation through Azure OpenAI, and CLIP image labeling from natural-language class names.
- What you can do after
- Apply it via an instruction prompt or CLIP-style text-image comparison when suitable task examples or fine-tuning resources are unavailable.
Read how Generative AI in Action explains zero-shot learning →
Hugging Face in Action
Zero-shot classification is the assignment of labels to inputs without task-specific labeled examples during model adaptation or inference.
- How it is used
- Applies pretrained models to classify new text or images against user-supplied labels without task-specific labeled examples.
- 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 you can do after
- Apply zero-shot text or image classification through Hugging Face Transformers pipelines and inspect returned scores.
Read how Hugging Face in Action explains zero-shot learning →
Transformers in Action
Zero-shot learning is the ability to perform a task or recognize classes without task-specific examples during adaptation or inference.
- How it is used
- Deploys pretrained transformers on unseen tasks without task-specific retraining or examples.
- How deep it goes
- Defines generalization beyond training and contrasts few-shot learning, but stops short of implementation procedures or model internals.
- What you can do after
- Evaluate whether pretrained-model generalization can replace task-specific training while accounting for domain and deployment constraints.
Read how Transformers in Action explains zero-shot learning →
Build a Large Language Model (From Scratch)
A learning setup where a model handles a task without having seen any task-specific examples beforehand.
- How it is used
- Frames GPT text completion as a way to perform unseen tasks without task-specific examples or model changes.
- How deep it goes
- Defines generalization to unseen tasks and contrasts few-shot prompting, but does not explain internal mechanisms.
- Examples
- Uses translation, summarization, fiction writing, and computer-code generation as examples of GPT capabilities.
- What you can do after
- Evaluate how GPT-like models can perform tasks from instructions alone, without retraining or task-specific examples.
Read how Build a Large Language Model (From Scratch) explains zero-shot learning →
Reinforcement Learning from Human Feedback
Zero-shot evaluation measures a model on questions or tasks without providing task-specific examples in the prompt.
- How it is used
- Evaluates instruction-tuned models on unseen questions without task-specific demonstrations, approximating open-ended usage.
- How deep it goes
- Defines the evaluation setup and motivation, but stops short of detailing implementation beyond sampling and exact-match terminology.
- Examples
- Uses an unanswered capital-of-France prompt and contrasts generation sampling with temperature-zero multiple-choice evaluation.
- What you can do after
- Evaluate model generalization on unseen questions without supplying task-specific prompt examples.
Read how Reinforcement Learning from Human Feedback explains zero-shot learning →
Related concepts
- few-shot learningcontrasts with · Few-shot learning is the adaptation or performance of a model on a task using only a small number of task-specific examples.
- prompt engineeringused by · Prompt engineering is the deliberate design and refinement of instructions, context, examples, or other inputs to guide an AI model’s behavior or outputs.
- one-shot learningcontrasts with · One-shot learning is a machine-learning setting in which a model generalizes to recognize or perform a task from a single labeled or demonstrated example.
- pretraininguses · Pretraining is the initial training of a model on broad data to learn general patterns or capabilities before adaptation to specific tasks or domains.
- DetectGPTincludes · DetectGPT is a zero-shot method for detecting machine-generated text by analyzing changes in language-model likelihoods under perturbations.
- NLIuses · Natural language inference is the task of determining whether a hypothesis is entailed by, contradicts, or is neutral with respect to a premise.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.









