DSPy: 编程——而非提示——基础模型
文档: DSPy Docs
DSPy 是一个用于_编程——而非提示——语言模型_的框架。它允许你在构建模块化 AI 系统时快速迭代,并为优化其提示词和权重提供算法,无论你是在构建简单的分类器、复杂的 RAG 管道,还是 Agent 循环。
DSPy 是 Declarative Self-improving Python(声明式自改进 Python)的缩写。与其使用脆弱的提示词,不如编写组合式的 Python 代码,并使用 DSPy 来教会你的 LM 输出高质量的结果。通过我们的官方文档站点了解更多,或通过此 GitHub 仓库和我们的 Discord 服务器加入社区、寻求帮助或开始贡献。
文档:dspy.ai
安装
pip install dspy
要从 main 安装最新版本:
pip install git+https://github.com/stanfordnlp/dspy.git
📜 引用与延伸阅读
如果您希望了解该框架,请访问 DSPy Docs at dspy.ai。
如果您希望了解其底层研究,以下是我们的论文列表:
[Jul'25] GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learning
[Jun'24] Optimizing Instructions and Demonstrations for Multi-Stage Language Model Programs
[Oct'23] DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines
[Jul'24] Fine-Tuning and Prompt Optimization: Two Great Steps that Work Better Together
[Jun'24] Prompts as Auto-Optimized Training Hyperparameters
[Feb'24] Assisting in Writing Wikipedia-like Articles From Scratch with Large Language Models
[Jan'24] In-Context Learning for Extreme Multi-Label Classification
[Dec'23] DSPy Assertions: Computational Constraints for Self-Refining Language Model Pipelines
[Dec'22] Demonstrate-Search-Predict: Composing Retrieval & Language Models for Knowledge-Intensive NLP
如需获取最新动态或了解更多,请关注 Twitter 上的 @DSPyOSS 或 LinkedIn 上的 DSPy 页面。
DSPy 标志由 Chuyi Zhang 设计。
如果您在研究论文中使用了 DSPy 或 DSP,请按以下方式引用我们的工作:
@inproceedings{khattab2024dspy,
title={DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines},
author={Khattab, Omar and Singhvi, Arnav and Maheshwari, Paridhi and Zhang, Zhiyuan and Santhanam, Keshav and Vardhamanan, Sri and Haq, Saiful and Sharma, Ashutosh and Joshi, Thomas T. and Moazam, Hanna and Miller, Heather and Zaharia, Matei and Potts, Christopher},
journal={The Twelfth International Conference on Learning Representations},
year={2024}
}
@article{khattab2022demonstrate,
title={Demonstrate-Search-Predict: Composing Retrieval and Language Models for Knowledge-Intensive {NLP}},
author={Khattab, Omar and Santhanam, Keshav and Li, Xiang Lisa and Hall, David and Liang, Percy and Potts, Christopher and Zaharia, Matei},
journal={arXiv preprint arXiv:2212.14024},
year={2022}
}