[GH-ISSUE #3656] [langchain]: The batch method of GoogleGenerativeAIEmbeddings should only returns one vector for "gemini-embedding-2-preview" #2746

Open
opened 2026-06-05 17:26:36 -04:00 by yindo · 1 comment
Owner

Originally created by @zjxjwxk on GitHub (Apr 21, 2026).
Original GitHub issue: https://github.com/langchain-ai/docs/issues/3656

Type of issue

issue / bug

Language

Python

Description

The embed_documents method of GoogleGenerativeAIEmbeddings only returns one vector for multiple inputs when using the model "gemini-embedding-2-preview".

In the Batch section of the GoogleGenerativeAIEmbeddings integration documentation.
The following Python code should print 1, but not 3:

embeddings = GoogleGenerativeAIEmbeddings(model="gemini-embedding-2-preview")
vectors = embeddings.embed_documents(
    [
        "Today is Monday",
        "Today is Tuesday",
        "Today is April Fools day",
    ]
)
print(len(vectors))

This note can be found at Embeddings of Google GenAI SDK:

"Note: Gemini Embedding 2 creates an aggregated embedding for multiple inputs. See Embedding aggregation for more details."

Originally created by @zjxjwxk on GitHub (Apr 21, 2026). Original GitHub issue: https://github.com/langchain-ai/docs/issues/3656 ### Type of issue issue / bug ### Language Python ### Description The `embed_documents` method of `GoogleGenerativeAIEmbeddings` only returns one vector for multiple inputs when using the model "gemini-embedding-2-preview". In the [Batch](https://docs.langchain.com/oss/python/integrations/embeddings/google_generative_ai#batch) section of the [GoogleGenerativeAIEmbeddings integration](https://docs.langchain.com/oss/python/integrations/embeddings/google_generative_ai) documentation. The following Python code should print 1, but not 3: ```Python embeddings = GoogleGenerativeAIEmbeddings(model="gemini-embedding-2-preview") vectors = embeddings.embed_documents( [ "Today is Monday", "Today is Tuesday", "Today is April Fools day", ] ) print(len(vectors)) ``` This note can be found at [Embeddings](https://ai.google.dev/gemini-api/docs/embeddings#generate-embeddings) of [Google GenAI SDK](https://ai.google.dev/gemini-api/docs): > "Note: Gemini Embedding 2 creates an aggregated embedding for multiple inputs. See [Embedding aggregation](https://ai.google.dev/gemini-api/docs/embeddings#embedding-aggregation) for more details."
yindo added the langchainexternal labels 2026-06-05 17:26:36 -04:00
Author
Owner

@riteshhh2024 commented on GitHub (Apr 30, 2026):

Hi maintainers, I’d like to work on this as my first contribution.

My understanding:

  • The current GoogleGenerativeAIEmbeddings documentation may imply that batching multiple texts with gemini-embedding-2-preview returns one embedding per input.
  • However, for gemini-embedding-2-preview, multiple inputs can produce a single aggregated embedding, so the current example may be misleading.

My proposed approach:

  • Update the GoogleGenerativeAIEmbeddings documentation to clarify this behavior.
  • Add a short note near the batch/example section explaining that gemini-embedding-2-preview may return one aggregated embedding for multiple inputs.
  • Keep the change limited to documentation unless maintainers prefer a code change.

Could you please confirm whether this docs-only approach is acceptable?

<!-- gh-comment-id:4351556753 --> @riteshhh2024 commented on GitHub (Apr 30, 2026): Hi maintainers, I’d like to work on this as my first contribution. My understanding: - The current GoogleGenerativeAIEmbeddings documentation may imply that batching multiple texts with `gemini-embedding-2-preview` returns one embedding per input. - However, for `gemini-embedding-2-preview`, multiple inputs can produce a single aggregated embedding, so the current example may be misleading. My proposed approach: - Update the GoogleGenerativeAIEmbeddings documentation to clarify this behavior. - Add a short note near the batch/example section explaining that `gemini-embedding-2-preview` may return one aggregated embedding for multiple inputs. - Keep the change limited to documentation unless maintainers prefer a code change. Could you please confirm whether this docs-only approach is acceptable?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/docs#2746