|
49 | 49 | " # !pip install dspy-ai\n",
|
50 | 50 | " !pip install -e $repo_path\n",
|
51 | 51 | "\n",
|
52 |
| - "import dspy" |
| 52 | + "!pip install transformers" |
53 | 53 | ]
|
54 | 54 | },
|
55 | 55 | {
|
|
58 | 58 | "metadata": {},
|
59 | 59 | "outputs": [],
|
60 | 60 | "source": [
|
61 |
| - "!pip install transformers\n", |
62 |
| - "\n", |
63 | 61 | "import dspy\n",
|
64 | 62 | "from dspy.evaluate import Evaluate\n",
|
65 |
| - "from dspy.datasets.hotpotqa import HotPotQA\n", |
66 | 63 | "from dspy.teleprompt import BootstrapFewShot, BootstrapFewShotWithRandomSearch, BootstrapFinetune"
|
67 | 64 | ]
|
68 | 65 | },
|
|
414 | 411 | " self.retrieve = dspy.Retrieve(k=num_passages)\n",
|
415 | 412 | " self.generate_query = dspy.ChainOfThought(\"question -> search_query\")\n",
|
416 | 413 | "\n",
|
417 |
| - " # TODO: Define a dspy.ChainOfThought module with the signature `context, question -> answer`.\n", |
418 |
| - " self.generate_query_from_context = dspy.ChainOfThought(\"context, question -> search_query\")\n", |
| 414 | + " # TODO: Replace `None` with a dspy.ChainOfThought module that has the signature `context, question -> answer`.\n", |
| 415 | + " self.generate_query_from_context = None\n", |
419 | 416 | "\n",
|
420 | 417 | " self.generate_answer = dspy.ChainOfThought(\"context, question -> answer\")\n",
|
421 | 418 | " \n",
|
|
425 | 422 | " search_query = self.generate_query(question=question).search_query\n",
|
426 | 423 | " passages += self.retrieve(search_query).passages\n",
|
427 | 424 | "\n",
|
428 |
| - " # TODO: Use self.generate_query_from_context to generate a search query.\n", |
429 |
| - " # Note: Modules require named keyword arguments (e.g., context=..., question=...).\n", |
430 |
| - " search_query = self.generate_query_from_context(context=passages, question=question).search_query\n", |
| 425 | + " # TODO: Replace `None` with a call to self.generate_query_from_context to generate a search query.\n", |
| 426 | + " # Note: In DSPy, always pass keyword arguments (e.g., context=..., question=...) to the modules to avoid ambiguity.\n", |
| 427 | + " search_query2 = None\n", |
431 | 428 | "\n",
|
432 |
| - " # TODO: Use self.retrieve to retrieve passages. Append them to the list `passages`.\n", |
433 |
| - " passages += self.retrieve(search_query).passages\n", |
| 429 | + " # TODO: Replace `None` with a call to self.retrieve to retrieve passages. Append them to the list `passages`.\n", |
| 430 | + " passages += None\n", |
434 | 431 | "\n",
|
435 | 432 | " return self.generate_answer(context=deduplicate(passages), question=question)"
|
436 | 433 | ]
|
|
0 commit comments