Claude On Google Cloud
← All lessons
Lesson 25Claude On Google Cloud

Providing examples

Summary audio

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

Study notes

Prompt Engineering: Few-Shot Prompting

  • Core Concept: Providing examples within the prompt to guide the AI's desired output.
  • Terminology:
  • One-shot Prompting: Providing a single example (input and ideal output).
  • Multi-shot Prompting: Providing multiple examples (input and ideal output).
  • Purpose and Applications:
  • Handling Ambiguity/Corner Cases: Training the model to recognize nuanced scenarios, such as sarcasm (e. g. , classifying a seemingly positive tweet as negative).
  • Output Formatting: Ensuring the model adheres to complex or specific output structures (e. g. , generating a specific JSON format).
  • Improving Quality: Guiding the model toward higher quality responses by demonstrating what an "ideal" output looks like.
  • Implementation Techniques:
  • Structuring the Prompt: Use clear instructions to the model that examples are forthcoming.
  • Using XML Tags: Wrap input and output examples in XML tags (e. g. , <input>, <output>) to clearly delineate the structure for the model.
  • Addressing Corner Cases: When providing examples for difficult cases (like sarcasm), add explicit context to the prompt, instructing the model to be "especially careful" with those scenarios.
  • Reinforcing Reasoning (Optional but Recommended): Include the reason why a specific output is ideal (e. g. , copying the grader's explanation) to help the model understand the criteria for success, not just the format.

Takeaways

  • Few-shot prompting guides AI output by providing examples (one-shot or multi-shot) directly within the prompt.
  • Its primary uses include handling ambiguity, enforcing specific output formats (like JSON), and improving response quality.
  • Implementation requires clear instructions and structuring the prompt, often by using XML tags to delineate input and output examples.
  • Including the reasoning behind an ideal output helps the model understand the criteria for success, not just the required format.
Flashcards 8 cards
Question
click to reveal · ←/→
Answer
click to flip back
Export to Anki (.tsv) ↓
Knowledge check 1 questions