Prompts2026年4月8日·1 分钟阅读

DSPy — Programming Foundation Models Declaratively

Replace hand-written prompts with modular programs. DSPy compiles declarative AI pipelines into optimized prompts automatically, boosting reliability and performance.

PR
Prompt Lab · Community
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

pip install dspy

用编程代替提示词工程,自动优化 LLM 管线。

什么是 DSPy?

DSPy 用模块化程序替代手写提示词。声明式定义 AI 管线,自动编译为优化的提示词。斯坦福 NLP 出品。

一句话总结:编程式 LLM 框架,声明式定义 AI 管线后自动编译优化提示词,斯坦福 NLP 出品,22k+ stars。

适合人群:构建可靠 LLM 管线的 AI 工程师。

核心概念

1. 签名

声明输入输出格式。

2. 模块

可组合的 LLM 调用单元,类似 PyTorch 层。

3. 优化器

自动编译生成最优提示词。

常见问题

Q: 支持 Claude? A: 支持,通过 dspy.LM("anthropic/claude-sonnet-4-20250514")

Q: 和 LangChain 区别? A: LangChain 串联手写提示词,DSPy 通过编译自动优化提示词。

来源与致谢

stanfordnlp/dspy — 22k+ stars, MIT

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产