Optimization

One of DSPy.rb’s most powerful features is automatic optimization. Instead of manually tweaking prompts, you can use optimizers to systematically improve your modules.

Why Optimize?

Traditional prompt engineering is:

  • Time-consuming and manual
  • Inconsistent across different inputs
  • Hard to maintain as requirements change

DSPy.rb optimization is:

  • Automatic and data-driven
  • Consistent and reproducible
  • Adapts to new requirements

Optimization Guides

Prompt Optimization

Learn the fundamentals of how DSPy.rb optimizes prompts automatically using examples and metrics.

Simple Optimizer

Start with BootstrapFewShot - the easiest optimizer that generates effective few-shot examples.

MIPROv2

Advanced optimization with MIPROv2 for production-grade performance and reliability.

Evaluation

Build metrics and evaluation frameworks to measure and improve your modules systematically.

Benchmarking Raw Prompts

Compare monolithic prompts against modular DSPy implementations to measure improvements in token usage, performance, and cost.

Getting Started

We recommend starting with:

  1. Understanding Prompt Optimization concepts
  2. Trying the Simple Optimizer on your modules
  3. Building proper Evaluation metrics
  4. Graduating to MIPROv2 for production use