1.13.3
Few-Shot Prompting
What is it?
Few-shot prompting provides a small number of input-output examples before the actual query. The model learns the expected pattern from these examples and applies it to a new input.
Key points
Few-shot examples are included in the prompt. Example diversity improves coverage of expected inputs. Keep the format consistent across examples. Include balanced labels for classification tasks. Use examples relevant to the target query. The source notes that performance often improves from zero to around 4–8 examples before gains begin to plateau.
Few-Shot Named Entity Recognition
Example 1: Apple released the iPhone in Cupertino. Entities: Apple (ORG), iPhone (PRODUCT), Cupertino (LOC). Example 2: OpenAI partnered with Microsoft. Entities: OpenAI (ORG), Microsoft (ORG). New input: Tesla opened a factory in Berlin. The model follows the demonstrated extraction format.
Real-world application
Use few-shot prompting for custom classification, extraction, formatting and domain-specific tasks where a short instruction alone is not enough.
Key takeaway
A few relevant, consistent examples can teach the model the expected task pattern without fine-tuning.