OSS Agents JP
オープンソース AI エージェント 日本語ガイド
← 一覧へ
DSPy
OTHER

DSPy

DSPy

プロンプトエンジニアリングではなくPythonコードで言語モデルを最適化・プログラミングするフレームワーク。モジュラーなAIシステムの迅速な構築と、プロンプト・重みの自動最適化を実現します。

原文: DSPy: The framework for programming—not prompting—language models
#LLM最適化#Python#メタプログラミング
EDITOR'S TAKE

編集部メモ

プロンプトの職人芸から解放する、言語モデルプログラミング言語

DSPyは、手書きプロンプトに頼らず、Pythonコードとして言語モデルシステムを構築・最適化するフレームワークです。RAGパイプラインからエージェントループまで、複雑なLLMアプリケーションを「プログラム」として扱い、プロンプトと重みを自動で改善できます。プロダクション志向の開発チームや、LLMの出力をより確実にしたい企業に向いています。一方、Pythonコーディングの習熟が前提で、プロンプト調整の細粒度な制御は失われるトレードオフがあります。

USE CASES

こんな場面で使う

  • 複数のLLMコンポーネントを組み合わせた推論パイプラインを、自動最適化で構築・運用する
  • 入出力の制約(JSON形式、特定フィールドの値)を保証しながら、LLMの応答品質を向上させる
  • A/Bテストや改善サイクルを組み込んだ、反復的なLLMシステム開発を加速する
DIFFERENTIATOR

類似ツールとの違い

LangChainはワークフロー統合を、PromptOpsはプロンプト版管理を重視するのに対し、DSPyは言語モデルの『プログラミング言語』として振る舞い、従来のソフトウェア最適化手法(勾配ベース、強化学習など)をLLM領域に持ち込むユニークな位置付けです。
CAVEAT

注意点・向かない用途

⚠️ Pythonの開発スキルが必須で、プロンプトエンジニアの直感的な調整が難しくなる可能性があります。また、最適化時にLLM APIコストが嵩むリスクや、フレームワークの抽象度が高いため習熟曲線が急な点に注意が必要です。
BEST FOR

向いている読者

LLMベースのプロダクト開発に携わるエンジニア出力品質の自動改善を求める企業・研究チームプロンプト管理の煩雑さから脱却したい開発者

— OSS Agents JP 編集部による独自評価(DSPy に関する観察)

REPO STATS

リポジトリ統計

⭐ Stars
34.4k
🍴 Forks
2.9k
⚠️ Open Issues
465
🌿 Language
Python
📄 License
MIT
🕒 最終更新
2026.05.13 (1日前)
📅 公開日
2023.01.10
🌿 Branch
main
REFERENCE

公式ドキュメント(README)

本ハブの独自評価は上記「編集部メモ」が一次情報です。以下は GitHub README の参考転載(折りたたみ)。

📖 GitHub README の日本語訳を読む(AI 自動翻訳 / 参考情報)

— AI による自動翻訳 (2026.05.14 更新)。正確な情報は GitHub の原文 をご確認ください。

DSPy: プログラミング—プロンプティングではなく—Foundation Models

ドキュメント: DSPy Docs

PyPI Downloads


DSPy は、プロンプティングではなくプログラミングによって言語モデルを制御するためのフレームワークです。**モジュール式 AI システム**を構築する際に迅速に反復でき、シンプルな分類器から高度な RAG パイプライン、Agent ループまで、**プロンプトと重みを最適化するアルゴリズム**を提供します。

DSPy は Declarative Self-improving Python の略です。脆いプロンプトの代わりに、合成型のPython コードを書き、DSPy を使って**LM に高品質な出力を提供するように教えます**。公式ドキュメントサイトで詳しく学ぶか、このGitHub リポジトリとDiscord サーバーでコミュニティに参加し、サポートを求めるか、貢献を開始できます。

ドキュメント: dspy.ai

dspy.ai の DSPy Docs にアクセスしてください

インストール

pip install dspy

main から最新版をインストールするには:

pip install git+https://github.com/stanfordnlp/dspy.git

📜 引用・詳細情報

フレームワークの理解を深めたい場合は、dspy.ai の DSPy Docs にアクセスしてください。

基礎となる研究を理解したい場合は、以下が当グループの論文です:

