Learn the fundamentals of DSPy and how to use its signature and module-based programming model to build modular, traceable, and debuggable GenAI agentic applications.
DSPy: Build and Optimize Agentic Apps
Instructor: Chen Qian
Earn an accomplishment with PRO · Updated Oct 7, 2025

- Intermediate
- 59m
- 6 Video Lessons
- 3 Code Examples
- 1 Graded Assignment PRO
- Earn an accomplishment with PRO
- Updated Oct 7, 2025
- Instructor: Chen Qian
Databricks- Learn more aboutMembership PRO Plan
What you'll learn
Build agentic applications by chaining DSPy modules like Predict, ChainOfThought, and ReAct, and use MLflow to trace and debug your programs.
Optimize your GenAI apps with DSPy Optimizer by automating prompt tuning and improving few-shot examples to improve answer accuracy and consistency.
Course recap
PROThis course, built in partnership with Databricks, teaches how to build and optimize GenAI applications using DSPy -- a lightweight, flexible framework that replaces manual prompt engineering with programmatic LM interaction. DSPy defines inputs and outputs via signatures and modules, enabling LM-agnostic programming rather than LM-biased prompting.
Concept map
Key concepts
- Prompt EngineeringDSPy addresses the brittleness of manual prompt engineering by replacing string-level prompt tweaking with structured input/output signatures
- Signatures and ModulesDSPy's two main abstractions: signatures define input/output contracts for LM calls, while modules wrap custom logic and can be composed like PyTorch modules
- DSPy OptimizersAutomatic program optimization through prompt template generation, few-shot bootstrapping, and intelligent combinatorial search (MiproV2 optimizer)
- Fine-TuningDSPy supports both prompt optimization and LM weight fine-tuning through its optimizer framework
- MLflow TracingOne-line integration (`mlflow.dspy.autolog`) provides hierarchical tracing of module calls, adapter formatting, LM interactions, and tool calls for debugging
- ReAct (Reasoning and Act)Built-in module for building AI agents that can reason about tool usage and decide when to call tools vs. answer directly
Lesson highlights
- 1.Introduction — Overview of DSPy, the problems it solves (brittle prompt engineering, framework lock-in), and its three key innovations
- 2.Introduction to DSPy — What DSPy is, compound AI systems, and why LM-agnostic programming matters
- 3.DSPy Programming - Signatures and Modules — Building applications with class-based/string-based signatures, built-in modules (Predict, ChainOfThought, ReAct), custom modules, and the "Name the Celebrity" game demo
- 4.Debug Your DSPy Agent with MLflow Tracing — Using MLflow tracing to build and debug an airline customer service agent with ReAct
- 5.Optimizing Agents with DSPy Optimizer — Using MiproV2 optimizer for automatic prompt optimization and few-shot bootstrapping on a Wikipedia QA RAG agent
- 6.Conclusion — Recap of DSPy's capabilities
About this course
Join DSPy: Build and Optimize Agentic Apps, built in partnership with Databricks and taught by Chen Qian, a software engineer at Databricks and co-lead maintainer of the DSPy framework.
Agentic AI applications tackle complex tasks such as document automation, question-answering, and multi-step decision-making. However, building these applications can become complex and one challenge is writing and maintaining good prompts. DSPy is a flexible open-source framework that simplifies your application’s interaction with LLMs. It streamlines your workflow by utilizing modular blocks in which you can provide a dataset of inputs and desired output, and systematically build, trace, and optimize your application.
This course teaches you how to use DSPy to build and optimize LLM-powered applications. You’ll write programs using DSPy’s signature-based programming model, debug them with MLflow tracing, and automatically improve their accuracy with DSPy Optimizer. Along the way, you’ll see how DSPy helps you easily switch models, manage complexity, and build agents that are both powerful and easy to maintain.
You’ll immediately put the concepts to work, first by coding a sentiment classifier in roughly 30 lines, then stretching the same pattern into a “Name the Celebrity” guessing game. Next, you’ll trace every step of a travel-booking assistant with MLflow, and wrap up by letting DSPy Optimizer lift a Wikipedia-based RAG agent’s accuracy, all without hand-tuning prompts.
In detail, you’ll learn:
- What makes DSPy different from other development frameworks, and how its signature-based design enables flexible, model-agnostic development.
- How to compose agentic apps by chaining DSPy modules like Predict, ChainOfThought, and React, and debug them using MLflow tracing, demonstrated in both a sentiment analyzer and a “Name the Celebrity” guessing game.
- How to visualize and interpret your DSPy programs using MLflow, an open-source MLOps framework for observability that makes it easy to understand submodule behavior and catch issues early.
- How to use DSPy Optimizer to automatically improve your program quality through prompt tuning and few-shot examples, seen through an example of optimizing a Wikipedia RAG agent that improves from 31% to 54% exact-match accuracy.
By the end of this course, you’ll be able to build structured, robust, and adaptable GenAI applications with DSPy, ready to run on whichever LLM comes next.
Who should join?
This course is ideal for anyone who wants a more reliable, maintainable way to build and debug multi-step agents. No prior DSPy experience or knowledge is required.
Course Outline
6 Lessons・3 Code Examples

Elevate your learning experience with Pro
Upgrade to Pro and gain unlimited accomplishments on your resume
Instructor
Course access is free for a limited time during the DeepLearning.AI learning platform beta!
Want to learn more about Generative AI?
Keep learning with updates on curated AI news, courses, and events, as well as Andrew’s thoughts from DeepLearning.AI!

