
An open-source framework for optimizing language model programs using modules, data, and evaluation metrics
项目介绍
DSPy 是起源于 Stanford NLP、由研究与开源社区共同发展的 Python 框架。它提倡把语言模型任务写成可组合的程序:先声明输入输出,再选择执行模块,最后通过数据和指标改进程序。它不是新的基础大模型,也不是给普通用户直接聊天的成品应用。主仓库采用 MIT 许可证,2026年10月28日 GitHub 约有3.9万星。对于已经会调用模型、但不希望长期靠手改提示词碰运气的开发者,它提供了另一种工程组织方式。
core functionality
Signature 用字段描述任务,例如输入一封邮件,输出事件名称、日期或分类;Module 决定如何执行这个任务,可以从简单 Predict 开始,逐步组合推理、检索或工具调用模块。模型适配层负责把这些定义转换成模型可接受的消息,因此“不手写提示”不代表底层没有提示。程序结构与模型选择分开后,更容易复用同一任务接口并比较不同方案。
数据驱动的优化
DSPy 的优化器利用样本和评分函数搜索更合适的指令或示例。以 GEPA 为例,评价结果还可以附带文字反馈,帮助下一轮修改指令。优化并非自动获得真实世界的最好答案:目标由指标定义,训练数据也会影响结果。开发者应保留独立的验证和测试样本,比较未优化基线与优化后表现,而不是只展示训练集分数。
What situations is it suitable for?
适合结构化信息抽取、分类、RAG 问答、工具型智能体,以及需要重复评估与迭代的语言模型业务。比如,把客服工单转成规定字段,或评估检索问答是否准确并依据资料。需要 Python 基础,也需要能说清楚什么是好结果。若只是临时写一段文案、没有可重复任务和评价标准,直接使用聊天工具通常更省事,不必引入完整优化流程。
How to Get Started
官方安装说明要求 Python 3.10 及以上,可用 pip install dspy 安装。先用 dspy.LM 配置模型提供方,通过 dspy.configure 设置默认模型,并用环境变量等安全方式管理密钥。为一个小任务定义输入输出 Signature,用 Predict 跑通单样本;接着收集代表性样本并编写 metric,使用 Evaluate 记录基线。确认评分能反映业务目标后,再尝试 GEPA 等优化器、设置预算,最后保存优化结果并在独立样本上复测。
费用与必要限制
开源库不收取模型推理费,但所调用的模型、评判模型和多轮优化会消耗算力或 API 额度。更高的评分也不自动等于更可靠:指标可能遗漏格式之外的事实错误,模型评判本身也可能有偏差。敏感样本进入外部模型前要检查数据权限和服务条款。DSPy 不能替代业务权限控制、生产监控或人工审核;切换模型、数据分布或库版本后,建议重新评估而不是假定旧优化结果继续有效。
Comparison of Similar Projects
| sports event | 主要方式 | 适合重点 | Please note |
|---|---|---|---|
| Langflow | 可视化流程与 Python 组件 | 快速原型、工具接入与流程 API | 需要维护运行环境和安全隔离 |
| Haystack | Python 组件与显式 Pipeline / Agent | 检索、RAG 与可控业务编排 | 需要自行设计数据与生产架构 |
| DSPy | Signature、Module、指标与优化器 | 结构化任务和数据驱动优化 | 需要样本、合理指标与优化预算 |
Official Portal and Resources
data statistics
Related Navigation

Microsoft has introduced a Visual Agent parsing framework that transforms large language models into intelligences that can manipulate computers, enabling efficient automated interactions.

MIDI (loanword)
AI 3D scene generation tool that can efficiently generate complete 3D environments containing multiple objects from a single image, widely used in VR/AR, game development, film and television production and other fields.

SongBloom
Tencent AI Lab and other joint research and development of open source song generation model, 10 seconds of audio + lyrics into 2 minutes 30 seconds of high-quality music, comparable to commercial standards.

AutoGPT
Based on the GPT-4 open-source project, integrating Internet search, memory management, text generation and file storage, etc., it aims to provide a powerful digital assistant to simplify the process of user interaction with the language model.

Kolors
Racer has open-sourced a text-to-image generation model called Kolors (Kotu), which has a deep understanding of English and Chinese and is capable of generating high-quality, photorealistic images.
Haystack
An Open-Source Python Orchestration Framework for Retrieval-Augmented Generation and Agents
MemHub
A "local-first" shared memory app launched by Tencent Hunyuan allows authorized AI tools to access conversation and coding context; it is currently still in preview.

NVIDIA Ising
The world's first open-source quantum AI model series, through AI-driven quantum chip calibration and error correction, provides a high-performance tool chain for practical quantum computing and reshapes the quantum industry ecosystem.
No comments...
