Esc

Few-shot prompting

Put two or three worked examples of the task in the prompt, on top of the description.

Few-shot prompting works because completing a pattern is what these models do best. Describing an output format in words leaves room to interpret it. Two examples leave none.

It pays off most when the format is unusual, the labels are yours and not standard ones, or the edge cases matter. Keep the examples short and make one of them a hard case. Keep them consistent too, because a single slip in your examples gets copied faithfully.

The price is context. Once the examples run past a few hundred tokens and the task has stopped changing, fine-tuning starts to look cheaper.

Where this comes up

Prompts, configs and tutorials in the library that touch this term.