Add image and video embedding to GoogleGenAIVectorizer with gemini-embedding-2

Aperta
#887 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
38/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
google-cloud, python

Direzione di ricerca

Read the GoogleGenAIVectorizer implementation, its tests, docs/api/vectorizer.rst, and the vectorizers guide; compare the existing VertexAIVectorizer helpers and the fix for #886. Start by checking how the Gemini and Vertex clients build embedding requests, then cover image, video, Part, caching, model capability, and the task type warning in sync and async paths. Done means both backends meet the listed unit and API test requirements and the migration docs point to GoogleGenAIVectorizer.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

Give GoogleGenAIVectorizer image and video input on gemini-embedding-2, on both the Gemini API and Vertex AI backends. This makes it the replacement for the multimodal path of the deprecated VertexAIVectorizer. Once #885 merges, also accept MultimodalInput, since gemini-embedding-2 turns several parts into one vector.

Depends on #885 for the MultimodalInput part and builds on the fix for #886. The single-modality work does not depend on #885.

Current state

  • GoogleGenAIVectorizer is text-only. _validate_many rejects anything but str.
  • embed_many on gemini-embedding-2 fails for batches of more than one input (#886), because a list of strings in contents is merged into one vector.
  • The only image and video route to Google models is VertexAIVectorizer with multimodalembedding@001. It uses the deprecated vertexai.vision_models SDK, which Google scheduled for removal in June 2026. pyproject.toml keeps google-cloud-aiplatform pinned because that multimodal path "has no google-genai replacement yet".
  • The docs/api/vectorizer.rst note for VertexAIVectorizer says the multimodal migration is tracked in #620. #620 is closed, and the migration it delivered was text-only.

Provider facts

From Google's docs, checked 2026-12-02:

  • Each part is text, or inline image or video bytes with a MIME type. Several parts in one Content give one vector, and one Content per input gives one vector per input.
  • Limits are per request:
    • 8,192 tokens in total, silently truncated beyond that;
    • 6 images (JPEG, PNG, WebP, BMP, HEIC, HEIF, AVIF);
    • 1 video (MP4 or MOV, up to 120 s / 120 frames).
  • The docs say task_type is not supported on gemini-embedding-2 and that task instructions belong in the text.
  • Dimensions: 3072 by default, and output_dimensionality accepts 128 to 3072.

Measured on the Gemini API on 2026-12-02 with google-genai 1.75.0:

  • One Content holding a text part and an image part gives 1 vector, and two Content objects give 2.
  • gemini-embedding-2 accepts task_type=RETRIEVAL_QUERY without an error. Its effect is unknown.

Design

  • Accepted items: str, PIL.Image.Image, Path to an image, and google.genai.types.Part as a passthrough for anything else the SDK supports. Add embed_image(path) and embed_video(path) helpers with the same names and behaviour as VertexAIVectorizer and VoyageAIVectorizer.
  • Request shape: one types.Content per item, as in the fix for #886. With #885, a MultimodalInput becomes one Content with one part per element.
  • Model capability: image, video and MultimodalInput items need a multimodal model. For now that is a model name starting with gemini-embedding-2. Other models raise TypeError before any API call.
  • task_type: if task_type is set with gemini-embedding-2, log a warning that the docs say it has no effect on this model and that instructions belong in the text. Do not raise, because the API accepts it.
  • Cache key: extend _serialize_for_cache to Part objects (MIME type plus bytes) and video bytes.
  • Docs: point the VertexAIVectorizer deprecation note at GoogleGenAIVectorizer for multimodal use.

Out of scope

  • Audio and PDF parts.
  • Removing VertexAIVectorizer or the google-cloud-aiplatform pin.
  • Video longer than the per-request limit (no client-side chunking).

Definition of done

  • Images and videos embed on gemini-embedding-2 through both backends, sync and async, as single items and inside embed_many.
  • After #885, MultimodalInput returns one vector, and supports_multimodal_input is True only for multimodal models.
  • Unit tests:
    • the request shape sent to a mocked client for image, video and Part items;
    • rejection by model capability;
    • the task_type warning;
    • cache keys for Part and video items.
  • Integration tests marked as API tests.
  • Docs updated in docs/api/vectorizer.rst and the vectorizers guide.

References

Lingua principale
Python
Stelle
435
Fork
123
Merge medio
8g 1h
PR unite (30g)
39

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di redis/redis-vl-python

Tutte le issue di redis/redis-vl-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.