跳到主要内容Skip to main content
Agent 框架与编排Agent Frameworks & Orchestration生产可用Production

DSPy

stanfordnlp / dspy

把提示词、检索和工具调用写成可组合的模块,再用优化器按指标自动改提示与示例;不是手写链式调用的封装。Write prompts, retrieval and tool calls as composable modules, then optimise prompts and examples against a metric instead of hand-tuning chains.

39.2k stars 3535 forks Python 语言Language MIT 许可License 最近推送Last push 2026-11-19

为什么选Why choose it

  • 同一套流程换模型或换数据时,signature 与 optimizer 能把调参变成可复现实验,而不是反复手改 prompt。Modules and signatures make prompt programs testable.
  • MIPROv2 等优化器仍是提示词自动优化的常用基线,适合做小样本、可量化的对比。Optimisers can search demonstrations and instructions against a metric.
  • 模块边界清楚,检索、推理、评分可以分开替换和单独评测。A better fit than ad-hoc string concatenation when you have evaluation data.

不适合Not for

只想开箱即用聊天界面,或不愿意为任务准备训练/验证样本的团队。You have no evaluation set and no way to measure improvement.
固定一条提示就能解决的小项目,引入优化器只会增加复杂度。You only need one static prompt with no optimisation loop.

最小上手Minimum setup

  1. 按 README 安装 dspy,准备一个模型 API 或本地推理端点。Start with a small labelled set and a simple metric.
  2. 跑官方 Signature + Predict 最小示例,确认输入输出字段。Build one module and record the baseline score.
  3. 用 20–50 条自己的样本接上 BootstrapFewShot 或 MIPROv2,记录基线分数。Run an optimiser and compare on a held-out set, not the training examples.

依赖与成本Dependencies and cost

Python 3.9+;任意 LLM API 或本地模型;优化器需要少量标注样本与可重复的评分函数。Check runtime, model weights and external service dependencies in the README.

许可与使用边界License and usage boundaries

代码 MIT;模型与数据按其自身条款。Code is MIT; model weights, training data and generated content may have separate terms — check each before commercial use.

开源不等于可商用:GPL / AGPL 有传染性;代码许可、模型许可、生成内容许可要分开看。上线前读仓库 LICENSE 与模型卡,必要时让法务确认。Open source is not automatically commercial-use friendly: GPL / AGPL are copyleft; code, model and output licenses are separate. Read the LICENSE and model card before launch, and involve legal when needed.

替代与相邻Alternatives and neighbors

  • LangGraph — 生产可用Production,把 agent 写成有状态图:节点、边、检查点、人工确认与回滚都能显式表达。Write an agent as a stateful graph: nodes, edges, checkpoints, human approval and rollback are explicit.
  • LlamaIndex — 生产可用Production,面向 RAG 与应用层的数据框架:连接器、索引、检索、查询引擎、agent。A data framework for RAG and application layers: connectors, indexes, retrieval, query engines and agents.

下一步Next steps

  • 打开 GitHub,先读 README、LICENSE、最近 release 与 issue。Open GitHub and read the README, LICENSE, latest release and issues first.
  • 按“部署依赖 / 显存 / 数据 / 网络 / 权限”列一张上手清单。Make an onboarding checklist for deployment dependencies, VRAM, data, network and permissions.
  • 用一个小样本跑通,再决定是否进生产;不要直接上生产数据。Run a small sample first, then decide on production; never start with production data.

GitHub 仓库 ↗GitHub repository ↗ 文档 ↗Docs ↗ 加入对比Add to compare

快照口径:stars / forks / language / license / pushed_at 来自 GitHub API 2026-11-20 快照;之后的变化没有回写。标签与“适合 / 不适合”是编辑判断,不是 GitHub 元数据。Snapshot: stars / forks / language / license / pushed_at come from the GitHub API snapshot on 2026-11-20; later changes are not written back. Tags and “fit / not fit” are editorial judgments, not GitHub metadata.
不背书:本站只做索引与风险提示,不审计代码、不保证安全、不替你做许可判断。仓库脚本与模型权重请自行审查。No endorsement: this site only indexes and flags risks; it does not audit code, guarantee security or make license decisions for you. Review repository scripts and model weights yourself.