Claude With Amazon Bedrock
← All lessons
Lesson 24Claude With Amazon Bedrock

Providing examples

Summary audio

Spoken summary — press play to read along: the line being spoken stays near the top.

Study notes

Prompt Engineering: Example-Based Prompting

  • Core Concept: Providing examples within the prompt is a highly effective technique for guiding the model's output.
  • Terminology:
  • One-shot prompting: Providing a single example (Input → Ideal Output).
  • Multi-shot prompting: Providing multiple examples to improve consistency and handle complex scenarios.
  • Implementation Structure:
  • Clearly define the task by providing a sample input and the desired ideal output.
  • Use XML tags to wrap inputs and outputs (e. g. , <input>... </input>, <output>... </output>) to structure the prompt and clarify the model's role.
  • Key Use Cases:
  • Handling Corner Cases: Examples help the model recognize nuances, such as sarcasm, which might otherwise be misinterpreted.
  • Complex Output Formatting: When generating structured data (e. g. , complex JSON), providing a sample input/output pair ensures the model adheres to the exact required format.
  • Reinforcing Quality (Advanced): To further guide the model, include the reasoning or justification for why the output is ideal (e. g. , copying the grader's explanation from a prompt evaluation report).
  • Application: This technique is particularly valuable when performing prompt evaluations (prompt evals) to guide the model toward high-scoring responses.

Takeaways

  • Example-based prompting guides model output by providing input → ideal output pairs.
  • One-shot prompting uses a single example, while multi-shot prompting uses multiple examples for consistency.
  • Use XML tags to structure the prompt and clearly define the model's role by wrapping inputs and outputs.
  • This technique is essential for handling complex output formatting (e. g. , JSON) and recognizing nuances like sarcasm.
Flashcards 9 cards
Question
click to reveal · ←/→
Answer
click to flip back
Export to Anki (.tsv) ↓
Knowledge check 6 questions