Reference · Glossary

DSPy

Last updated

A framework that treats prompting as **programming, not string templating** — you declare the input/output signature you want, and DSPy compiles and auto-tunes the actual prompt (and few-shot examples) against your evaluation metric instead of you hand-editing wording.

#When to use

When you're manually tweaking prompt wording over and over to chase a metric — DSPy automates that search using your eval set as the feedback signal.

#When not to

A one-off prompt you'll write once and never tune — the compile step only pays off once you have a real evaluation loop to optimize against.

#Example

import dspy
class Summarize(dspy.Signature):
    """Summarize the document in one sentence."""
    document = dspy.InputField()
    summary = dspy.OutputField()
summarizer = dspy.Predict(Summarize)
result = summarizer(document="...")