DSPy is a Python framework that treats LLM interactions as programmable tasks rather than ad-hoc prompts: developers declare typed Signatures that specify inputs and outputs, then attach interchangeable Modules that implement strategies (direct completion, chain-of-thought, ReAct with tools, ensembles, multimodal handlers, etc.). Signatures make tasks portable and maintainable, enable composition of primitives into larger pipelines, and allow tool integration (search, Python interpreter, calculators) and multimodal fields like images. Examples show extracting events or contact info, building agents that search and compute, composing verification pipelines, and returning structured predictions with enforced output types.
Optimization is built in: DSPy compiles programs against user-defined metrics using optimizers such as GEPA to automatically tune prompts/instructions and demos, with reported gains (example F1 from 0.41 to 0.63, or accuracy from 62% to 89% using GEPA). The project, originating at Stanford NLP, is research-forward (papers on GEPA, RLM, fine-tuning hybrids) and production-proven at companies like Shopify, Dropbox, AWS and more. The ecosystem includes many modules, adapters, evaluation metrics, caching/deployment utilities, and a large community with millions of downloads and tens of thousands of GitHub stars.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.