liveBook · Manning

Few-shot learning

As explained in Effective Conversational AI

Few-shot prompting is the practice of providing a language model with a small number of example demonstrations in a prompt to guide its response.

A chatbot builder may ask a language model for short customer utterances and get full sentences instead. Few-shot prompting adds a few examples to the prompt so the model can see the desired kind of response, not just read instructions about it. The examples can also show the format to follow. section 7.2.2 section 4.1.4

The number of examples gives the technique its name: zero-shot uses none, one-shot uses one, and few-shot uses a few. When an instruction to generate login-related fragments failed, adding “Forgot password” as an example helped produce fragments. A good example can be more effective than another rewrite of the instruction. section 7.2.2

Listing 7.10 Using a creative prompt to generate examples with a Granite model
<|instruction|>  #1
Here are actual utterances submitted by customers to an  #2
automated help desk. Your task is to create new   #2
examples from people having problems with their   #2
password and login ability.  #2

<|example|>  #3
I can't log in

<|example|>
My login information isn't working

<|example|>
Forgot password

<|example|>
Help me get into my account

<|example|>  #4
Hi there, I can't seem to login to my account  #5

The prompt supplies several customer utterances about login trouble, then invites another example. It shows how demonstrations can carry the task without detailed formatting instructions. section 7.2.2

Examples can guide other conversational tasks, including summaries for a human-agent handoff. They do not guarantee accuracy: a summary can still speculate about why a user requested an agent. Check the result against the conversation, and make prompt sections clear when transcripts and examples might be confused. section 12.3.1

For intent-data work, compare an instructions-only prompt with one that includes examples. Review or refine generated utterances before using them, then measure whether they improve a chatbot’s accuracy. Trying the same prompt more than once with sampling can yield additional variations. section 7.2.4 section 7.4

How Effective Conversational AI covers it

How deep it goes
Defines shot counts and works through prompting examples, while emphasizing output review rather than model internals.
Examples
Shows login utterance demonstrations, a password-fragment cue, and an example summary for human-agent handoff.
What it assumes
Assumes a chatbot or prompting task is in view, but defines zero-shot, one-shot, and few-shot from the number of examples supplied.
What you can do after
Practice/perform example-led prompting, refine generated utterances, and measure whether augmented intent data improves chatbot accuracy.
How it connects
Connects prompt engineering with intent-data augmentation, sampling decoding, and conversational summarization.

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 Effective Conversational AI. The section links point to the parts of the book it draws on.