Files
myWiki/concepts/dspy.md

1.1 KiB
Raw Blame History

title, created, updated, type, tags, sources, confidence
title created updated type tags sources confidence
DSPy声明式自改进 Python 2026-06-29 2026-06-29 concept
prompt-engineering
framework
optimization
LLM
prompt-to-loop-engineering-2026
high

DSPy (Declarative Self-improving Python)

Stanford NLP 推出的声明式框架——将 prompt-engineering 从"人工手写"升级为"可编译、可学习的程序"。

核心转变

开发者不再手写指令字符串,而是声明输入输出的签名,交给优化器自动搜索最优 Prompt 与 Few-shot 组合。

关键能力

  1. 签名声明:定义 input → output 的语义契约
  2. 自动编译:优化器在候选空间中搜索最优 Prompt + Few-shot
  3. 模型切换:底座模型从 GPT-4 换成 Llama 时,一键重新编译即可适配

工程意义

  • 消除手工调参的技术债务
  • 模型升级不再导致已有 Prompt 集体失效
  • 将 Prompt 工程从"手艺"变为"工程学科"

相关概念