Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

minor changes to notebook+copro code (better print statements)

klopsahlong76e0cb1bf829
diff --git a/dspy/teleprompt/copro_optimizer.py b/dspy/teleprompt/copro_optimizer.py
index 4cd7e3ba3..9d304cf9e 100644
--- a/dspy/teleprompt/copro_optimizer.py
+++ b/dspy/teleprompt/copro_optimizer.py
@@ -151,7 +151,7 @@ class COPRO(Teleprompter):
# For each iteration in depth...
for d in range(self.depth): # TODO: fix this so that we eval the new batch of predictors with the new best followoing predictors
- if self.verbose: print(f"Starting iteration {d}/{self.depth}.")
+ print(f"Iteration Depth: {d+1}/{self.depth}.")
latest_scores = []
@@ -176,9 +176,9 @@ class COPRO(Teleprompter):
# Score the instruction / prefix
if self.verbose: print("----------------")
for i,predictor in enumerate(module_clone.predictors()):
- if self.verbose: print(f"Predictor {i}")
+ if self.verbose: print(f"Predictor {i+1}")
self._print_signature(predictor)
- if self.verbose: print(f"At Depth {d}/{self.depth}, Evaluating Prompt Candidate #{c_i}/{len(candidates_)} for Predictor {p_i} of {len(module.predictors())}.")
+ print(f"At Depth {d+1}/{self.depth}, Evaluating Prompt Candidate #{c_i+1}/{len(candidates_)} for Predictor {p_i+1} of {len(module.predictors())}.")
score = evaluate(module_clone, devset=trainset, **eval_kwargs)
if self.verbose and self.prompt_model: print(f"prompt_model.inspect_history(n=1) {self.prompt_model.inspect_history(n=1)}")
total_calls += 1
diff --git a/examples/qa/hotpot/hotpotqa_with_MIPRO.ipynb b/examples/qa/hotpot/hotpotqa_with_MIPRO.ipynb
index e97102d97..3c1df4f37 100644
--- a/examples/qa/hotpot/hotpotqa_with_MIPRO.ipynb
+++ b/examples/qa/hotpot/hotpotqa_with_MIPRO.ipynb
@@ -15,7 +15,8 @@
"id": "3wEDck3ZqZH0"
},
"source": [
- "# Using __<ins>M</ins>ulti-stage <ins>I</ins>nstruction <ins>P</ins>roposal & <ins>O</ins>ptimization (MIPRO)__ in DSPy"
+ "# Using __<ins>M</ins>ulti-stage <ins>I</ins>nstruction <ins>P</ins>roposal & <ins>O</ins>ptimization (MIPRO)__ in DSPy\n",
+ "<!-- [![colab-badge](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/stanfordnlp/dspy/blob/main/examples/longformqa/longformqa_assertions.ipynb) -->"
]
},
{
@@ -136,7 +137,8 @@
" !pip install -e $repo_path\n",
" !pip install --upgrade cloudpickle==3.0.0\n",
"\n",
- "import dspy"
+ "import dspy\n",
+ "import openai"
]
},
{
@@ -392,7 +394,7 @@
],
"source": [
"import cloudpickle as pickle\n",
- "from dspy.teleprompt import BayesianSignatureOptimizer\n",
+ "from dspy.teleprompt import MIPRO\n",
"\n",
"LOAD_PRECOMPILED_PROGRAM = True\n",
"\n",