Chapter 6. Deep Dive into Prompt Optimizers
Reaching the optimization stage means you’ve done your homework. You’ve defined your program, collected your dataset, and built a robust evaluation metric. Your reward is that you now have everything you need to run DSPy’s powerful optimizers. But it can be hard to understand which one to run.
Different optimizers in DSPy will improve the quality of your program’s outputs by selecting or generating good few-shot examples, or proposing and testing better prompt instructions, as well as fine-tuning the weights of your language model. Finding the right optimizer and configuration to use for your task requires experimentation, but there are good rules of thumb to follow:
-
Start with
BootstrapFewShotif you have ~10 examples in your dataset -
For optimizing the prompt,
GEPAlearns well from 10-50 examples -
If you have 50+ examples try
BootstrapFewShotWithRandomSearch -
If your optimization budget is substantial and you have 200+ examples, use
MIPROv2 -
To maximize efficiency ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access