Skip to content

Commit f8578be

Browse files
committed
Multimodal capability
1 parent a312eb2 commit f8578be

File tree

10 files changed

+3942
-3171
lines changed

10 files changed

+3942
-3171
lines changed

docs/api/vectorizer.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,15 @@ VoyageAITextVectorizer
9696
.. autoclass:: VoyageAITextVectorizer
9797
:show-inheritance:
9898
:members:
99+
100+
101+
VoyageAIMultimodalVectorizer
102+
============================
103+
104+
.. _voyageaimultimodalvectorizer_api:
105+
106+
.. currentmodule:: redisvl.utils.vectorize.multimodal.voyageai
107+
108+
.. autoclass:: VoyageAIMultimodalVectorizer
109+
:show-inheritance:
110+
:members:

docs/user_guide/04_vectorizers.ipynb

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,7 @@
44
"attachments": {},
55
"cell_type": "markdown",
66
"metadata": {},
7-
"source": [
8-
"# Vectorizers\n",
9-
"\n",
10-
"In this notebook, we will show how to use RedisVL to create embeddings using the built-in text embedding vectorizers. Today RedisVL supports:\n",
11-
"1. OpenAI\n",
12-
"2. HuggingFace\n",
13-
"3. Vertex AI\n",
14-
"4. Cohere\n",
15-
"5. Mistral AI\n",
16-
"6. Amazon Bedrock\n",
17-
"7. Bringing your own vectorizer\n",
18-
"8. VoyageAI\n",
19-
"\n",
20-
"Before running this notebook, be sure to\n",
21-
"1. Have installed ``redisvl`` and have that environment active for this notebook.\n",
22-
"2. Have a running Redis Stack instance with RediSearch > 2.4 active.\n",
23-
"\n",
24-
"For example, you can run Redis Stack locally with Docker:\n",
25-
"\n",
26-
"```bash\n",
27-
"docker run -d -p 6379:6379 -p 8001:8001 redis/redis-stack:latest\n",
28-
"```\n",
29-
"\n",
30-
"This will run Redis on port 6379 and RedisInsight at http://localhost:8001."
31-
]
7+
"source": "# Vectorizers\n\nIn this notebook, we will show how to use RedisVL to create embeddings using the built-in text embedding vectorizers. Today RedisVL supports:\n1. OpenAI\n2. HuggingFace\n3. Vertex AI\n4. Cohere\n5. Mistral AI\n6. Amazon Bedrock\n7. Bringing your own vectorizer\n8. VoyageAI (text and multimodal)\n\nBefore running this notebook, be sure to\n1. Have installed ``redisvl`` and have that environment active for this notebook.\n2. Have a running Redis Stack instance with RediSearch > 2.4 active.\n\nFor example, you can run Redis Stack locally with Docker:\n\n```bash\ndocker run -d -p 6379:6379 -p 8001:8001 redis/redis-stack:latest\n```\n\nThis will run Redis on port 6379 and RedisInsight at http://localhost:8001."
328
},
339
{
3410
"cell_type": "code",
@@ -452,6 +428,30 @@
452428
"execution_count": null,
453429
"outputs": []
454430
},
431+
{
432+
"cell_type": "markdown",
433+
"source": "#### Multimodal Embeddings\n\nVoyageAI also offers multimodal embedding models that can embed text, images, and video together. The `VoyageAIMultimodalVectorizer` supports:\n- **Text strings** - Plain text descriptions\n- **PIL Images** - Image objects loaded with PIL/Pillow\n- **Image URLs** - URLs pointing to images\n- **Video** - Video files (voyage-multimodal-3.5 only, requires voyageai>=0.3.6)\n\nAvailable models:\n- `voyage-multimodal-3` - Text and images\n- `voyage-multimodal-3.5` - Text, images, and video",
434+
"metadata": {}
435+
},
436+
{
437+
"cell_type": "code",
438+
"source": "from redisvl.utils.vectorize import VoyageAIMultimodalVectorizer\nfrom PIL import Image\n\n# Create a multimodal vectorizer\nmultimodal_vo = VoyageAIMultimodalVectorizer(\n model=\"voyage-multimodal-3\",\n api_config={\"api_key\": api_key},\n)\n\n# Embed text only\ntext_embedding = multimodal_vo.embed(\n content=[\"A description of a sunset over the ocean\"],\n input_type=\"document\"\n)\nprint(f\"Text-only embedding dimensions: {len(text_embedding)}\")\n\n# Embed text with an image (uncomment to test with your own image)\n# image = Image.open(\"your_image.jpg\")\n# multimodal_embedding = multimodal_vo.embed(\n# content=[\"A photo showing a beautiful sunset\", image],\n# input_type=\"document\"\n# )\n# print(f\"Multimodal embedding dimensions: {len(multimodal_embedding)}\")\n\n# Batch embedding multiple contents\ncontents = [\n [\"First text description\"],\n [\"Second text description\"],\n [\"Third text description\"],\n]\nembeddings = multimodal_vo.embed_many(contents, input_type=\"document\")\nprint(f\"Generated {len(embeddings)} embeddings\")",
439+
"metadata": {},
440+
"execution_count": null,
441+
"outputs": []
442+
},
443+
{
444+
"cell_type": "markdown",
445+
"source": "#### Video Embeddings (voyage-multimodal-3.5)\n\nThe `voyage-multimodal-3.5` model supports video inputs in addition to text and images. Videos must be loaded using VoyageAI's `Video` utility class.\n\n**Requirements:**\n- Model: `voyage-multimodal-3.5` only\n- Package: `voyageai>=0.3.6`\n- Max video size: 20 MB",
446+
"metadata": {}
447+
},
448+
{
449+
"cell_type": "code",
450+
"source": "# Video embedding example (uncomment to test with your own video)\n# from voyageai.video_utils import Video\n# \n# # Create vectorizer with video-capable model\n# video_vo = VoyageAIMultimodalVectorizer(\n# model=\"voyage-multimodal-3.5\",\n# api_config={\"api_key\": api_key},\n# )\n# \n# # Load video using VoyageAI's Video utility\n# video = Video.from_path(\"your_video.mp4\", model=\"voyage-multimodal-3.5\")\n# \n# # Embed video with text description\n# video_embedding = video_vo.embed(\n# content=[\"A video showing a cat playing with a toy\", video],\n# input_type=\"document\"\n# )\n# print(f\"Video embedding dimensions: {len(video_embedding)}\")",
451+
"metadata": {},
452+
"execution_count": null,
453+
"outputs": []
454+
},
455455
{
456456
"cell_type": "markdown",
457457
"metadata": {},

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ mistralai = ["mistralai>=1.0.0"]
3737
openai = ["openai>=1.1.0"]
3838
nltk = ["nltk>=3.8.1,<4"]
3939
cohere = ["cohere>=4.44"]
40-
voyageai = ["voyageai>=0.3.5"]
40+
voyageai = ["voyageai>=0.3.6"]
4141
sentence-transformers = ["sentence-transformers>=3.4.0,<4"]
4242
langcache = ["langcache>=0.9.0"]
4343
vertexai = [

redisvl/utils/vectorize/__init__.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
from typing import Optional
33

44
from redisvl.extensions.cache.embeddings import EmbeddingsCache
5-
from redisvl.utils.vectorize.base import BaseVectorizer, Vectorizers
5+
from redisvl.utils.vectorize.base import (
6+
BaseMultimodalVectorizer,
7+
BaseVectorizer,
8+
Vectorizers,
9+
)
10+
from redisvl.utils.vectorize.multimodal.voyageai import VoyageAIMultimodalVectorizer
611
from redisvl.utils.vectorize.text.azureopenai import AzureOpenAITextVectorizer
712
from redisvl.utils.vectorize.text.bedrock import BedrockTextVectorizer
813
from redisvl.utils.vectorize.text.cohere import CohereTextVectorizer
@@ -14,16 +19,21 @@
1419
from redisvl.utils.vectorize.text.voyageai import VoyageAITextVectorizer
1520

1621
__all__ = [
22+
# Base classes
1723
"BaseVectorizer",
24+
"BaseMultimodalVectorizer",
25+
# Text vectorizers
26+
"AzureOpenAITextVectorizer",
27+
"BedrockTextVectorizer",
1828
"CohereTextVectorizer",
29+
"CustomTextVectorizer",
1930
"HFTextVectorizer",
31+
"MistralAITextVectorizer",
2032
"OpenAITextVectorizer",
2133
"VertexAITextVectorizer",
22-
"AzureOpenAITextVectorizer",
23-
"MistralAITextVectorizer",
24-
"CustomTextVectorizer",
25-
"BedrockTextVectorizer",
2634
"VoyageAITextVectorizer",
35+
# Multimodal vectorizers
36+
"VoyageAIMultimodalVectorizer",
2737
]
2838

2939

0 commit comments

Comments
 (0)