{"slug": "dspy-program-don-t-prompt-your-llms", "title": "DSPy – Program, don't prompt, your LLMs", "summary": "DSPy 3.4.0 has been released with PythonInterpreter improvements, faster GEPA optimization, and MCP v2 compatibility, according to the Stanford NLP project's release notes. The Python framework, which has 38,000 GitHub stars, 461 contributors, and more than 5.2 million monthly downloads, lets developers define tasks as typed signatures and compile them against a metric; the release notes cite a GEPA example improving retrieval-augmented generation from 0.41 F1 to 0.63 F1.", "body_md": "DSPy 3.4.0 — PythonInterpreter improvements, faster GEPA, and MCP v2 compatibility · \n\n [learn more →](https://github.com/stanfordnlp/dspy/releases)\n#  Program, don’t prompt,\n\nyour LLMs. \n\n DSPy is a Python framework for building AI systems. Express your tasks as structured signatures, not prompts, to produce maintainable, modular, and optimizable programs.\n\n**extract_events.py**\n\n 12345 678910 \n\n lm = dspy.LM(\"openai/gpt-5.4-nano\")\n\n class ExtractEvent(dspy.Signature):\n\n  \"\"\"Extract event details from an email.\"\"\"\n\n  email: str = dspy.InputField()\n\n  event_name: str = dspy.OutputField()\n\n  date: str = dspy.OutputField()\n\n extract = dspy.Predict(ExtractEvent)\n\n extract(email=inbox_message)\n\n output\n\n Prediction(\n\n  event_name=\"Team Offsite\",\n\n  date=\"Thursday, June 5\"\n\n )\n\n 5.2M+\n\n monthly downloads\n\n 461+\n\n contributors\n\n 38k\n\n github stars\n\n in production at\n\n ## Compose programs with reusable primitives.\n\n### Signatures\n\nDeclare your task.\n\n Define your task as typed inputs and outputs instead of managing messy prompts. Portable, maintainable, and easy to iterate on.\n\nclass Triage(dspy.Signature):\n\n  \"\"\"Route a support ticket.\"\"\"\n\n  ticket: str = dspy.InputField()\n\n  urgency: Literal[\"low\", \"high\"] = dspy.OutputField()\n\n  team: str = dspy.OutputField()\n\n ### Modules\n\nSame interface, different strategy.\n\n Modules control how your signature executes. Reason, run ensembles, use tools, add a REPL, and more without rewriting your task.\n\n# Direct completion\n\n classify = dspy.Predict(Triage)\n\n # Add step-by-step reasoning\n\n classify = dspy.ChainOfThought(Triage)\n\n # Add tools and a reasoning loop\n\n classify = dspy.ReAct(Triage, tools=[search])\n\n ### Optimizers\n\nCompile your program against a metric.\n\n Give DSPy examples and a scoring function. It tunes your prompts automatically until quality converges.\n\ntp = dspy.GEPA(\n\n  metric=semantic_f1,\n\n  auto=\"medium\")\n\n opt = tp.compile(rag, trainset)\n\n # Before: 0.41 F1\n\n # After: 0.63 F1\n\n opt.save(\"rag.v2.json\")\n\n ## Define a task. Grow it into a system.\n\nclass Extract(dspy.Signature):\n\n  \"\"\"Extract contact info.\"\"\"\n\n  message: str = dspy.InputField()\n\n  name: str = dspy.OutputField()\n\n  email: Optional[str] = dspy.OutputField()\n\n  intent: Literal[\n\n  \"meeting\", \"intro\", \"follow-up\"\n\n  ] = dspy.OutputField()\n\n extract = dspy.Predict(Extract)\n\n extract(message=\"I'm Sarah\"\n\n  \"(sarah@acme.co). Meet Thursday?\")\n\n outputstdout\n\n Prediction(\n\n  name=\"Sarah\",\n\n  email=\"sarah@acme.co\",\n\n  intent=\"meeting\"\n\n )\n\n def search(query: str) -> list[str]:\n\n  \"\"\"Search a knowledge base.\"\"\"\n\n  return kb.query(query, k=3)\n\n def calc(expr: str) -> float:\n\n  \"\"\"Evaluate a math expression.\"\"\"\n\n  return dspy.PythonInterpreter({}).execute(expr)\n\n agent = dspy.ReAct(\n\n  \"question -> answer\",\n\n  tools=[search, calc])\n\n agent(question=\"GDP per capita of France?\")\n\n outputstdout\n\n # thought 1: I need France's GDP and population.\n\n # action 1: search(\"France GDP\") → ...\n\n # thought 2: Now divide GDP by population.\n\n # action 2: calc(\"3.13e12 / 68e6\") → 46029.4\n\n Prediction(answer=\"$46,029\")\n\n class FactCheck(dspy.Module):\n\n  def __init__(self):\n\n  self.find = dspy.ChainOfThought(\n\n  \"article -> claims: list[str]\")\n\n  self.verify = dspy.ChainOfThought(\n\n  \"claim, source -> verdict\")\n\n  def forward(self, article):\n\n  found = self.find(article=article)\n\n  return [\n\n  self.verify(claim=c, source=article)\n\n  for c in found.claims]\n\n outputstdout\n\n # >>> FactCheck()(article=news_article)\n\n [Prediction(verdict=\"supported\"),\n\n  Prediction(verdict=\"unsupported\"),\n\n  Prediction(verdict=\"supported\")]\n\n class AnalyzeChart(dspy.Signature):\n\n  \"\"\"Describe the trend and key data points in a chart.\"\"\"\n\n  chart: dspy.Image = dspy.InputField()\n\n  title: str = dspy.OutputField()\n\n  trend: str = dspy.OutputField()\n\n  data_points: list[dict] = dspy.OutputField()\n\n analyze = dspy.Predict(AnalyzeChart)\n\n analyze(chart=dspy.Image(\"quarterly_revenue.png\"))\n\n outputstdout\n\n Prediction(\n\n  title=\"Quarterly Revenue (2024)\",\n\n  trend=\"Steady growth, Q3 dip, strong Q4 recovery\",\n\n  data_points=[{\"q\": \"Q1\", \"rev\": \"$4.2M\"}, ...]\n\n )\n\n optimizer = dspy.GEPA(\n\n  metric=accuracy, auto=\"medium\")\n\n optimized = optimizer.compile(\n\n  extract, trainset=labeled_emails)\n\n optimized.save(\"extract_v2.json\")\n\n outputstdout\n\n # Baseline 62% (gpt-5.4-mini, zero-shot)\n\n # Optimized 89% (gpt-5.4-mini + GEPA compile)\n\n # Cost $2.18 · 200 examples\n\n # Saved to → extract_v2.json\n\n ## Built in the open, since Dec 2022.\n\nDSPy started at Stanford NLP and grew into a research community. New optimizers and module types land here first — then show up in production systems at companies you’ve heard of.\n\nDec 2025\n\n Recursive Language Models\n\n  Jul 2025\n\n GEPA: Reflective Prompt Evolution\n\n  Jul 2024\n\n BetterTogether: Fine-Tuning + Prompt Opt.\n\n  Jun 2024\n\n MIPROv2: Optimizing Instructions & Demos\n\n  Feb 2024\n\n STORM: Writing Wikipedia-like Articles\n\n  Oct 2023\n\n DSPy: Compiling Declarative LM Calls\n\n  Dec 2022\n\n Demonstrate-Search-Predict\n\n   ### DSPy in production\n\nMetadata extraction across all shops; ~550× cost reduction\n\n Optimized Dash relevance judge for ranking and evaluation\n\n Prompt migration from larger to smaller models on Amazon Nova\n\n Multiple chatbot use cases on Databricks\n\n Code repair pipeline using code LLMs to synthesize diffs\n\n LM judges, RAG, classification, and customer solutions\n\n Evolutionary self-improvement for the Hermes agent\n\n See all companies using DSPy in production", "url": "https://wpnews.pro/news/dspy-program-don-t-prompt-your-llms", "canonical_source": "https://dspy.ai/current/", "published_at": "2026-09-27 19:38:34+00:00", "updated_at": "2026-09-27 20:01:28.709024+00:00", "lang": "en", "topics": ["large-language-models", "ai-agents", "developer-tools", "agent-protocols", "ai-tools"], "entities": ["DSPy", "Stanford NLP", "PythonInterpreter", "GEPA", "MCP", "GitHub"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/dspy-program-don-t-prompt-your-llms", "markdown": "https://wpnews.pro/news/dspy-program-don-t-prompt-your-llms.md", "text": "https://wpnews.pro/news/dspy-program-don-t-prompt-your-llms.txt", "jsonld": "https://wpnews.pro/news/dspy-program-don-t-prompt-your-llms.jsonld"}}