Support interleaved text and image input in VoyageAIVectorizer

未关闭
#885 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 4 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
ai, backend

调研方向

Start with redisvl/utils/vectorize/base.py for input validation, cache serialization, and sync/async entry points, then read redisvl/utils/vectorize/voyageai.py for Voyage request construction. Check the existing vectorizer tests and add coverage for validation, cache key ordering, request shape, unsupported models, and sync/async embedding; the issue also names docs/user_guide/04_vectorizers.ipynb and docs/api/vectorizer.rst. Done means the wrapper is exported, supported Voyage models produce one vector per mixed input, and the documented tests and examples are covered.

由索引模型根据 Issue 内容生成。

描述

Summary

Add a way to embed one input made of ordered text and image parts and get one vector for it. This is the request left open by #260. #452 added image and video embedding, one modality per input.

The first implementation targets VoyageAIVectorizer. The input type and the base-class plumbing are general, so other vectorizers can opt in later.

Current state

  • embed() and embed_many() treat every item as one modality (str, PIL.Image.Image, Path or Voyage Video), and each item gets its own vector.
  • VoyageAIVectorizer._embed_many wraps every item as a single-part input, [[item] for item in batch] (redisvl/utils/vectorize/voyageai.py:486-492). Voyage's multimodal_embed accepts several parts per input, but RedisVL has no way to pass them.
  • BaseVectorizer._serialize_for_cache (base.py:581) handles only single items.

Provider landscape

Checked against provider documentation on 2026-12-02.

Provider / model One vector for mixed text and image input?
Voyage voyage-multimodal-3.5 Yes. Each entry in inputs is an ordered list of parts, and the docs call this interleaved. The limit is 32,000 tokens per input, with images counted by pixel area.
Google gemini-embedding-2 Yes. Several parts in one contents are aggregated into one vector. Up to 6 images and 8,192 tokens per request. GoogleGenAIVectorizer is text-only today.
Cohere embed-v5.0-pro / Embed v4.0 Yes for v5, shown in the docs (inputs=[{"content": [...parts]}]). v4.0 is listed as supporting mixed input, but the docs show no request example for it. CohereTextVectorizer is text-only today.
Amazon Titan Multimodal G1 One vector, but it is the average of separately computed text and image embeddings, not a joint encoding. One image and 256 text tokens per request.
Amazon Nova Multimodal Embeddings No. Exactly one modality per request.
OpenAI text-embedding-3-* No. Text only.

Design

Input type

Add a public, immutable wrapper, exported from redisvl.utils.vectorize:

MultimodalInput(parts=["A ripe banana", Image.open("banana.jpg")])
  • parts is an ordered, non-empty sequence of str and PIL.Image.Image. Empty strings, nested MultimodalInput values and any other type raise TypeError at construction.
  • Part order is meaningful. It changes the embedding and the cache key.
  • A MultimodalInput is a single item. It goes wherever one item goes today: embed(content=...), aembed(), and as an element of embed_many() / aembed_many(), mixed freely with plain items.
vec = vz.embed(MultimodalInput(["A ripe banana", Image.open("banana.jpg")]))
vecs = vz.embed_many([
    MultimodalInput(["caption", img1]),
    "plain text",
    img2,
])
Vectorizer support
  • BaseVectorizer gains a capability flag, for example a supports_multimodal_input property that is False by default.
  • embed, embed_many and their async forms check it before the cache lookup and the provider call. An unsupported vectorizer raises a TypeError naming the vectorizer and the model.
  • VoyageAIVectorizer returns True when is_multimodal, and False for text and contextualised models.
  • In _embed_many / _aembed_many, a MultimodalInput is sent as list(item.parts) and a plain item keeps being sent as [item], so the request shape for existing calls does not change. _validate_input accepts MultimodalInput items.
  • Batching stays item-count based for multimodal models, as it is today.
Cache key

_serialize_for_cache serialises a MultimodalInput to deterministic bytes. The bytes start with a format marker, then each part as a type tag, a length and its payload (UTF-8 for text, PNG bytes for images, matching the existing image handling). The same parts in the same order give the same key, and reordered parts give a different key.

preprocess

preprocess is still applied to the item passed in, so it receives the MultimodalInput as a whole. No per-part hook.

Out of scope

  • Video, audio and PDF parts. Voyage Video stays supported as a plain item, but not inside a MultimodalInput.
  • Mixed input for Gemini, Cohere and Bedrock. The capability flag is the extension point for them.
  • Titan Multimodal G1. Its averaged vector isn't the joint encoding this feature describes.
  • Client-side token or image limits. Provider errors keep surfacing as they do today.
  • Any change to how existing single items are embedded or cached.

Definition of done

  • MultimodalInput is exported from redisvl.utils.vectorize, with validation as described.
  • VoyageAIVectorizer returns one vector per MultimodalInput, sync and async, alone or mixed with plain items in embed_many.
  • Unsupported vectorizers raise a clear TypeError before any cache or provider call.
  • Unit tests cover:
    • MultimodalInput validation;
    • cache-key determinism and order sensitivity;
    • the request shape sent to a mocked Voyage client, for a MultimodalInput and for a plain item side by side;
    • the unsupported-vectorizer error.
  • An integration test against voyage-multimodal-3.5, marked to run only with API tests.
  • Docs: a mixed-input example in the vectorizers guide (docs/user_guide/04_vectorizers.ipynb, marked # NBVAL_SKIP because it calls the API) and in the docs/api/vectorizer.rst reference.

References

主要语言
Python
星标
435
派生
123
平均合并
8 天 1 小时
30 天内合并 PR
39

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

redis/redis-vl-python 的其他 Issue

查看 redis/redis-vl-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。