Subtitle:
Learning from demonstrations within the prompt
Core Idea:
Few-shot prompting presents the model with high-quality examples of input-output pairs before asking it to complete a new task, helping it understand the expected pattern and criteria for good answers.
Key Principles:
- Demonstration Learning:
- Showing the model what good performance looks like through examples
- Pattern Recognition:
- Enabling the model to recognize and apply patterns from examples to new inputs
- Example Selection Impact:
- Choice of examples significantly affects performance, from near-random to state-of-the-art
Why It Matters:
- Improved Performance:
- Often leads to better results than zero-shot for complex tasks
- Task Clarification:
- Disambiguates tasks through concrete examples
- Format Guidance:
- Shows exact output format expected without explicit instructions
How to Implement:
- Select Diverse Examples:
- Choose examples that represent different aspects of the task
- Order Strategically:
- Arrange examples to avoid biasing the model (avoid recency and majority label bias)
- Match Test Sample:
- Include examples semantically similar to the test case when possible
Example:
-
Scenario:
- Sentiment analysis with examples
-
Application:
Text: (lawrence bounces) all over the stage, dancing, running, sweating, mopping his face and generally displaying the wacky talent that brought him fame in the first place.Sentiment: positiveText: despite all evidence to the contrary, this clunker has somehow managed to pose as an actual feature movie, the kind that charges full admission and gets hyped on tv and purports to amuse small children and ostensible adults.Sentiment: negativeText: for the first time in years, de niro digs deep emotionally, perhaps because he's been stirred by the powerful work of his co-stars.Sentiment: positiveText: i'll bet the video game is a lot more fun than the film.Sentiment:
-
Result:
- Model produces more accurate sentiment classification having seen patterns in examples
Connections:
- Related Concepts:
- Zero-shot prompting, in-context learning, example selection techniques
- Broader Concepts:
- Meta-learning, transfer learning, one-shot/few-shot learning
References:
- Primary Source:
- Weng, Lilian. (Mar 2023). Prompt Engineering. Lil'Log.
- Additional Resources:
- Liu et al. "What Makes Good In-Context Examples for GPT-3?"
- Lu et al. "Fantastically Ordered Prompts and Where to Find Them"
Tags:
#few-shot #in-context-learning #examples #demonstrations #prompting
Connections:
Sources: