Configuring and Running the MetaPromptOptimizer

~15 min read

MetaPromptOptimizer uses a reasoning model to critique and iteratively refine your base prompt — install, configure, define a base prompt, and call optimize_prompt() to start.

Configuring and Running the MetaPromptOptimizer is a Pro topic

Sign in, then upgrade to Pro or Power to unlock this topic and the full AI Engineering curriculum.

Key points

  • MetaPromptOptimizer uses a reasoning model to critique and iteratively refine your base prompt, informed by evaluation results
  • Setup sequence: install Opik + optimizer package -> define dataset -> configure the metric -> define the base prompt -> instantiate the optimizer with a chosen model
  • optimize_prompt() takes the dataset, metric, and base prompt to start the optimization process
  • It first evaluates the initial prompt to establish a baseline score, then iterates through several AI-written candidate prompts
  • The book uses GPT-4o for the optimizing model, but notes any other LLM works since Opik is fully open-source