Chapter
1. Introduction: From Prompts to Programs
An introduction to the concept of self-optimizing language model pipelines using DSPy, moving beyond brittle prompt engineering.
A tutorial for writing Self Optimizing DSPy for CNS
This tutorial demonstrates how to evolve a CNS 2.0 module from a system reliant on brittle, hand-crafted “prompt engineering” to a robust, self-optimizing program using the DSPy framework. We will focus on building a synthesis module that can programmatically learn to generate better prompts by using its own CNS Critic Pipeline as a quality metric.
This approach is a cornerstone of the advanced vision for CNS 2.0, creating a system that can adapt and improve its own reasoning capabilities over time. For more detail, see Chapter 7 of the Developer’s Guide.
Follow the steps in order:
Chapter
An introduction to the concept of self-optimizing language model pipelines using DSPy, moving beyond brittle prompt engineering.
Chapter
A code-heavy guide to setting up the core DSPy components: the Signature, the Metric, and the training Examples.
Chapter
How to use the DSPy compiler to automatically generate and optimize a powerful synthesis prompt based on our defined task.
Chapter
Analyzing the results of the DSPy compiler, comparing the optimized prompt to a naive one, and seeing the performance difference on a new example.