Workshop · Compile
DSPy
Write the program. Declare what goes in and what must come out. Attach a metric and a trainset. Compile searches for instructions and demonstrations that raise that metric. The shipped artifact is the compiled program.
What a template cannot do
A library template is a static string. It cannot search, cannot keep score, and cannot tell you whether yesterday’s wording still works on today’s cases.
- Not a prompt directory.
- Not live compilation in this encyclopedia.
- Not a claim about private chain-of-thought.
How it works
Conceptual workflow
Steppable map of DSPy. Evidence is taken from the spec on this page. Nothing here is a live compiler, eval, decoder, or optimizer run.
vcp · prompts/dspy
run@once
- signature
- module
- metric
- compile
- eval
- save
Stage 1 / 6 · role
Declare the signature
Name typed fields: what the module reads and what it must emit. The signature is the contract, not a personality.
Artifact · signature.py
User input
question -> answer
Rule in force
The interface is fields, not a costume.
Visible reply
class QA(dspy.Signature): question, answer
Illustration · not a live model run
Spec evidence
DSPy compiles a language-model program instead of leaving you to babysit a prompt string. A signature names typed inputs and outputs: question -> answer, or context, question -> evidence, answer. That contract is the module’s interface. A module is the unit of work. Predict fills the signature. ChainOfThought asks for a rationale field. ReAct interleaves tool calls with observations. Modules compose like ordinary code. A metric scores the program on examples you actually care about. Exact match, F1, a rubric, or a unit test — the optimizer cannot search without a score. Compile is the search. An optimizer proposes instructions and few-shot demonstrations, runs the program on a trainset, and keeps the candidates that raise the metric. The artifact is a compiled program, not a vibes-based rewrite. Evaluate on held-out examples. If the compiled prompt only memorizes the trainset, the metric on unseen cases will fall. Save the compiled program so the search does not have to be re-run for every request. DSPy does not run inside this encyclopedia. What you see is the compile loop as a map.
- This page is a conceptual map
- The compiler or eval runner is not executed here
Method
Compile loop · not executed here
Library
A pasted persona belongs in the library
Conceptual workflow · 4.5s / stage · 1/6