GoogleGenAIVectorizer.embed_many fails on gemini-embedding-2 for batches of more than one input
Los mantenedores suelen responder en 4 días
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- machine-learning
Línea de trabajo
Start with redisvl/utils/vectorize/googlegenai.py, especially _embed_many, _aembed_many, and _embeddings_from_response; the issue also specifies mocked sync and async tests. Check the open pull request #892 before taking this on. Done means batches send one Content per input and return one vector per input for both models.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
GoogleGenAIVectorizer.embed_many() and aembed_many() fail on gemini-embedding-2 whenever a batch holds more than one string. The model merges every entry in a contents list into one vector, so the vectorizer gets one embedding back for N inputs and raises.
Reproduction
from redisvl.utils.vectorize import GoogleGenAIVectorizer
vz = GoogleGenAIVectorizer(model="gemini-embedding-2", api_config={"api_key": "..."})
vz.embed_many(["The cat sat on the mat.", "Paris is in France."])
# ValueError: Google GenAI API returned 1 embedding(s) for 2 input(s).
embed() and aembed() with a single string are unaffected, as is gemini-embedding-001.
Cause
_embed_many and _aembed_many send each batch as contents=batch, a list of strings (redisvl/utils/vectorize/googlegenai.py:336 and :376). _embeddings_from_response then checks that the count matches.
The API treats a list of strings differently per model. We measured this on the Gemini API on 2026-12-02 with google-genai 1.75.0:
contents for three inputs |
gemini-embedding-001 |
gemini-embedding-2 |
|---|---|---|
["a", "b", "c"] |
3 vectors | 1 vector |
[Content(parts=[a]), Content(parts=[b]), Content(parts=[c])] |
3 vectors | 3 vectors |
Google's embeddings docs describe the same thing: on gemini-embedding-2, several parts in one request are aggregated into one embedding.
Fix
Wrap each input in its own types.Content in _embed_many and _aembed_many. This gives one vector per input on both models, and for gemini-embedding-001 it keeps the current one-vector-per-string result.
Tests
- A unit test with a mocked client asserting that each batch is sent as one
Contentper input, sync and async. - An integration test, marked as an API test, running
embed_manyongemini-embedding-2with more than one input.
We have not checked the Vertex AI backend. It uses the same embed_content call, so it is expected to behave the same.
- Lenguaje dominante
- Python
- Estrellas
- 435
- Forks
- 123
- Merge medio
- 8 d 1 h
- PR fusionados (30 d)
- 39
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de redis/redis-vl-python
-
SearchIndex.drop_keys does not validate cluster hash-tag co-location (inconsistent with drop_documents)Posiblemente ocupada @Hashim1999164 la tomó hace 47 días. Abiertobug good first issue index
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
redis/redis-vl-python#601 · 2 comentarios ·
Los mantenedores suelen responder en 4 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
redis/redis-vl-python#889 ·
Los mantenedores suelen responder en 4 días
-
Add image embedding to the Cohere vectorizer (Embed v4 and v5)Posiblemente ocupada @rahulsjha la tomó hace 1 día. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 58/100
redis/redis-vl-python#888 · 2 comentarios ·
Los mantenedores suelen responder en 4 días
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 38/100
redis/redis-vl-python#887 ·
Los mantenedores suelen responder en 4 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
redis/redis-vl-python#885 ·
Los mantenedores suelen responder en 4 días
Todos los issues de redis/redis-vl-python
Issues similares
-
[Resource]: SpaicelyAbiertoresource-submission validation-passed
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
hesreallyhim/awesome-claude-code#3875 · 1 comentario ·
-
[Bug]: Ajax Pro login issueAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
bvis/aegis-hass#725 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
datasektionen/cashflow#468 ·
-
dont call alembic upgrade until we check whether or not the cache DB has an alembic version stampAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Bug: AttributeError: 'GptOssConfig' object has no attribute 'rope_scaling_factor' with transformers >= 5.xPosiblemente ocupada @NimaVaziri la tomó hoy. AbiertoPytorch
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NVIDIA/TensorRT-LLM#23406 ·
Los mantenedores suelen responder en 1 día