Prompting & Contextadvanced10 min · 7 steps
Prompt Optimization with DSPy
Stop hand-tuning prompt text. Declare what each step does, define a metric, and let an optimizer compile the prompts, and even the program shape, for each model.
requesterrordataresponsesignal
ProblemStep 1 of 7
Hand-tuned prompts are tuned for one model at one moment
You spent a week finding the right wording for GPT-6.1 Sol. Then you move to Claude Sonnet 5.5 or an open-weight Qwen3.8-27B, and quality drops. The prompt encoded point-in-time tuning for one model.
Was “Be helpful” better than “Think carefully”? Nobody measured. The wording was a guess that happened to work once.
Lesson 7 of 8 in Prompting & Context