stanfordnlp/dspy

GitHub: stanfordnlp/dspy

DSPy 是一个通过编程而非手工提示来构建和优化语言模型管线的声明式框架,解决 prompt 脆弱且难以系统化优化的问题。

Stars: 36139 | Forks: 3102

## DSPy:_编程_——而非提示——基础模型 **文档:** [DSPy 文档](https://dspy.ai/) [![PyPI 下载量](https://static.pepy.tech/personalized-badge/dspy?period=monthly)](https://pepy.tech/projects/dspy) DSPy 是一个_通过编程而非提示来驱动语言模型_的框架。它允许您快速迭代**构建模块化 AI 系统**,并提供算法来**优化提示和权重**,无论您是在构建简单的分类器、复杂的 RAG pipeline,还是 Agent 循环。 DSPy 代表 Declarative Self-improving Python(声明式自我改进 Python)。您无需编写脆弱的提示,而是编写组合式的 _Python 代码_,并使用 DSPy 来**教导您的 LM 提供高质量的输出**。通过我们的[官方文档网站](https://dspy.ai/)了解更多信息,或者通过这个 GitHub 仓库和我们的 [Discord 服务器](https://discord.gg/XCGy2WDCQB)与社区互动、寻求帮助,或开始贡献。 ## 文档:[dspy.ai](https://dspy.ai) **请前往 [dspy.ai 上的 DSPy 文档](https://dspy.ai)** ## 安装 ``` pip install dspy ``` 安装 `main` 分支上的最新版本: ``` pip install git+https://github.com/stanfordnlp/dspy.git ``` ## 📜 引用与延伸阅读 如果您想了解该框架,请前往 [dspy.ai 上的 DSPy 文档](https://dspy.ai)。 如果您想了解其背后的研究,以下是我们的一系列论文: **[25年7月] [GEPA:反思式提示进化可以胜过强化学习](https://arxiv.org/abs/2507.19457)** **[24年6月] [为多阶段语言模型程序优化指令和示例](https://arxiv.org/abs/2406.11695)** **[23年10月] [DSPy:将声明式语言模型调用编译为自我改进的 Pipeline](https://arxiv.org/abs/2310.03714)** [24年7月] [Fine-Tuning 与提示优化:协同工作效果更佳的两大步骤](https://arxiv.org/abs/2407.10930) [24年6月] [将提示作为自动优化的训练超参数](https://arxiv.org/abs/2406.11706) [24年2月] [利用大型语言模型从头协助撰写维基百科风格的文章](https://arxiv.org/abs/2402.14207) [24年1月] [用于极端多标签分类的 In-Context Learning](https://arxiv.org/abs/2401.12178) [23年12月] [DSPy Assertions:自我改进语言模型 Pipeline 的计算约束](https://arxiv.org/abs/2312.13382) [22年12月] [Demonstrate-Search-Predict:组合检索与语言模型以处理知识密集型 NLP](https://arxiv.org/abs/2212.14024.pdf) 如需保持最新状态或了解更多信息,请在 Twitter 上关注 [@DSPyOSS](https://twitter.com/DSPyOSS) 或 LinkedIn 上的 DSPy 主页。 **DSPy** Logo 由 **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} } ```