liveBook · Manning

Few-shot learning

As explained in AI for Everyday IT

Few-shot prompting is a technique that supplies an AI model with a small number of examples in the prompt to guide its behavior on a task.

Few-shot learning guides an AI model by placing a small number of examples directly in the prompt. Multiple examples reveal both the expected pattern and acceptable variations, making the approach useful for subtle or judgment-heavy tasks. section 4.2.3

Use few-shot prompting when you need to:

  • Show several examples instead of relying on a single demonstration. section 4.2
  • Teach a temporary style or preference, even when that style is not part of the model’s original training. section 4.2.3
  • Define how results should be presented as models become better at handling basic instructions. section 4.2.5

Two poem styles

Provide examples for two invented forms: a “Halo” poem about nature using a 5-7-5 syllable structure, and a humorous “Lemon” poem using an AABBA rhyme scheme. Then ask the model to write both forms about a cat named Mittens that loves pizza and explain their differences. section 4.2.3

How AI for Everyday IT covers it

How deep it goes
Explains the technique through multiple examples and temporary pattern learning without developing model internals.
Examples
Uses invented Halo and Lemon poetry styles, syllable and rhyme constraints, and a cat-themed generation task.
What you can do after
Apply few-shot prompting to generate new content that follows demonstrated patterns and customized preferences.
How it connects
Connects few-shot prompting with zero-shot prompting, single-shot prompting, many-shot prompting, prompt engineering, and problem formulation.

Also explained in

Compare how 18 books explain few-shot learning →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI for Everyday IT. The section links point to the parts of the book it draws on.