← Back to concept explainers

Concept Fable

DSPy

Conclusion first:DSPy is a framework for programming and optimizing LLM systems. It uses Signatures to declare task inputs and outputs, Modules to compose reasoning flows, and Teleprompter / Optimizer to optimize prompts, demonstrations or program settings based on examples and metrics. It emphasizes "programming, not prompting" and is suited to enterprise applications that need testable, tunable, multi-step LLM pipelines.

DSPy · LLM programming and optimization framework

Read the story first. There is no rush to give a definition here; let the question grow on its own first.

Fable

The theater turned prompt writing into a testable rehearsal program

The South City Theater hired many actors skilled at improvisation. The director arranged them through cue sheets: this line must be rigorous, that line must be brief, and when evidence appears, cite the source. The new play grew more and more complex. One actor rewrote questions, one actor looked up materials, one actor inferred the case, and one actor wrote the reply. The cue sheets were scattered everywhere. The director first tuned the wording by feel. Add a line today, delete a line tomorrow, and add a rule whenever a bad example appeared. After several rounds, no one knew which line was useful. He then posted the best examples on the wall. Some tasks improved, others worsened; after new actors joined, they had to figure it out all over again.

The new director switched to a rehearsal program. Each role declared inputs and outputs, modules were connected according to the program, and results were measured with evaluation sets and metrics.

The prompt sheet no longer relies on handwriting alone. The rehearsal meeting will search for more suitable lines, examples and pacing based on examples, evaluation scores and role structure.

The theater began arranging complex performances like a fixed set of tricks. Change one role and old scenes can be replayed; swap one set of examples and score changes can be seen.

The director also did not give up judgment. If metrics are chosen wrongly, data is too scarce, or the task definition is vague, the optimizer will lead the system in the wrong direction.

The new director didn't throw away the cue sheets, but placed them in the rehearsal book. Every time a line was changed, it had to be test-performed on the same set of plays, recording which act worked and which didn't; if a line saved only one scene but hurt three, it was withdrawn and re-staged.

The rehearsal book also let the theater stop fumbling in the dark when swapping actors. New actors took the stage according to the role's inputs, outputs, and scoring method, and the director then adjusted the stage cue sheet based on audition results. Experience moved from the director's head into rehearsals that could be repeatedly tested, and the production stabilized. Later, when the theater took on new plays, the director first wrote roles and scoring, then arranged auditions. Changes no longer piled up from on-the-spot inspiration, but entered an inspectable rehearsal procedure; good and bad could be compared, and experience could be reused.

He finally understood that a complex production cannot be sustained long-term by the director's feel alone; it needs a clear role structure and a rehearsal method that can be measured repeatedly.

Reveal

This story is about: DSPy

DSPy is a framework for programming and optimizing LLM systems. It uses Signatures to declare task inputs and outputs, Modules to compose reasoning flows, and Teleprompter / Optimizer to optimize prompts, demonstrations or program settings based on examples and metrics. It emphasizes "programming, not prompting" and is suited to enterprise applications that need testable, tunable, multi-step LLM pipelines.

What matters is that it is not just a term, but a structural problem that repeatedly appears in real AI / Agent systems. Understanding it lets you judge when to add a model, when to change a process, and when to add governance.

Metaphor mapping

  • Improviser: LLM calls
  • Tuning words by feel: manual prompt engineering
  • Example on the wall: few-shot examples
  • Rehearsal program: DSPy program
  • Declare inputs and outputs: Signature
  • Module connections: DSPy Modules
  • Search prompts and examples by metric: Teleprompter / Optimizer
  • Final insight: DSPy moves LLM systems from handwritten prompts to a programmable, evaluable and optimizable structure

Andy Ren Xu's judgment

The practical value of this concept is that it helps you break "AI features that look smart" into deliverable, verifiable, and governable units of work.

signaturemoduleteleprompteroptimizerprompt optimizationevaluation metric
京ICP备2026014272号