[Jul'25] GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learning
[Jun'24] Optimizing Instructions and Demonstrations for Multi-Stage Language Model Programs
[Oct'23] DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines
[Jul'24] Fine-Tuning and Prompt Optimization: Two Great Steps that Work Better Together
[Jun'24] Prompts as Auto-Optimized Training Hyperparameters
[Feb'24] Assisting in Writing Wikipedia-like Articles From Scratch with Large Language Models
[Jan'24] In-Context Learning for Extreme Multi-Label Classification
[Dec'23] DSPy Assertions: Computational Constraints for Self-Refining Language Model Pipelines
[Dec'22] Demonstrate-Search-Predict: Composing Retrieval & Language Models for Knowledge-Intensive NLP

最新情報を得たり詳しく学んだりするには、Twitter で @DSPyOSS をフォローするか、LinkedIn の DSPy ページをご覧ください。

DSPy ロゴは Chuyi Zhang によってデザインされました。

研究論文で DSPy または DSP を使用する場合は、以下のように当グループの研究を引用してください:

@inproceedings{khattab2024dspy,
  title={DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines},
  author={Khattab, Omar and Singhvi, Arnav and Maheshwari, Paridhi and Zhang, Zhiyuan and Santhanam, Keshav and Vardhamanan, Sri and Haq, Saiful and Sharma, Ashutosh and Joshi, Thomas T. and Moazam, Hanna and Miller, Heather and Zaharia, Matei and Potts, Christopher},
  journal={The Twelfth International Conference on Learning Representations},
  year={2024}
}
@article{khattab2022demonstrate,
  title={Demonstrate-Search-Predict: Composing Retrieval and Language Models for Knowledge-Intensive {NLP}},
  author={Khattab, Omar and Santhanam, Keshav and Li, Xiang Lisa and Hall, David and Liang, Percy and Potts, Christopher and Zaharia, Matei},
  journal={arXiv preprint arXiv:2212.14024},
  year={2022}
}
📖 GitHub README の原文を読む(English / 参考情報)

— GitHub から取得した原文。完全版は GitHub へ。

DSPy: Programming—not prompting—Foundation Models

Documentation: DSPy Docs

PyPI Downloads


DSPy is the framework for programming—rather than prompting—language models. It allows you to iterate fast on building modular AI systems and offers algorithms for optimizing their prompts and weights, whether you're building simple classifiers, sophisticated RAG pipelines, or Agent loops.

DSPy stands for Declarative Self-improving Python. Instead of brittle prompts, you write compositional Python code and use DSPy to teach your LM to deliver high-quality outputs. Learn more via our official documentation site or meet the community, seek help, or start contributing via this GitHub repo and our Discord server.

Documentation: dspy.ai

Please go to the DSPy Docs at dspy.ai

Installation

pip install dspy

To install the very latest from main:

pip install git+https://github.com/stanfordnlp/dspy.git

📜 Citation & Reading More

If you're looking to understand the framework, please go to the DSPy Docs at dspy.ai.

If you're looking to understand the underlying research, this is a set of our papers:

[Jul'25] GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learning
[Jun'24] Optimizing Instructions and Demonstrations for Multi-Stage Language Model Programs
[Oct'23] DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines
[Jul'24] Fine-Tuning and Prompt Optimization: Two Great Steps that Work Better Together
[Jun'24] Prompts as Auto-Optimized Training Hyperparameters
[Feb'24] Assisting in Writing Wikipedia-like Articles From Scratch with Large Language Models
[Jan'24] In-Context Learning for Extreme Multi-Label Classification
[Dec'23] DSPy Assertions: Computational Constraints for Self-Refining Language Model Pipelines
[Dec'22] Demonstrate-Search-Predict: Composing Retrieval & Language Models for Knowledge-Intensive NLP

To stay up to date or learn more, follow @DSPyOSS on Twitter or the DSPy page on LinkedIn.

The DSPy logo is designed by Chuyi Zhang.

If you use DSPy or DSP in a research paper, please cite our work as follows:

@inproceedings{khattab2024dspy,
  title={DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines},
  author={Khattab, Omar and Singhvi, Arnav and Maheshwari, Paridhi and Zhang, Zhiyuan and Santhanam, Keshav and Vardhamanan, Sri and Haq, Saiful and Sharma, Ashutosh and Joshi, Thomas T. and Moazam, Hanna and Miller, Heather and Zaharia, Matei and Potts, Christopher},
  journal={The Twelfth International Conference on Learning Representations},
  year={2024}
}
@article{khattab2022demonstrate,
  title={Demonstrate-Search-Predict: Composing Retrieval and Language Models for Knowledge-Intensive {NLP}},
  author={Khattab, Omar and Santhanam, Keshav and Li, Xiang Lisa and Hall, David and Liang, Percy and Potts, Christopher and Zaharia, Matei},
  journal={arXiv preprint arXiv:2212.14024},
  year={2022}
}
RELATED

同じカテゴリの他のツール