Humanizing Artificial Intelligence

Few-Shot Prompting

Few-Shot Prompting involves providing the language model with a small number of examples demonstrating the desired input-output format and task.

This technique builds on one-shot prompting by offering multiple examples that help the model recognize patterns and better understand the task requirements. With more examples, the model can better grasp nuances and variations in the desired output.

Pros:

  • Offers more context and clarifies the desired output format and style
  • Leads to more accurate and relevant responses, especially for complex tasks
  • Helps the model understand patterns across different examples
  • Reduces the chance of the model fixating on specific characteristics of a single example

Cons:

  • Requires more effort to create effective examples
  • The model’s performance can still be sensitive to the quality and relevance of the provided examples
  • Takes up more of your prompt’s available space
  • Examples need to be carefully selected to cover relevant variations

Example:

Prompt:

Classify these movie reviews as positive or negative.

Review: 'This movie was fantastic!' -> Positive
Review: 'The plot was confusing and the acting was poor.' -> Negative
Review: 'I really enjoyed the special effects.'

Expected Output:

Positive

Few-shot prompting works best for:

  • Classification tasks
  • Pattern recognition
  • Tasks with subtle variations
  • When consistency across multiple outputs is important
  • When the task is complex enough that a single example isn’t sufficient

For tasks requiring complex reasoning or multi-step thinking, consider using chain-of-thought prompting to guide the model through a step-by-step process.