Files
myWiki/concepts/dspy.md

35 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "DSPy声明式自改进 Python"
created: 2026-06-29
updated: 2026-06-29
type: concept
tags: [prompt-engineering, framework, optimization, LLM]
sources: [[prompt-to-loop-engineering-2026]]
confidence: high
---
# DSPy (Declarative Self-improving Python)
> Stanford NLP 推出的声明式框架——将 [[prompt-engineering|Prompt]] 从"人工手写"升级为"可编译、可学习的程序"。
## 核心转变
开发者**不再手写指令字符串**,而是声明输入输出的签名,交给优化器自动搜索最优 Prompt 与 Few-shot 组合。
## 关键能力
1. **签名声明**:定义 `input → output` 的语义契约
2. **自动编译**:优化器在候选空间中搜索最优 Prompt + Few-shot
3. **模型切换**:底座模型从 GPT-4 换成 Llama 时,一键重新编译即可适配
## 工程意义
- 消除手工调参的技术债务
- 模型升级不再导致已有 Prompt 集体失效
- 将 Prompt 工程从"手艺"变为"工程学科"
## 相关概念
- [[prompt-engineering|Prompt Engineering]]
- [[blind-prompting|Blind Prompting]]