Michael Ryan’s Stanford lecture builds a calendar workflow with DSPy and compares it with LangGraph. It was recorded on October 7 and published on November 13, 2026. The lecture notebook makes the examples inspectable.

A DSPy signature names the inputs and outputs of a model call. Ryan types the event fields, then combines extraction with ordinary Python logic that checks for missing details before adding an event. Types help check structure; they cannot prove the extracted date is correct.

For comparison, the LangGraph version expresses the same workflow as state, nodes and conditional edges. Ryan notes that a graph can also call DSPy: the frameworks need not be exclusive choices.

What the demo measures

The notebook splits 50 synthetic emails into 30 training and 20 test examples. Its metric requires an exact match on date, start time and duration; it does not grade the event name. Ryan reports that Gemma 3 12B scored 11 of 20 before GEPA prompt optimization and 20 of 20 afterward. These are the lecture’s results, not an independent replication.

The notebook passes the training set to GEPA without a separate validation set. Current DSPy guidance recommends a separate validation set for candidate selection and a final test set untouched by either step. The notebook locks DSPy 3.4.0; the demo’s hosted model calls and optimization have a cost.

Try it

On paper, design a small event-extraction test set with missing times, conflicting dates and messages without events. Define which fields must match, reserve distinct training, validation and final test sets, and list errors the metric would miss.

Caveat: twenty synthetic test emails and a partial-field metric cannot establish calendar reliability in real use.

Return to the DSPy learning path.