The Real Python Podcast

Programmatically Developing LLM Prompts With DSPy

52 snips
Aug 7, 2026
Brett Kennedy, author and applied ML practitioner who builds real-world LLM systems, explains DSPy and programmatic prompting. He describes declarative signatures, optimizers that search and tune prompts, and moving from brittle manual prompts to higher-level prompt programming. He also covers RAG workflows, evaluation with judge models, and practical patterns for production LLM apps.
Ask episode
AI Snips
Chapters
Books
Transcript
Episode notes
INSIGHT

DSPy Automates Prompt Engineering From Signatures

  • DSPy automates prompt engineering by generating and optimizing prompts from a high-level task signature.
  • You declare inputs/outputs and test examples; DSPy then writes prompts, tunes them, and evaluates responses for you.
INSIGHT

Signatures Let You Specify Precise Output Types

  • Signatures in DSPy let you declare precise input and output types, including formats like JSON fields and date formats.
  • Explicit typing guides LLM behavior and makes prompts clearer and more reliable across use cases.
INSIGHT

Manual Prompt Tricks Break Across Models

  • Manual prompt engineering is brittle because many small tricks (personas, chain-of-thought, rewording) work inconsistently across models.
  • DSPy treats prompt tuning like model training: the framework experiments rather than relying on human guesswork.
Get the Snipd Podcast app to discover more snips from this episode
Get the app