← Back to Resources

DSPy: Programming (not prompting) LMs

DSPy (Stanford) replaces manual prompt engineering with a code-based workflow. Instead of tweaking text strings to get a better result, you define the logic using signatures (interfaces) and metrics (tests).

The system uses optimisers to automatically refine the underlying prompt until the output satisfies the defined metric. This treats the language model (LM) as a programmable module rather than a chat interface, providing a technical foundation for building more reliable AI systems.

Reference:Stanford NLP. (2025). DSPy: Programming (not prompting) LMs. DSPy.ai. https://dspy.ai/