liveBook · Manning

Zero-shot learning

As explained in Introduction to Generative AI, Second Edition

Zero-shot learning is performing a task without task-specific labeled examples or demonstrations.

Suppose a restaurant owner asks a language model to mark every meat-free dish on a pasted menu. The menu supplies items to work on, but no example of a correctly marked dish. This is a zero-shot task: the model must follow the instruction without a task demonstration in the prompt. section 2.14

In zero-shot prompting, a direct instruction draws on what the model learned during pretraining. “Zero-shot” describes the examples supplied for this request; it does not mean the model has never encountered related language or ideas. Few-shot prompting instead includes a small number of demonstrations to show the desired pattern or format. section 7.3 section 2.14

Table 7.2 Foundational prompting techniques

Technique

Description

Example use case

Example prompt

Zero-shot

Provide an instruction without examples

Language translation, Q&A

Translate the following sentence into Spanish: “Good morning, how are you?”

Few-shot

Include a small set of examples in the prompt

Summarization, classification, language translation, code generation

Translate: “Hello” → “Hola”; “Goodbye” → “Adiós”; Now translate: “How are you?”

Multi-turn

Carry information forward across multiple exchanges

Customer support, tutoring agents

User: My internet isn’t working.

Model: What device are you using?

User: MacBook Pro.

Model: Let’s run a few tests.

Compare a direct translation instruction with a translation prompt that supplies example pairs before asking for a new answer. section 7.3

A direct request may work well, but examples can help when the response does not follow the intended format. The term also appears outside prompting: DetectGPT was described as a zero-shot method for detecting AI-generated text because it did not require labeled examples. Its reported performance fell when the model used to assess text differed from the one that generated it. Zero-shot therefore describes what examples a method does without, not a guarantee of accuracy. section 2.14 section 6.9

How Introduction to Generative AI, Second Edition covers it

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 it assumes
Introduces prompts as model input and distinguishes supplied demonstrations from pretrained knowledge.
What you can do after
Practice/perform it by giving a direct instruction, then add examples if the response needs clearer guidance.
How it connects
Connects zero-shot learning to pretraining, few-shot prompting, prompt engineering, and machine-generated text detection.

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 Introduction to Generative AI, Second Edition. The section links point to the parts of the book it draws on.