Chapter 1.2: Few-Shot prompting
What is few-shot prompting?
Few-shot prompting is used for more complex tasks, where one-shot prompting wouldn't give the expected results. Few-shot prompting requires slightly more preparation than one-shot prompting. It is a technique where a demonstration of what you expect from the model is included in the prompt. You are essentially training the model for a specific task in a specific context, where you provide the training data. This type of prompting is especially suitable for classification and labelling tasks.
Best practices
- Task Clearly state what you want the model to do
- Context Provide the relevant context necessary to carry out the task
- Demonstration Give at least one example of what you want the model's reply to look like
- Example formatting Format your examples consistently
Example: Labelling publications
At the Netherlands Institute of Ecology (NIOO), all publications are labelled with one or more of our research themes.
The themes are Biodiversity, Climate Change and Sustainable Use of Land and Water.
In rare cases, we opt for 'No theme'.
The publications below have already been labelled with the appropriate themes:
- https://doi.org/10.18194/ws.00345, Biodiversity
- https://doi.org/10.1111/geb.13901, Climate Change
- https://doi.org/10.1007/s13593-024-00991-3, Sustainable Use of Land and Water
- https://doi.org/10.1002/2688-8319.12303, Biodiversity & Climate Change
- https://doi.org/10.1016/j.scitotenv.2024.173699, Biodiversity & Sustainable Use of Land and Water
- https://doi.org/10.1016/j.watres.2024.122193, Climate Change & Sustainable Use of Land and Water
- https://doi.org/10.3390/microorganisms12040760, Biodiversity & Climate Change & Sustainable Use of Land and Water.
- https://doi.org/10.1186/s40462-024-00489-3, No theme
Assign one or more of NIOO's research theme(s) to this publication: https://doi.org/10.1111/brv.13164.
Sources
Based on materials from Prompt Engineering Guide and Software Guide.
⬅ Back Zero shot prompting | ➡ Next: Role based prompting