Coders In Hoods
  • Courses
  • Roles
  • Blog
  • Setup

Coders In Hoods AI Academy

Every course is free. Sign in to start, and your progress, quiz scores and bookmarks follow you.

AI Academy

  • Courses
  • Paths
  • Setup guides
  • How we teach

Role roadmaps

  • AI Engineer
  • Forward Deployed Engineer
  • Machine Learning Engineer
  • All roles

Coders In Hoods

  • The agency
  • Coaching for teams
  • Blog
  • LinkedIn
  • X (Twitter)

Contact

codersinhoods@gmail.com

© Coders In Hoods · since 2019

Course overview

Prompt and Context Optimisation

Free · sign in to start and track progress

1 · Designing prompts systematically

  • 1Prompting current Claude models
  • 2Choosing few-shot examples
  • 3Eval-driven prompt iteration

2 · Optimising and operating prompts

  • 4Automatic prompt optimisation

    Exercise answers

    • Answer: Build a small reflective optimiser on claude -p
    • Answer: DSPy: MIPROv2 versus GEPA
  • 5Optimising tools, instructions and skills
  • 6Prompt registries and online tests
  • 7Model migration and regression suites
CapstoneOptimise and ship the questions drafterReference implementation

Module 2 · Optimising and operating prompts · Lesson 4

Automatic prompt optimisation

How optimisers search over prompts and examples - from APE and OPRO to DSPy's MIPROv2 and GEPA's reflective, Pareto-based evolution - what they genuinely buy you, what a run costs, and how they overfit, with a DSPy version of the report summariser.

80 min 2 videos 3 exercises 7-question quiz Answers
Setup for the exercises:Install Claude CodePython with uvGet an OpenRouter keyLocal models with Ollama

By the end of this lesson you can

  • Describe the shared skeleton of prompt optimisers (candidates, proposer, metric, search) and place APE, ProTeGi, OPRO, TextGrad, MIPROv2 and GEPA on it
  • Write a DSPy signature, module and feedback metric for a workflow step, and choose between BootstrapFewShot, MIPROv2 and GEPA
  • Explain how GEPA uses reflection on traces and a Pareto front of candidates, and why that is more sample-efficient than scalar-reward search
  • Estimate the cost of an optimisation run from call counts and prices, and identify which component dominates it
  • Judge an optimised prompt against a held-out set and decide whether to adopt, adapt or reject it

On this page

  • The skeleton every optimiser shares
  • DSPy: programs, not prompt strings
  • MIPROv2
  • GEPA: reflection and a Pareto front
  • Worked example: what does a run cost?
  • What optimisers really buy
  • Misconceptions and limits
  • Connections
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01The skeleton every optimiser shares
  2. 02DSPy: programs, not prompt strings
  3. 03GEPA: reflection and a Pareto front
  4. 04Worked example: what does a run cost?
  5. 05What optimisers really buy
  6. 06Misconceptions and limits
  7. 07Connections
  8. 08Summary

Sources & further reading

  • GEPA: Reflective Prompt Evolution Can Outperform Reinforcement LearningPaper · Agrawal et al. · UC Berkeley, Stanford and others · 2025The current state of the art. Reflection on traces plus Pareto selection; reports beating GRPO with up to 35x fewer rollouts and MIPROv2 by over 10%. Read sections 1–3 (ICLR 2026 oral).
  • Optimizing Instructions and Demonstrations for Multi-Stage Language Model ProgramsPaper · Opsahl-Ong et al. · Stanford · 2024The MIPRO paper - grounded instruction proposals, demo bootstrapping and a Bayesian surrogate over combinations (EMNLP 2024).
  • DSPy: Compiling Declarative Language Model Calls into Self-Improving PipelinesPaper · Khattab et al. · Stanford · 2023The programming model - signatures, modules and optimisers ("teleprompters") that compile a program against a metric.
  • Large Language Models as OptimizersPaper · Yang et al. · Google DeepMind · 2023OPRO - an LLM proposes new prompts from a trajectory of past prompts and scores. The clearest statement of "LLM as optimiser" (ICLR 2024).
  • Automatic Prompt Optimization with "Gradient Descent" and Beam SearchPaper · Pryzant et al. · Microsoft · 2023ProTeGi - natural-language critiques of errors used as "textual gradients", with beam search over edits (EMNLP 2023).
  • A Systematic Survey of Automatic Prompt Optimization TechniquesPaper · Ramnath et al. · 2025A recent taxonomy of the field by candidate generation, evaluation and search strategy. Use it to place new tools as they appear (EMNLP 2025).
  • DSPy docs: choosing an optimizerDocs · DSPy (Stanford NLP)Current practical guidance - which optimiser for which bottleneck, cost warnings and overfitting notes.
Free · sign in to start

Sign in to keep reading.

Free, no card. We use your account to save progress, quiz scores, bookmarks and occasionally send updates from our team.

  • 8 more sections
  • 3 hands-on exercises
  • A 7-question quiz
  • Progress, quiz scores and bookmarks