Skip to content

Commit 5724ba6

Browse files
committed
fix some typos
1 parent cb5fb89 commit 5724ba6

File tree

1 file changed

+106
-21
lines changed

1 file changed

+106
-21
lines changed

python-recipes/vector-search/05_multivector_search.ipynb

Lines changed: 106 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,18 @@
2626
"metadata": {},
2727
"outputs": [],
2828
"source": [
29-
"%pip install \"redisvl>=0.9.0\""
29+
"%pip install \"redisvl>0.9.1\""
30+
]
31+
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": null,
35+
"metadata": {},
36+
"outputs": [],
37+
"source": [
38+
"import redisvl\n",
39+
"# check version\n",
40+
"redisvl.__version__"
3041
]
3142
},
3243
{
@@ -119,7 +130,7 @@
119130
},
120131
{
121132
"cell_type": "code",
122-
"execution_count": null,
133+
"execution_count": 6,
123134
"metadata": {},
124135
"outputs": [],
125136
"source": [
@@ -131,7 +142,8 @@
131142
"REDIS_PASSWORD = os.getenv(\"REDIS_PASSWORD\", \"\") # ex: \"1TNxTEdYRDgIDKM2gDfasupCADXXXX\"\n",
132143
"\n",
133144
"# If SSL is enabled on the endpoint, use rediss:// as the URL prefix\n",
134-
"REDIS_URL = f\"redis://:{REDIS_PASSWORD}@{REDIS_HOST}:{REDIS_PORT}\""
145+
"# REDIS_URL = f\"redis://:{REDIS_PASSWORD}@{REDIS_HOST}:{REDIS_PORT}\"\n",
146+
"REDIS_URL = \"redis://localhost:6380\" # running redis 8 here"
135147
]
136148
},
137149
{
@@ -143,9 +155,20 @@
143155
},
144156
{
145157
"cell_type": "code",
146-
"execution_count": null,
158+
"execution_count": 7,
147159
"metadata": {},
148-
"outputs": [],
160+
"outputs": [
161+
{
162+
"data": {
163+
"text/plain": [
164+
"True"
165+
]
166+
},
167+
"execution_count": 7,
168+
"metadata": {},
169+
"output_type": "execute_result"
170+
}
171+
],
149172
"source": [
150173
"from redis import Redis\n",
151174
"\n",
@@ -155,7 +178,7 @@
155178
},
156179
{
157180
"cell_type": "code",
158-
"execution_count": null,
181+
"execution_count": 8,
159182
"metadata": {},
160183
"outputs": [],
161184
"source": [
@@ -182,11 +205,26 @@
182205
},
183206
{
184207
"cell_type": "code",
185-
"execution_count": null,
208+
"execution_count": 9,
186209
"metadata": {},
187-
"outputs": [],
210+
"outputs": [
211+
{
212+
"name": "stdout",
213+
"output_type": "stream",
214+
"text": [
215+
"13:55:47 datasets INFO PyTorch version 2.3.0 available.\n",
216+
"13:55:48 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n",
217+
"13:55:48 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: sentence-transformers/all-MiniLM-L6-v2\n",
218+
"13:55:50 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n",
219+
"13:55:50 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: sentence-transformers/all-mpnet-base-v2\n",
220+
"13:55:51 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n",
221+
"13:55:51 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2\n"
222+
]
223+
}
224+
],
188225
"source": [
189226
"from redisvl.utils.vectorize import HFTextVectorizer\n",
227+
"from redisvl.extensions.cache.embeddings import EmbeddingsCache\n",
190228
"\n",
191229
"# Model 1: General purpose embeddings (what we used before)\n",
192230
"general_model = HFTextVectorizer(\n",
@@ -195,7 +233,7 @@
195233
" name=\"embedcache_general\",\n",
196234
" ttl=600,\n",
197235
" redis_client=client,\n",
198-
" )\n",
236+
" ),\n",
199237
" dtype=\"float64\"\n",
200238
")\n",
201239
"\n",
@@ -206,7 +244,7 @@
206244
" name=\"embedcache_movie\",\n",
207245
" ttl=600,\n",
208246
" redis_client=client,\n",
209-
" )\n",
247+
" ),\n",
210248
" dtype=\"float32\"\n",
211249
")\n",
212250
"\n",
@@ -217,7 +255,7 @@
217255
" name=\"embedcache_genre\",\n",
218256
" ttl=600,\n",
219257
" redis_client=client,\n",
220-
" )\n",
258+
" ),\n",
221259
" dtype=\"float32\"\n",
222260
")"
223261
]
@@ -234,9 +272,18 @@
234272
},
235273
{
236274
"cell_type": "code",
237-
"execution_count": null,
275+
"execution_count": 10,
238276
"metadata": {},
239-
"outputs": [],
277+
"outputs": [
278+
{
279+
"name": "stdout",
280+
"output_type": "stream",
281+
"text": [
282+
"Generating multiple embeddings for movies...\n",
283+
"Generated embeddings for 20 movies\n"
284+
]
285+
}
286+
],
240287
"source": [
241288
"# Generate multiple embeddings for each movie\n",
242289
"print(\"Generating multiple embeddings for movies...\")\n",
@@ -256,9 +303,18 @@
256303
},
257304
{
258305
"cell_type": "code",
259-
"execution_count": null,
306+
"execution_count": 12,
260307
"metadata": {},
261-
"outputs": [],
308+
"outputs": [
309+
{
310+
"name": "stdout",
311+
"output_type": "stream",
312+
"text": [
313+
"13:56:14 redisvl.index.index INFO Index already exists, overwriting.\n",
314+
"Multi-vector index created and populated successfully!\n"
315+
]
316+
}
317+
],
262318
"source": [
263319
"from redisvl.schema import IndexSchema\n",
264320
"from redisvl.index import SearchIndex\n",
@@ -336,13 +392,42 @@
336392
},
337393
{
338394
"cell_type": "code",
339-
"execution_count": null,
395+
"execution_count": 13,
340396
"metadata": {},
341-
"outputs": [],
397+
"outputs": [
398+
{
399+
"name": "stdout",
400+
"output_type": "stream",
401+
"text": [
402+
"1. The Incredibles \n",
403+
" Genre: comedy, Rating: 8\n",
404+
" Description: A family of undercover superheroes, while trying to live the quiet suburban life, are forced into ac...\n",
405+
"\n",
406+
"2. The Avengers \n",
407+
" Genre: action, Rating: 8\n",
408+
" Description: Earth's mightiest heroes come together to stop an alien invasion that threatens the entire planet....\n",
409+
"\n",
410+
"3. Mad Max: Fury Road \n",
411+
" Genre: action, Rating: 8\n",
412+
" Description: In a post-apocalyptic wasteland, Max teams up with Furiosa to escape a tyrant's clutches and find fr...\n",
413+
"\n",
414+
"4. John Wick \n",
415+
" Genre: action, Rating: 8\n",
416+
" Description: A retired hitman seeks vengeance against those who wronged him, leaving a trail of destruction in hi...\n",
417+
"\n",
418+
"5. The Dark Knight \n",
419+
" Genre: action, Rating: 9\n",
420+
" Description: Batman faces off against the Joker, a criminal mastermind who threatens to plunge Gotham into chaos....\n",
421+
"\n"
422+
]
423+
}
424+
],
342425
"source": [
343-
"from redisvl.query import Vector\n",
426+
"from redisvl.query import Vector, MultiVectorQuery\n",
344427
"query_text = \"action movie with superheroes and explosions\"\n",
345428
"\n",
429+
"num_results = 5\n",
430+
"\n",
346431
"# Create Vector objects for each embedding model\n",
347432
"query_vectors = [\n",
348433
" Vector(\n",
@@ -390,18 +475,18 @@
390475
},
391476
{
392477
"cell_type": "code",
393-
"execution_count": null,
478+
"execution_count": 14,
394479
"metadata": {},
395480
"outputs": [],
396481
"source": [
397482
"# clean up!\n",
398-
"index.delete()"
483+
"multi_vector_index.delete()"
399484
]
400485
}
401486
],
402487
"metadata": {
403488
"kernelspec": {
404-
"display_name": "redis-ai-res",
489+
"display_name": "3.11.9",
405490
"language": "python",
406491
"name": "python3"
407492
},

0 commit comments

Comments
 (0)