Few-shot learning helps a language model infer a task from a small set of examples. Each example pairs an input with its desired output, giving the model a pattern to follow rather than relying only on a task description. section 1.3.1
Make the output easy to use
Suppose a model must detect cars in images. Instead of accepting a response such as “Yes, there is a car,” specify an output of “1” for a car and “0” otherwise. Consistent labels make later counting and processing easier. section 1.3.1
A practical few-shot prompt combines worked examples, instructions, and a new item. For sentiment classification, show a review with its reference label, then repeat the task for the review the model must classify. A Python helper can build this prompt by formatting each sample with its text and sentiment label, then appending the unlabeled review. section 9.5
[Sample Review]
Is the sentiment positive or negative?
Answer ("pos"/"neg"):[Sample Solution]
[Review to Classify]
Is the sentiment positive or negative?
Answer ("pos"/"neg"):
Use the prompt listing to see the compact structure: sample review, task instruction, sample answer, and a new review awaiting classification. section 9.5
A reliable few-shot setup typically follows these practices:
- Choose examples that represent correctly solved versions of the task. section 9.11
- Repeat the required output format so generated answers can be evaluated or processed consistently. section 1.3.1
- Experiment with prompt variants and evaluate them on samples, since prompt design can affect performance and cost. section 9.11 section 9.5

















