Few-shot learning gives a language model a small number of task-specific examples before asking it to handle a new input. For sentiment classification, a prompt might show several tweets paired with their sentiment labels, then ask for the sentiment of another tweet. The examples, or “shots,” communicate the intended task without retraining the model. section 2.5 section 6.4.2
Build a useful few-shot prompt by choosing demonstrations deliberately:
- Show both an input and its desired output for each example. Keep the format consistent so the task pattern is clear. section 6.4.2 section 6.4.4
- Use relevant, varied examples that reflect the possible inputs and labels. Prefer correct labels, while recognizing that structure and label distribution also affect performance. section 6.4.4 section 6.8
- Test example order as well as content. A successful order for one model may not work as well for another. section 6.8
Teaching a new pattern
A prompt can pair a couple of invented words with their definitions, then ask the model to define a third. The paired examples establish the expected input–output pattern. Another use is to show Celsius-to-Fahrenheit conversions before asking for a new conversion. section 6.4.2 section 6.3
Few-shot learning is a form of in-context learning: the examples condition the response at inference time, but do not update model weights. Their effect is transient for that call. Compared with zero-shot prompting, examples can make the task criteria clearer and often improve performance; many-shot prompting supplies more examples. Repeatedly sending the same demonstrations adds cost, so consider saving or caching them where appropriate. Evaluate outputs rather than assuming that more examples, or one effective ordering, will always help. section 6.3 section 6.4.2 section 6.8

















