Claude, Nutshell Series

Claude Exam Quick Revision 1: Prompt Engineering & Few-Shot Prompting

Core rule: Precise instructions beat vague instructions.

Prompting Types

  • Zero-shot: Instruction only, no examples.
  • One-shot: One example demonstrates expected behaviour.
  • Few-shot: A small number of examples guide difficult decisions.
  • Negative examples: Show what Claude should NOT identify.
  • Contrastive examples: Show why one similar case is correct and another is not.

When to Use Few-Shot Prompting

  • Ambiguous classification.
  • Sarcasm or mixed sentiment.
  • Subjective boundaries.
  • Important edge cases.

Good pattern: Use 2–4 diverse examples including at least one difficult edge case.

Reducing False Positives

Use explicit and measurable criteria instead of instructions such as “flag anything suspicious.”

Example: “Flag functions longer than 50 lines” is better than “flag overly complex functions.”

Exam Traps

  • Temperature 0 improves consistency, not correctness.
  • Few-shot examples guide behaviour but do not guarantee enforcement.
  • Critical business rules should be implemented programmatically.

Memory: Ambiguity → examples. Hard rule → code.

Leave a comment