Skip to content

armgit / dspy

Public Imported from GitHub
0

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

Python

colab changes

Jasper Xian5bfed8eab95b
diff --git a/pyserini.ipynb b/pyserini.ipynb
index 0fd8eecc8..2ed64a5ae 100644
--- a/pyserini.ipynb
+++ b/pyserini.ipynb
@@ -17,6 +17,42 @@
"Using `dspy.Pyserini` will require installing pyserini, Pytorch, and Faiss. Pyserini can be installed with `pip install pyserini`, and we'll leave it to you to decide the right versions of Pytorch and Faiss to install."
]
},
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "%load_ext autoreload\n",
+ "%autoreload 2\n",
+ "\n",
+ "import sys\n",
+ "import pkg_resources \n",
+ "\n",
+ "try: # When on google Colab, let's clone the notebook so we download the cache.\n",
+ " import google.colab\n",
+ " repo_path = 'dspy'\n",
+ " if not \"pyserini\" in {pkg.key for pkg in pkg_resources.working_set}:\n",
+ " !pip install pyserini\n",
+ " if not \"torch\" in {pkg.key for pkg in pkg_resources.working_set}:\n",
+ " !pip install torch\n",
+ " if not \"faiss-cpu\" in {pkg.key for pkg in pkg_resources.working_set}:\n",
+ " !pip install faiss-cpu\n",
+ "except:\n",
+ " repo_path = '.'\n",
+ "\n",
+ "if repo_path not in sys.path:\n",
+ " sys.path.append(repo_path)\n",
+ "\n",
+ "# Install the package if it's not installed\n",
+ "if not \"dspy-ai\" in {pkg.key for pkg in pkg_resources.working_set}:\n",
+ " !pip install -U pip\n",
+ " !pip install dspy-ai\n",
+ " # !pip install -e $repo_path\n",
+ "\n",
+ "import dspy"
+ ]
+ },
{
"cell_type": "markdown",
"metadata": {},
@@ -26,7 +62,7 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 1,
"metadata": {},
"outputs": [
{
@@ -49,7 +85,6 @@
}
],
"source": [
- "import dspy\n",
"pys_ret_prebuilt = dspy.Pyserini(index='beir-v1.0.0-nfcorpus.contriever-msmarco', query_encoder='facebook/contriever-msmarco', id_field='_id', text_fields=['title', 'text'])\n",
"\n",
"dspy.settings.configure(rm=pys_ret_prebuilt)\n",
@@ -158,7 +193,7 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 2,
"metadata": {},
"outputs": [
{