Context Engineering With DSPy

Every · · 1 hr 9 min

Mike Taylor, head of evals at Every, walks through DSPy with Drew and Isaac of Compound, the team behind it. They argue you should define tasks and examples, then let optimizers write the prompts instead of hand-tuning them.

Watch the episode 1 hr 9 min · YouTube

The gist

  1. Mike says DSPy signatures define a task by its typed inputs and outputs, so his two-year-old programs still work after swapping models and re-optimizing.
  2. Using a Pydantic object as the output type removed all his parsing and retry code when Mike generated 5,000 AI personas for a credit card company.

What they recommend · 3 picks

DSPy Main topic · strong yes

A framework for algorithmically optimizing language model prompts and weights, especially for complex tasks...

"The magic words that you found, like they don't resonate with this new model. And so DSPy I think solved that problem for me, which is I can do all the fun stuff around the prompt, but I don't need to write the prompt anymore... My DSPy programs I've writte..."
Mike Taylor ▶ Play at 4:29

What Mike uses it for: Model-agnostic LLM programs, building CLIs, optimizing prompts, and getting structured outputs

Get an email when another creator talks about DSPy.

"One of the tricks I like to do in DSPy... it's called an optimizer evaluator pattern. If I have a subjective test like, 'Hey, does this rewritten text look like AI?' I will firs..."

Pydantic Productivity

"I just made that output object in Pydantic and then passed that in... I'd written all this extra code of like, hey, if it doesn't come out with this, then try again. And none of..."

Also mentioned

26:40 Claude · "Now I don't hand in an HTML page or an email of like here's the work I did. I use Opus to actually create a..."
30:45 pandas · "I'm just going to load this into a data frame in Pandas."
38:12 ChatGPT · "This text is not AI, I wrote this. You know, this one is AI, like ChatGPT wrote this."
54:25 Gemini · "Then we can drop in Gemini. We can say, 'Hey, a new Gemini model came out.'... And then you can see here..."
1:00:22 LangChain · "I had kind of built DSPy in LangChain at the time. I had a really shitty one, and then I was like, 'Oh,..."

◎

Related episodes

Episodes covering similar topics

Follow DSPy

Free email updates