PromptCause
Donate

9 / 11

Part 9 Automatic Prompt Optimization

Meta-prompting

Intermediate

In short: Use the model to write and improve prompts.

What is: Use the model itself to generate or improve prompts. It's what tools like Anthropic's "Prompt Improver" do, the model applies the techniques in this guide automatically to your draft.

When to use: When you have a draft prompt and want to optimize it without memorizing every technique.

When to avoid: Trivial prompts, meta-prompting becomes overhead.

Wrong
summarize this text for me
Right
You are a prompt-engineering expert. Rewrite the prompt below applying best practices: add a role, structure with XML, define the output format and include reasoning if the task needs it. Explain what changed. Original prompt: "summarize this text for me"

Instead of you memorizing everything, the model applies the techniques.

Why: Anthropic's Prompt Improver flow is: identify examples → structured draft with XML → refine with chain-of-thought → enrich examples. Meta-prompting is prompt engineering applied to itself.

💡 Tip: Give the meta-prompt the target model's context (Claude? GPT reasoning?), best practices diverge across families.

APE, OPRO, DSPy and friends

Advanced

In short: The machine optimizes the prompt automatically against data.

What is: Frameworks that optimize prompts programmatically against an evaluation set with ground truth. You don't write the perfect prompt, the machine discovers it by testing variations.

When to use: You have a labeled dataset and an objective metric, and the prompt runs at scale (worth automating).

When to avoid: No dataset/metric, stick with manual meta-prompting.

Right
Have ground truth and a metric? → DSPy/OPRO compile the prompt against the data. Want a quick win rewriting the instruction? → APE/TextGrad. No data? → manual meta-prompting with the guide's techniques.

OPRO beat human-written prompts by up to 50% on some benchmarks.

Why: OPRO (Yang et al., 2023) uses a meta-prompt describing the problem + prior solutions and their scores, and the model proposes better prompts iteratively. DSPy treats prompts as compilable code against ground truth.

💡 Tip: Even without a framework you can do it manually: define the metric, generate K variations, measure, take the best and iterate (hill climbing).