Zero-shot, few-shot, in-context learning

Showing a model three examples of the output you want usually beats describing it in a paragraph.

Part of the Getting good answers track on lAItest.

Describing the format you want takes a paragraph. Showing it takes three lines and works better.

Why examples beat instructions.

Zero-shot is asking. Few-shot is showing.

Zero-shot: you state the task and the model answers with no examples. Few-shot: you paste two to five worked pairs first, each an input followed by the output you would have wanted, and only then the real input. The model continues the pattern. The name for what happens next is in-context learning.

A common misconception

Commonly believed: Giving a model examples teaches it. It will remember them next time.

Actually: Nothing is learned. No weight changes. The examples work only because they are sitting in the same input as your question, and they are gone the moment the request ends. On the next call you send them again, and pay for them again.

Try it

Add examples one at a time and watch the window fill. Every one of them is re-sent on every single call. This step is an interactive widget; open the lesson to use it.

Examples win where the target is hard to describe.

Classification with fuzzy edges, a house tone of voice, an unusual labelling scheme, an exact output shape. If you can state the rule in one clear sentence, state the rule. If you catch yourself writing "well, except when" for the third time, stop writing and paste examples of the exceptions instead.

In one sentence

Few-shot examples are not training. They are a pattern you rent for one request, and the rent is due again on the next one.