Skip to content

Commit 8c4d4f3

Browse files
committed
Update Redis 8.2.0+ installation for multivector search notebook
1 parent a28f05f commit 8c4d4f3

File tree

1 file changed

+148
-97
lines changed

1 file changed

+148
-97
lines changed

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

Lines changed: 148 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -121,44 +121,48 @@
121121
]
122122
},
123123
{
124-
"cell_type": "markdown",
125124
"metadata": {},
125+
"cell_type": "markdown",
126126
"source": [
127-
"### Install Redis Stack\n",
127+
"### Install Redis\n",
128128
"\n",
129129
"Later in this tutorial, Redis will be used to store, index, and query vector\n",
130130
"embeddings and full text fields. **We need to have a Redis\n",
131131
"instance available.**\n",
132132
"\n",
133133
"#### Local Redis\n",
134-
"Use the shell script below to download, extract, and install [Redis Stack](https://redis.io/docs/getting-started/install-stack/) directly from the Redis package archive."
134+
"Use the shell script below to download, extract, and install [Redis](https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/apt/) directly from the Redis package archive for a Linux environment."
135135
]
136136
},
137137
{
138-
"cell_type": "code",
139-
"execution_count": null,
140138
"metadata": {},
139+
"cell_type": "code",
141140
"outputs": [],
141+
"execution_count": 20,
142142
"source": [
143143
"# NBVAL_SKIP\n",
144144
"%%sh\n",
145+
"sudo apt-get install lsb-release curl gpg\n",
145146
"curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg\n",
147+
"sudo chmod 644 /usr/share/keyrings/redis-archive-keyring.gpg\n",
146148
"echo \"deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main\" | sudo tee /etc/apt/sources.list.d/redis.list\n",
147-
"sudo apt-get update > /dev/null 2>&1\n",
148-
"sudo apt-get install redis-stack-server > /dev/null 2>&1\n",
149-
"redis-stack-server --daemonize yes"
149+
"sudo apt-get update\n",
150+
"sudo apt-get install redis\n",
151+
"\n",
152+
"redis-server --version\n",
153+
"redis-server --daemonize yes --loadmodule /usr/lib/redis/modules/redisearch.so"
150154
]
151155
},
152156
{
153-
"cell_type": "markdown",
154157
"metadata": {},
158+
"cell_type": "markdown",
155159
"source": [
156160
"#### Alternative Redis Access (Cloud, Docker, other)\n",
157161
"There are many ways to get the necessary redis-stack instance running\n",
158162
"1. On cloud, deploy a [FREE instance of Redis in the cloud](https://redis.com/try-free/). Or, if you have your\n",
159163
"own version of Redis Enterprise running, that works too!\n",
160164
"2. Per OS, [see the docs](https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/)\n",
161-
"3. With docker: `docker run -d --name redis-stack-server -p 6379:6379 redis/redis-stack-server:latest`"
165+
"3. With docker: `docker run -d --name redis -p 6379:6379 redis:latest`"
162166
]
163167
},
164168
{
@@ -172,9 +176,12 @@
172176
},
173177
{
174178
"cell_type": "code",
175-
"execution_count": null,
176-
"metadata": {},
177-
"outputs": [],
179+
"metadata": {
180+
"ExecuteTime": {
181+
"end_time": "2025-12-09T15:24:43.601826Z",
182+
"start_time": "2025-12-09T15:24:43.599178Z"
183+
}
184+
},
178185
"source": [
179186
"import os\n",
180187
"\n",
@@ -185,7 +192,9 @@
185192
"\n",
186193
"# If SSL is enabled on the endpoint, use rediss:// as the URL prefix\n",
187194
"REDIS_URL = f\"redis://:{REDIS_PASSWORD}@{REDIS_HOST}:{REDIS_PORT}\""
188-
]
195+
],
196+
"outputs": [],
197+
"execution_count": 1
189198
},
190199
{
191200
"cell_type": "markdown",
@@ -196,38 +205,48 @@
196205
},
197206
{
198207
"cell_type": "code",
199-
"execution_count": 3,
200-
"metadata": {},
208+
"metadata": {
209+
"ExecuteTime": {
210+
"end_time": "2025-12-09T15:24:45.636539Z",
211+
"start_time": "2025-12-09T15:24:45.602099Z"
212+
}
213+
},
214+
"source": [
215+
"from redis import Redis\n",
216+
"\n",
217+
"client = Redis.from_url(REDIS_URL)\n",
218+
"client.ping()"
219+
],
201220
"outputs": [
202221
{
203222
"data": {
204223
"text/plain": [
205224
"True"
206225
]
207226
},
208-
"execution_count": 3,
227+
"execution_count": 2,
209228
"metadata": {},
210229
"output_type": "execute_result"
211230
}
212231
],
213-
"source": [
214-
"from redis import Redis\n",
215-
"\n",
216-
"client = Redis.from_url(REDIS_URL)\n",
217-
"client.ping()"
218-
]
232+
"execution_count": 2
219233
},
220234
{
221235
"cell_type": "code",
222-
"execution_count": 4,
223-
"metadata": {},
224-
"outputs": [],
236+
"metadata": {
237+
"ExecuteTime": {
238+
"end_time": "2025-12-09T15:24:48.003249Z",
239+
"start_time": "2025-12-09T15:24:47.998789Z"
240+
}
241+
},
225242
"source": [
226243
"import json\n",
227244
"\n",
228245
"with open(\"resources/movies.json\", 'r') as file:\n",
229246
" movies = json.load(file)"
230-
]
247+
],
248+
"outputs": [],
249+
"execution_count": 3
231250
},
232251
{
233252
"cell_type": "markdown",
@@ -246,23 +265,12 @@
246265
},
247266
{
248267
"cell_type": "code",
249-
"execution_count": 5,
250-
"metadata": {},
251-
"outputs": [
252-
{
253-
"name": "stdout",
254-
"output_type": "stream",
255-
"text": [
256-
"14:45:04 datasets INFO PyTorch version 2.3.0 available.\n",
257-
"14:45:05 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n",
258-
"14:45:05 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: sentence-transformers/all-MiniLM-L6-v2\n",
259-
"14:45:07 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n",
260-
"14:45:07 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: sentence-transformers/all-mpnet-base-v2\n",
261-
"14:45:08 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n",
262-
"14:45:08 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2\n"
263-
]
268+
"metadata": {
269+
"ExecuteTime": {
270+
"end_time": "2025-12-09T15:25:17.968696Z",
271+
"start_time": "2025-12-09T15:24:51.320769Z"
264272
}
265-
],
273+
},
266274
"source": [
267275
"from redisvl.utils.vectorize import HFTextVectorizer\n",
268276
"from redisvl.extensions.cache.embeddings import EmbeddingsCache\n",
@@ -299,7 +307,30 @@
299307
" ),\n",
300308
" dtype=\"float32\"\n",
301309
")"
302-
]
310+
],
311+
"outputs": [
312+
{
313+
"name": "stderr",
314+
"output_type": "stream",
315+
"text": [
316+
"/Users/vishal.bala/PycharmProjects/redis-ai-resources/.venv/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
317+
" from .autonotebook import tqdm as notebook_tqdm\n"
318+
]
319+
},
320+
{
321+
"name": "stdout",
322+
"output_type": "stream",
323+
"text": [
324+
"16:24:55 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n",
325+
"16:24:55 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: sentence-transformers/all-MiniLM-L6-v2\n",
326+
"16:24:58 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n",
327+
"16:24:58 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: sentence-transformers/all-mpnet-base-v2\n",
328+
"16:25:01 sentence_transformers.SentenceTransformer INFO Use pytorch device_name: mps\n",
329+
"16:25:01 sentence_transformers.SentenceTransformer INFO Load pretrained SentenceTransformer: sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2\n"
330+
]
331+
}
332+
],
333+
"execution_count": 4
303334
},
304335
{
305336
"cell_type": "markdown",
@@ -313,18 +344,12 @@
313344
},
314345
{
315346
"cell_type": "code",
316-
"execution_count": 6,
317-
"metadata": {},
318-
"outputs": [
319-
{
320-
"name": "stdout",
321-
"output_type": "stream",
322-
"text": [
323-
"Generating multiple embeddings for movies...\n",
324-
"Generated embeddings for 20 movies\n"
325-
]
347+
"metadata": {
348+
"ExecuteTime": {
349+
"end_time": "2025-12-09T15:25:27.857788Z",
350+
"start_time": "2025-12-09T15:25:24.034106Z"
326351
}
327-
],
352+
},
328353
"source": [
329354
"# Generate multiple embeddings for each movie\n",
330355
"print(\"Generating multiple embeddings for movies...\")\n",
@@ -340,21 +365,27 @@
340365
" multi_vector_movie_data.append(movie_with_vectors)\n",
341366
"\n",
342367
"print(f\"Generated embeddings for {len(multi_vector_movie_data)} movies\")"
343-
]
344-
},
345-
{
346-
"cell_type": "code",
347-
"execution_count": 7,
348-
"metadata": {},
368+
],
349369
"outputs": [
350370
{
351371
"name": "stdout",
352372
"output_type": "stream",
353373
"text": [
354-
"Multi-vector index created and populated successfully!\n"
374+
"Generating multiple embeddings for movies...\n",
375+
"Generated embeddings for 20 movies\n"
355376
]
356377
}
357378
],
379+
"execution_count": 5
380+
},
381+
{
382+
"cell_type": "code",
383+
"metadata": {
384+
"ExecuteTime": {
385+
"end_time": "2025-12-09T15:25:27.891696Z",
386+
"start_time": "2025-12-09T15:25:27.864579Z"
387+
}
388+
},
358389
"source": [
359390
"from redisvl.schema import IndexSchema\n",
360391
"from redisvl.index import SearchIndex\n",
@@ -411,7 +442,17 @@
411442
"# Load the multi-vector data\n",
412443
"multi_vector_index.load(multi_vector_movie_data)\n",
413444
"print(\"Multi-vector index created and populated successfully!\")"
414-
]
445+
],
446+
"outputs": [
447+
{
448+
"name": "stdout",
449+
"output_type": "stream",
450+
"text": [
451+
"Multi-vector index created and populated successfully!\n"
452+
]
453+
}
454+
],
455+
"execution_count": 6
415456
},
416457
{
417458
"cell_type": "markdown",
@@ -432,36 +473,12 @@
432473
},
433474
{
434475
"cell_type": "code",
435-
"execution_count": 8,
436-
"metadata": {},
437-
"outputs": [
438-
{
439-
"name": "stdout",
440-
"output_type": "stream",
441-
"text": [
442-
"1. The Incredibles \n",
443-
" Genre: comedy, Rating: 8\n",
444-
" Description: A family of undercover superheroes, while trying to live the quiet suburban life, are forced into ac...\n",
445-
"\n",
446-
"2. The Avengers \n",
447-
" Genre: action, Rating: 8\n",
448-
" Description: Earth's mightiest heroes come together to stop an alien invasion that threatens the entire planet....\n",
449-
"\n",
450-
"3. Mad Max: Fury Road \n",
451-
" Genre: action, Rating: 8\n",
452-
" Description: In a post-apocalyptic wasteland, Max teams up with Furiosa to escape a tyrant's clutches and find fr...\n",
453-
"\n",
454-
"4. John Wick \n",
455-
" Genre: action, Rating: 8\n",
456-
" Description: A retired hitman seeks vengeance against those who wronged him, leaving a trail of destruction in hi...\n",
457-
"\n",
458-
"5. The Dark Knight \n",
459-
" Genre: action, Rating: 9\n",
460-
" Description: Batman faces off against the Joker, a criminal mastermind who threatens to plunge Gotham into chaos....\n",
461-
"\n"
462-
]
476+
"metadata": {
477+
"ExecuteTime": {
478+
"end_time": "2025-12-09T15:25:31.125875Z",
479+
"start_time": "2025-12-09T15:25:30.346516Z"
463480
}
464-
],
481+
},
465482
"source": [
466483
"from redisvl.query import Vector, MultiVectorQuery\n",
467484
"query_text = \"action movie with superheroes and explosions\"\n",
@@ -503,7 +520,36 @@
503520
" print(f\" Genre: {result['genre']}, Rating: {result['rating']}\")\n",
504521
" print(f\" Description: {result['description'][:100]}...\")\n",
505522
" print()"
506-
]
523+
],
524+
"outputs": [
525+
{
526+
"name": "stdout",
527+
"output_type": "stream",
528+
"text": [
529+
"1. The Incredibles \n",
530+
" Genre: comedy, Rating: 8\n",
531+
" Description: A family of undercover superheroes, while trying to live the quiet suburban life, are forced into ac...\n",
532+
"\n",
533+
"2. The Avengers \n",
534+
" Genre: action, Rating: 8\n",
535+
" Description: Earth's mightiest heroes come together to stop an alien invasion that threatens the entire planet....\n",
536+
"\n",
537+
"3. Mad Max: Fury Road \n",
538+
" Genre: action, Rating: 8\n",
539+
" Description: In a post-apocalyptic wasteland, Max teams up with Furiosa to escape a tyrant's clutches and find fr...\n",
540+
"\n",
541+
"4. John Wick \n",
542+
" Genre: action, Rating: 8\n",
543+
" Description: A retired hitman seeks vengeance against those who wronged him, leaving a trail of destruction in hi...\n",
544+
"\n",
545+
"5. The Dark Knight \n",
546+
" Genre: action, Rating: 9\n",
547+
" Description: Batman faces off against the Joker, a criminal mastermind who threatens to plunge Gotham into chaos....\n",
548+
"\n"
549+
]
550+
}
551+
],
552+
"execution_count": 7
507553
},
508554
{
509555
"cell_type": "markdown",
@@ -515,13 +561,18 @@
515561
},
516562
{
517563
"cell_type": "code",
518-
"execution_count": 9,
519-
"metadata": {},
520-
"outputs": [],
564+
"metadata": {
565+
"ExecuteTime": {
566+
"end_time": "2025-12-09T15:25:33.245401Z",
567+
"start_time": "2025-12-09T15:25:33.242415Z"
568+
}
569+
},
521570
"source": [
522571
"# clean up!\n",
523572
"multi_vector_index.delete()"
524-
]
573+
],
574+
"outputs": [],
575+
"execution_count": 8
525576
}
526577
],
527578
"metadata": {

0 commit comments

Comments
 (0)