WhoBuilt

Principles for Prompt Engineering

Oct 20, 2023· 56 min· 9.4K views·Watch on YouTube

Speaker

Karina Nguyen, a research engineer at Anthropic, shares prompt engineering practices for Claude with the AI Engineer audience.

Prompting as a writing practice

Nguyen explains that prompts shape which responses a model is likely to produce by supplying relevant context, keywords, and examples. She recommends treating prompt work as iterative writing: form a hypothesis about what the model can do, test it, and use the results to understand its strengths and limits.

Principles for clear prompts

Nguyen’s guidelines are clarity, conciseness, coherence, consistency, direction, and grounding with examples or sources. She says Claude often benefits from detailed, simple instructions and consistent XML tags, which can also help constrain the answer format.

Applying prompts to recommendations and long-context tasks

For a clothing recommendation project, Nguyen shows how Claude can judge whether labeled items fit a user’s request, then refine the prompt with criteria and a 1-to-10 score. For long-document question answering, she describes breaking questions into independent sub-questions and reports that, in one evaluation, putting the question at the end improved recall.

Evaluations, labeling, and practical API tips

Nguyen describes generating multiple-choice questions from government meeting transcripts published after the model’s training cutoff, then testing recall across long documents. For labeling text clusters, she suggests sampling multiple answers, checking consistency, and using contrastive examples. She also recommends allowing the model to say it lacks enough information and asking it to find supporting quotes in source documents.

Where prompt engineering is headed

Nguyen expects prompting to remain part of product development, including synthetic data generation, evaluations, self-revision, and small features such as conversation titles. She says Claude 2 is larger and somewhat smarter than Claude Instant, while Instant is faster and cheaper.

Takeaways

  • Write prompts as clear task instructions with consistent structure and only the needed context.
  • Use diverse examples and explicit criteria when a task is ambiguous or has edge cases.
  • For long-document question answering, test placing the question at the end of the prompt.
  • Ask for source quotes and allow an explicit no-answer response to reduce unsupported claims.
  • Evaluate prompts on the task itself; use manual review where automated checks are insufficient.

Mentioned in this talk

Search inside this talk

What was claimed 9

  • built
    “Claude, a large language model trained by Anthropic”
    YouTube
    Verified32 sources· Talk, Job posting, Web· archived
  • uses
    “working with security teams and Claude to find and fix vulnerabilities”
    0:12inUsing LLMs to Secure Source CodeYouTube
    Verified13 sources· Talk, Job posting
  • previously at
    Karina Nguyen previously at Anthropic
    research engineer
    “Before that, I worked at Anthropic for about two years”
    0:17inCreating Agents that Co-CreateYouTube
    Verified3 sources· Talk, Web· archived
  • feature
    CLIP: Provides embeddings for text and images
    “It provides embeddings for text and images.”
    YouTube
    Unverified1 source· Talk
  • uses
    trained by OpenAI
    “CLIP is a contrastive language-image model trained by OpenAI.”
    YouTube
    Unverified1 source· Talk
  • feature
    Claude: XML tags are easy to extract and can help constrain output formatting
    “Claude is pretty good at following instructions like, “Don't put anything outside the XML tags.””
    YouTube
    Unverified1 source· Talk
  • metric
    Claude: In the described long-document Q&A evaluation, asking the question at the end performed better than asking at the beginning.
    “asking the question at the end of the prompt performs a lot better than asking at the beginning”
    YouTube
    Unverified1 source· Talk
  • feature
    Claude: Improved at math and code compared with Claude Instant 1
    “Claude Instant is better than Claude Instant 1 in more reasoning-based tasks. It's much better at math and code.”
    YouTube
    Unverified1 source· Talk
Show all 9 facts

Related talks