|
| 1 | +alias:: [[AI/Prompt Engineering/Technique/Few-Shot Prompting]], [[Few-Shot Prompting]] |
| 2 | + |
| 3 | +- # Few-Shot Prompting |
| 4 | + - ## Overview |
| 5 | + - Few-shot prompting is a technique in [[Prompt Engineering]] where you provide the [[AI/LLM]] with a small number of examples (typically 2-5) to demonstrate the desired input-output pattern before asking it to perform the same task on new inputs |
| 6 | + - This technique helps the model understand the task format, style, and expected behavior without requiring extensive fine-tuning |
| 7 | + - ## How It Works |
| 8 | + - ### Pattern Recognition |
| 9 | + - The model learns from the provided examples to identify patterns in input-output relationships |
| 10 | + - It uses these patterns to generate appropriate responses for new, similar inputs |
| 11 | + - ### Context Learning |
| 12 | + - Examples serve as context that guides the model's understanding of the task |
| 13 | + - The model infers the underlying rules and constraints from the examples |
| 14 | + - ## Best Practices |
| 15 | + - ### Example Selection |
| 16 | + - Choose diverse examples that represent the range of inputs you expect |
| 17 | + - Ensure examples are high-quality and demonstrate the desired output format |
| 18 | + - Include edge cases when relevant |
| 19 | + - ### Format Consistency |
| 20 | + - Maintain consistent formatting across all examples |
| 21 | + - Use clear separators between examples and the actual prompt |
| 22 | + - ### Example Order |
| 23 | + - Place examples in logical order (e.g., simple to complex) |
| 24 | + - Consider the order's impact on the model's learning |
| 25 | + - ## Resources |
| 26 | + - ### Tutorials and Examples |
| 27 | + - [Using Examples & Few-Shot Prompting](https://github.com/anthropics/prompt-eng-interactive-tutorial/blob/master/AmazonBedrock/anthropic/07_Using_Examples%20_Few-Shot_Prompting.ipynb) - Interactive tutorial from Anthropic's prompt engineering series |
| 28 | + - ## Related Techniques |
| 29 | + - [[Zero-Shot Prompting]] - Providing no examples, just instructions |
| 30 | + - [[One-Shot Prompting]] - Providing a single example |
| 31 | + - [[Chain-of-Thought Prompting]] - Breaking down complex reasoning |
| 32 | + - ## See Also |
| 33 | + - [[Prompt Engineering]] - Main page for prompt engineering techniques |
| 34 | + - [[Context Engineering]] - Broader concept of providing appropriate context to LLMs |
| 35 | + |
0 commit comments