"First we'll want to create a Chroma VectorStore and seed it with some data. We've created a small demo set of documents that contain summaries of movies.\n",
"\n",
"NOTE: The self-query retriever requires you to have `lark` installed (`pip install lark`)"
@ -46,7 +46,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"id": "bcbe04d9",
"metadata": {},
"outputs": [
@ -77,13 +77,13 @@
"id": "5ecaab6d",
"metadata": {},
"source": [
"# Creating our self-querying retriever\n",
"## Creating our self-querying retriever\n",
"Now we can instantiate our retriever. To do this we'll need to provide some information upfront about the metadata fields that our documents support and a short description of the document contents."
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"id": "86e34dbf",
"metadata": {},
"outputs": [],
@ -124,13 +124,13 @@
"id": "ea9df8d4",
"metadata": {},
"source": [
"# Testing it out\n",
"## Testing it out\n",
"And now we can try actually using our retriever!"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"id": "38a126e9",
"metadata": {},
"outputs": [
@ -150,7 +150,7 @@
" Document(page_content='Leo DiCaprio gets lost in a dream within a dream within a dream within a ...', metadata={'year': 2010, 'director': 'Christopher Nolan', 'rating': 8.2})]"
]
},
"execution_count": 6,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
@ -162,7 +162,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"id": "fc3f1e6e",
"metadata": {},
"outputs": [
@ -180,7 +180,7 @@
" Document(page_content='Three men walk into the Zone, three men walk out of the Zone', metadata={'year': 1979, 'rating': 9.9, 'director': 'Andrei Tarkovsky', 'genre': 'science fiction'})]"
]
},
"execution_count": 7,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
@ -192,7 +192,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"id": "b19d4da0",
"metadata": {},
"outputs": [
@ -209,7 +209,7 @@
"[Document(page_content='A bunch of normal-sized women are supremely wholesome and some men pine after them', metadata={'year': 2019, 'director': 'Greta Gerwig', 'rating': 8.3})]"
]
},
"execution_count": 8,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
@ -221,7 +221,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"id": "f900e40e",
"metadata": {},
"outputs": [
@ -238,7 +238,7 @@
"[Document(page_content='Three men walk into the Zone, three men walk out of the Zone', metadata={'year': 1979, 'rating': 9.9, 'director': 'Andrei Tarkovsky', 'genre': 'science fiction'})]"
]
},
"execution_count": 9,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
@ -250,7 +250,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"id": "12a51522",
"metadata": {},
"outputs": [
@ -267,7 +267,7 @@
"[Document(page_content='Toys come alive and have a blast doing so', metadata={'year': 1995, 'genre': 'animated'})]"
]
},
"execution_count": 10,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
@ -276,6 +276,14 @@
"# This example specifies a query and composite filter\n",
"retriever.get_relevant_documents(\"What's a movie after 1990 but before 2005 that's all about toys, and preferably is animated\")"
"Now we can instantiate our retriever. To do this we'll need to provide some information upfront about the metadata fields that our documents support and a short description of the document contents."
]
},
@ -142,7 +142,7 @@
"id": "ea9df8d4",
"metadata": {},
"source": [
"# Testing it out\n",
"## Testing it out\n",
"And now we can try actually using our retriever!"