Imp.Optimizer.COPRO (Imp v0.5.0)

Copy Markdown View Source

DSPy 3.2.1 coordinate prompt optimizer.

COPRO searches, stores, compares, and deduplicates (instruction, prefix) metadata as DSPy 3.2.1 does. DSPy declares prefix deprecated and does not render it into task prompts; Imp behaves the same way. Only instruction changes affect task prompts.

A configured proposal LM may return the whole requested JSON batch. If it returns one candidate, Imp performs ordered, bounded fan-out with distinct rollout IDs until the requested batch is complete. A proposal LM must be set explicitly on the optimizer or in Imp settings. COPRO never substitutes canned suffixes for a missing proposer, including when the task program has its own LM. :extra_instructions are explicit candidate seeds; when present, they are evaluated before LM-generated proposals but do not silently replace the required proposal model.

proposal_response_format: :required sends an exact JSON Schema and validates the returned batch before any candidate evaluation. :auto does so when the configured LM advertises schema support; :off preserves DSPy's tolerant text compatibility path.

For statistics fidelity, results_latest preserves 3.2.1's cumulative latest_scores behavior across predictors within each depth.

Ordinary proposal and task failures follow COPRO's bounded error behavior. Operational route, cost, budget, transport, and cancellation guards remain fatal through both proposal fan-out and candidate evaluation.

Summary

Functions

new(metric, opts \\ [])