Prompt Optimization (DSPy, OPRO)

Treat prompts as code: optimize them programmatically with objective functions.

Prompt optimization frameworks treat prompts as artifacts that can be improved through automated search and evaluation.

Examples

  • DSPy: declarative modules + optimizers that tune instructions and demonstrations.
  • OPRO: use an LLM as an optimizer by iterating on prompt candidates with scores.

Why It Matters

Manual prompt tweaks do not scale. For agents, you want evaluation-driven optimization tied to metrics like success rate, cost, and latency.