Skip to content

armgit / dspy

Public Imported from GitHub
0

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

Python

tutorial adjustment

Omar Khattab0eb1e04bfc13
diff --git a/docs/docs/tutorials/rag/index.ipynb b/docs/docs/tutorials/rag/index.ipynb
index 79cb6a070..45ce46b7c 100644
--- a/docs/docs/tutorials/rag/index.ipynb
+++ b/docs/docs/tutorials/rag/index.ipynb
@@ -94,7 +94,7 @@
"\n",
"\n",
"\n",
- "\u001b[34m[2024-11-23T22:12:48.901453]\u001b[0m\n",
+ "\u001b[34m[2024-11-23T23:16:35.966534]\u001b[0m\n",
"\n",
"\u001b[31mSystem message:\u001b[0m\n",
"\n",
@@ -404,7 +404,7 @@
"\n",
"\n",
"\n",
- "\u001b[34m[2024-11-23T22:12:49.329836]\u001b[0m\n",
+ "\u001b[34m[2024-11-23T23:16:36.149518]\u001b[0m\n",
"\n",
"\u001b[31mSystem message:\u001b[0m\n",
"\n",
@@ -527,14 +527,14 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "Average Metric: 125.68 / 300 (41.9%): 100%|██████████| 300/300 [00:00<00:00, 598.18it/s]"
+ "Average Metric: 125.68 / 300 (41.9%): 100%|██████████| 300/300 [00:00<00:00, 666.96it/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "2024/11/23 22:12:49 INFO dspy.evaluate.evaluate: Average Metric: 125.68228336477591 / 300 (41.9%)\n"
+ "2024/11/23 23:16:36 INFO dspy.evaluate.evaluate: Average Metric: 125.68228336477591 / 300 (41.9%)\n"
]
},
{
@@ -699,13 +699,24 @@
"source": [
"## Set up your system's retriever.\n",
"\n",
- "As far as DSPy is concerned, you can plug in any Python code for calling tools or retrievers. Here, we'll just use OpenAI Embeddings and do top-K search locally, just for convenience."
+ "As far as DSPy is concerned, you can plug in any Python code for calling tools or retrievers. Here, we'll just use OpenAI Embeddings and do top-K search locally, just for convenience.\n",
+ "\n",
+ "**Note:** The step below will require that you either do `pip install -U faiss-cpu` or pass `brute_force_threshold=30_000` to `dspy.retrievers.Embeddings` to avoid faiss."
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
+ "outputs": [],
+ "source": [
+ "# %pip install -U faiss-cpu # or faiss-gpu if you have a GPU"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {},
"outputs": [
{
"name": "stdout",
@@ -744,7 +755,7 @@
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
@@ -767,7 +778,7 @@
},
{
"cell_type": "code",
- "execution_count": 15,
+ "execution_count": 16,
"metadata": {},
"outputs": [
{
@@ -779,7 +790,7 @@
")"
]
},
- "execution_count": 15,
+ "execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
@@ -791,7 +802,7 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": 17,
"metadata": {},
"outputs": [
{
@@ -802,7 +813,7 @@
"\n",
"\n",
"\n",
- "\u001b[34m[2024-11-23T22:13:02.348625]\u001b[0m\n",
+ "\u001b[34m[2024-11-23T23:16:49.175612]\u001b[0m\n",
"\n",
"\u001b[31mSystem message:\u001b[0m\n",
"\n",
@@ -879,21 +890,21 @@
},
{
"cell_type": "code",
- "execution_count": 17,
+ "execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Average Metric: 166.39 / 300 (55.5%): 100%|██████████| 300/300 [00:14<00:00, 20.29it/s]"
+ "Average Metric: 166.54 / 300 (55.5%): 100%|██████████| 300/300 [00:04<00:00, 61.40it/s] "
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "2024/11/23 22:13:17 INFO dspy.evaluate.evaluate: Average Metric: 166.39410892098812 / 300 (55.5%)\n"
+ "2024/11/23 23:16:54 INFO dspy.evaluate.evaluate: Average Metric: 166.53601368289284 / 300 (55.5%)\n"
]
},
{
@@ -1008,10 +1019,10 @@
{
"data": {
"text/plain": [
- "55.46"
+ "55.51"
]
},
- "execution_count": 17,
+ "execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
@@ -1057,7 +1068,7 @@
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": 20,
"metadata": {},
"outputs": [
{
@@ -1075,7 +1086,7 @@
},
{
"cell_type": "code",
- "execution_count": 20,
+ "execution_count": 21,
"metadata": {},
"outputs": [
{
@@ -1111,21 +1122,21 @@
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Average Metric: 183.28 / 300 (61.1%): 100%|██████████| 300/300 [00:13<00:00, 22.20it/s] "
+ "Average Metric: 183.32 / 300 (61.1%): 100%|██████████| 300/300 [00:02<00:00, 104.48it/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
- "2024/11/23 22:14:01 INFO dspy.evaluate.evaluate: Average Metric: 183.27658621624977 / 300 (61.1%)\n"
+ "2024/11/23 23:17:21 INFO dspy.evaluate.evaluate: Average Metric: 183.3194433591069 / 300 (61.1%)\n"
]
},
{
@@ -1240,10 +1251,10 @@
{
"data": {
"text/plain": [
- "61.09"
+ "61.11"
]
},
- "execution_count": 21,
+ "execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
@@ -1263,7 +1274,7 @@
},
{
"cell_type": "code",
- "execution_count": 22,
+ "execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
@@ -1283,7 +1294,7 @@
},
{
"cell_type": "code",
- "execution_count": 23,
+ "execution_count": 24,
"metadata": {},
"outputs": [
{
@@ -1295,7 +1306,7 @@
")"
]
},
- "execution_count": 23,
+ "execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}