Skip to content

armgit / dspy

Public Imported from GitHub
0

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

Python

SkyCamp 2023 commit 04

Omar Khattab11d6296d29d7
diff --git a/skycamp2023.ipynb b/skycamp2023.ipynb
index d111ff169..a7f5fef26 100644
--- a/skycamp2023.ipynb
+++ b/skycamp2023.ipynb
@@ -49,7 +49,7 @@
" # !pip install dspy-ai\n",
" !pip install -e $repo_path\n",
"\n",
- "import dspy"
+ "!pip install transformers"
]
},
{
@@ -58,11 +58,8 @@
"metadata": {},
"outputs": [],
"source": [
- "!pip install transformers\n",
- "\n",
"import dspy\n",
"from dspy.evaluate import Evaluate\n",
- "from dspy.datasets.hotpotqa import HotPotQA\n",
"from dspy.teleprompt import BootstrapFewShot, BootstrapFewShotWithRandomSearch, BootstrapFinetune"
]
},
@@ -414,8 +411,8 @@
" self.retrieve = dspy.Retrieve(k=num_passages)\n",
" self.generate_query = dspy.ChainOfThought(\"question -> search_query\")\n",
"\n",
- " # TODO: Define a dspy.ChainOfThought module with the signature `context, question -> answer`.\n",
- " self.generate_query_from_context = dspy.ChainOfThought(\"context, question -> search_query\")\n",
+ " # TODO: Replace `None` with a dspy.ChainOfThought module that has the signature `context, question -> answer`.\n",
+ " self.generate_query_from_context = None\n",
"\n",
" self.generate_answer = dspy.ChainOfThought(\"context, question -> answer\")\n",
" \n",
@@ -425,12 +422,12 @@
" search_query = self.generate_query(question=question).search_query\n",
" passages += self.retrieve(search_query).passages\n",
"\n",
- " # TODO: Use self.generate_query_from_context to generate a search query.\n",
- " # Note: Modules require named keyword arguments (e.g., context=..., question=...).\n",
- " search_query = self.generate_query_from_context(context=passages, question=question).search_query\n",
+ " # TODO: Replace `None` with a call to self.generate_query_from_context to generate a search query.\n",
+ " # Note: In DSPy, always pass keyword arguments (e.g., context=..., question=...) to the modules to avoid ambiguity.\n",
+ " search_query2 = None\n",
"\n",
- " # TODO: Use self.retrieve to retrieve passages. Append them to the list `passages`.\n",
- " passages += self.retrieve(search_query).passages\n",
+ " # TODO: Replace `None` with a call to self.retrieve to retrieve passages. Append them to the list `passages`.\n",
+ " passages += None\n",
"\n",
" return self.generate_answer(context=deduplicate(passages), question=question)"
]