ITADN

[Bug]: Gemini Embedding 2 -> unable to create multiple embeddings in one embedding call

#2721Closedjoelkartoon 创建于 2026-03-11
J
joelkartooncommented
### File Name gemini/embedding/intro_gemini_embedding.ipynb ### What happened? In the `gemini/embedding/intro_gemini_embedding.ipynb` notebook, you say: > On the other hand, this example creates multiple embeddings in one embedding call: ``` result = client.models.embed_content( model=MODEL_ID, contents=[ "the cookies are delicious", types.Part.from_bytes( data=image_bytes, mime_type="image/png", ), ], ) # This produces two embeddings for embedding in result.embeddings: print(embedding.values) ``` That said when I try out the code I only get 1 embedding. I am curious about using the `Gemini Embedding 2` model to do batch embeddings. The previous model was able to handle 250 embeddings at a time. Does the same expectation still hold? Thanks for your help ### Relevant log output ```shell client = genai.Client( vertexai=True, project=get_config().GOOGLE_VERTEX_PROJECT_ID, location="us-central1", ) result = client.models.embed_content( model="gemini-embedding-2-preview", contents=[ "the cookies are delicious", "the cookies are delicious", "the cookies are delicious", "the cookies are delicious", "the cookies are delicious", "the cookies are delicious", "the cookies are delicious", "the cookies are delicious", "the cookies are delicious", "the cookies are delicious", types.Part.from_bytes( data=image_bytes, mime_type="image/png", ), ], ) # This produces two embeddings for embedding in result.embeddings: print(embedding.values) # only 1 row is printed print(f"len(result.embeddings): {len(result.embeddings)}") # prints: len(result.embeddings): 1 ``` ### Code of Conduct - [x] I agree to follow this project's Code of Conduct
关闭于 2026-03-11 5 条评论