GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update model name to gemini-embedding-001 in code snipets by Feiyang1 · Pull Request #13388 · GoogleCloudPlatform/python-docs-samples

Conversation

@Feiyang1

@Feiyang1 Feiyang1 commented May 23, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Description

Fixes #

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

Checklist

  • I have followed Sample Guidelines from AUTHORING_GUIDE.MD
  • README is updated to include all relevant information
  • Tests pass: nox -s py-3.9 (see Test Environment Setup)
  • Lint pass: nox -s lint (see Test Environment Setup)
  • These samples need a new API enabled in testing projects to pass (let us know which ones)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Feiyang1
Update model name to gemini-embedding-001 in code snipets
cf33c74
@Feiyang1
Feiyang1 requested review from a team as code owners May 23, 2025 23:40
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label May 23, 2025
@blunderbuss-gcf blunderbuss-gcf Bot assigned iennae May 23, 2025
gemini-code-assist[bot]
gemini-code-assist Bot reviewed May 23, 2025
View reviewed changes

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @Feiyang1, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

Hello everyone, gemini-code-assist here to provide a summary of this pull request. The primary intent of this PR, as indicated by the title and changes, is to update the model names used in several embedding code snippets within the generative_ai/embeddings directory. Specifically, it replaces older model identifiers with the newer gemini-embedding-001 model name to ensure the examples are current and use the recommended model.

Highlights

  • Model Name Update: This pull request updates the model name used for text embeddings in several example files from older versions (textembedding-gecko@003 and text-embedding-005) to the gemini-embedding-001 model.

Changelog

  • generative_ai/embeddings/batch_example.py
    • Updated the model name from textembedding-gecko@003 to gemini-embedding-001 when loading the TextEmbeddingModel on line 42.
  • generative_ai/embeddings/code_retrieval_example.py
    • Updated the default MODEL_NAME constant from text-embedding-005 to gemini-embedding-001 on line 20.
    • Updated the default model_name parameter in the embed_text function from text-embedding-005 to gemini-embedding-001 on line 27.
  • generative_ai/embeddings/document_retrieval_example.py
    • Updated the model name from text-embedding-005 to gemini-embedding-001 when loading the TextEmbeddingModel on line 35.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Old model name fades,
New Gemini shines so bright,
Examples updated.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
gemini-code-assist[bot]
gemini-code-assist Bot suggested changes May 23, 2025
View reviewed changes

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This PR updates the embedding model name to gemini-embedding-001 across several example files. The changes are clear, concise, and directly address the stated goal. Thank you for making these updates!

My main feedback revolves around ensuring that gemini-embedding-001 is fully compatible with the existing parameters and usage patterns in these examples (such as task types and output_dimensionality). I've added specific comments in the files regarding this verification, as this is crucial for the correctness and utility of these samples.

Additionally, I noticed that several items in the PR checklist (like confirming tests pass and linting) are not yet marked as completed. Ensuring these checks are performed would increase confidence in the changes before merging.

Overall, the code modifications themselves are straightforward. Addressing the compatibility verification would be key.

Summary of Findings

  • Model Compatibility Verification: The primary concern raised is the need to verify that the new gemini-embedding-001 model is fully compatible with existing parameters (e.g., task types like CODE_RETRIEVAL_QUERY, RETRIEVAL_DOCUMENT; output_dimensionality=256) and usage patterns (e.g., batch_predict method, behavior of TextEmbeddingModel.from_pretrained) in the updated examples. This verification is crucial to ensure the correctness, effectiveness, and reliability of the code samples.
  • PR Checklist Completion: It was noted that several items in the PR checklist, such as test execution and linting, were not marked as completed. Completing these standard checks would enhance confidence in the proposed changes.

Merge Readiness

While the code changes to update the model name are simple and correctly implemented, I recommend REQUEST_CHANGES at this time. This is primarily to ensure that the compatibility of the new gemini-embedding-001 model with the existing example code (parameters, task types, expected outputs, API usage) is thoroughly verified, as detailed in the review comments. Once this verification is confirmed and other checklist items (like tests and linting) are addressed, the PR should be in good shape for merging. As a reviewer, I am not authorized to approve the PR directly; further review and approval by authorized personnel will be needed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread generative_ai/embeddings/batch_example.py

textembedding_model = language_models.TextEmbeddingModel.from_pretrained(
"textembedding-gecko@003"
"gemini-embedding-001"

@gemini-code-assist gemini-code-assist Bot May 23, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The model is updated to gemini-embedding-001. This is a key change. Could you please confirm if this new model has been verified for full compatibility with the existing usage patterns in this and other updated examples?

Specifically for the examples touched in this PR:

  • Are the task types used in code_retrieval_example.py (CODE_RETRIEVAL_QUERY, RETRIEVAL_DOCUMENT) and document_retrieval_example.py (RETRIEVAL_DOCUMENT) supported and appropriate for gemini-embedding-001?
  • Is the output_dimensionality=256 (used in code_retrieval_example.py and document_retrieval_example.py) a valid, supported, and optimal setting for gemini-embedding-001?
  • Does gemini-embedding-001 (when used via TextEmbeddingModel.from_pretrained) behave as expected with the batch_predict method and the input/output formats used in this specific batch_example.py file?

Ensuring these compatibilities are verified is important for the correctness and reliability of these samples. If the new model has different characteristics or requirements, further code adjustments might be needed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread generative_ai/embeddings/code_retrieval_example.py
from vertexai.language_models import TextEmbeddingInput, TextEmbeddingModel

MODEL_NAME = "text-embedding-005"
MODEL_NAME = "gemini-embedding-001"

@gemini-code-assist gemini-code-assist Bot May 23, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

With MODEL_NAME now set to gemini-embedding-001, it's important to ensure this model works correctly with the parameters used in this example. Specifically, have the task types (CODE_RETRIEVAL_QUERY and RETRIEVAL_DOCUMENT, as used in the if __name__ == "__main__" block) and the default dimensionality=256 been verified for compatibility and optimal performance with gemini-embedding-001?

Different models can have varying support for task types or optimal dimensionalities, so confirming this would help ensure the example remains accurate and effective.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread generative_ai/embeddings/code_retrieval_example.py
texts: list[str] = ["Retrieve a function that adds two numbers"],
task: str = "CODE_RETRIEVAL_QUERY",
model_name: str = "text-embedding-005",
model_name: str = "gemini-embedding-001",

@gemini-code-assist gemini-code-assist Bot May 23, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The default model_name in the embed_text function signature is also updated to gemini-embedding-001. This is consistent with the MODEL_NAME constant change. The same verification question applies here: has this default been confirmed to work well with the function's other default parameters (like task and dimensionality) when using gemini-embedding-001?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread generative_ai/embeddings/document_retrieval_example.py
task = "RETRIEVAL_DOCUMENT"

model = TextEmbeddingModel.from_pretrained("text-embedding-005")
model = TextEmbeddingModel.from_pretrained("gemini-embedding-001")

@gemini-code-assist gemini-code-assist Bot May 23, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Updating the model to gemini-embedding-001 here is consistent with the other changes. As with the other files, could you confirm if the task = "RETRIEVAL_DOCUMENT" and dimensionality = 256 settings have been verified as compatible and appropriate for gemini-embedding-001? This verification is key to ensuring the example functions correctly and demonstrates best practices with the new model.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Feiyang1
update to max 3072 dim
1c31328
iennae
iennae approved these changes May 24, 2025
View reviewed changes
@glasnt glasnt added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 26, 2025
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 26, 2025
@glasnt

glasnt commented May 26, 2025

Copy link
Copy Markdown
Contributor

Unable to submit request because batchSize must be 1 but the entered value was 3.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@glasnt glasnt added the waiting-response Waiting for the author's response. label May 26, 2025
@Feiyang1
Update examples to process one input at a time
48b1046
@Feiyang1

Feiyang1 commented May 27, 2025

Copy link
Copy Markdown
Contributor Author

Unable to submit request because batchSize must be 1 but the entered value was 3.

I'm glad we have tests to catch errors in code snippets. Updated the code and test.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Feiyang1

Feiyang1 commented May 27, 2025

Copy link
Copy Markdown
Contributor Author

@skarukas ptal

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@glasnt glasnt added kokoro:force-run Add this label to force Kokoro to re-run the tests. and removed waiting-response Waiting for the author's response. labels May 27, 2025
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 27, 2025
glasnt
glasnt reviewed May 27, 2025
View reviewed changes
Comment thread generative_ai/embeddings/code_retrieval_example.py Outdated

embeddings = []
# gemini-embedding-001 takes one input at a time
for text in texts:

@glasnt glasnt May 27, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is failing linting and tests due to the extra space. I don't seem to be able to suggest the edit to fix this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Feiyang1 Feiyang1 May 27, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
glasnt
glasnt reviewed May 27, 2025
View reviewed changes
Comment thread generative_ai/embeddings/document_retrieval_example.py Outdated
@@ -35,12 +35,18 @@ def embed_text() -> list[list[float]]:
model = TextEmbeddingModel.from_pretrained("gemini-embedding-001")
inputs = [TextEmbeddingInput(text, task) for text in texts]

@glasnt glasnt May 27, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is unused and is failing linting.
You're constructing text_input later for each item in the for loop, so this variable should be removed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Feiyang1 Feiyang1 May 27, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Feiyang1
Fix indentation and unused variable
41e3221
@glasnt glasnt added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 28, 2025
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 28, 2025
@Feiyang1
remove unused variable
e6b2843
glasnt
glasnt reviewed May 28, 2025
View reviewed changes
Comment thread generative_ai/embeddings/code_retrieval_example.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@glasnt
correct linting issue
62b985c
@glasnt
glasnt merged commit 800c162 into GoogleCloudPlatform:main May 28, 2025
@zeevox

zeevox commented May 29, 2025

Copy link
Copy Markdown

Hi, I tried running the batch embedding sample in generative_ai/embeddings/batch_example.py, but I get an error 400 with the message Do not support publisher model gemini-embedding-001 - does gemini-embedding-001 actually support batch embedding (yet?)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gemini-code-assist

gemini-code-assist Bot commented May 29, 2025

Copy link
Copy Markdown
Contributor

Hi @zeevox, thanks for reporting this issue.

The error message Do not support publisher model gemini-embedding-001 indeed suggests that the gemini-embedding-001 model does not currently support the batch prediction method used in the batch_example.py sample.

This pull request updated the model name in several embedding examples, including batch_example.py, to gemini-embedding-001. While the PR author fixed a previous batchSize error (as noted in comment #2), it seems the new model itself is not compatible with the batch prediction functionality demonstrated in that specific sample.

It's best to refer to the official documentation for the gemini-embedding-001 model to confirm its supported features, including batch prediction capabilities. If batch support is a critical requirement, you might need to use a different model that explicitly supports it, or wait for potential future updates to the gemini-embedding-001 model.

Thanks again for catching this and providing the detailed error message!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@glasnt

glasnt commented May 29, 2025

Copy link
Copy Markdown
Contributor

Hi, I tried running the batch embedding sample in generative_ai/embeddings/batch_example.py, but I get an error 400 with the message Do not support publisher model gemini-embedding-001 - does gemini-embedding-001 actually support batch embedding (yet?)

Hi! If you could create a new issue with the code you ran and the error you received, we can investigate.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gemini-code-assist

gemini-code-assist Bot commented May 29, 2025

Copy link
Copy Markdown
Contributor

Thanks for the suggestion, @glasnt! Creating a new issue is indeed the best way to track and investigate this specific model compatibility problem further.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zeevox zeevox mentioned this pull request May 29, 2025
Batch embedding sample does not work after update to gemini-embedding-001 #13393
Closed
@Feiyang1 Feiyang1 mentioned this pull request May 30, 2025
fix: Revert the change in generative_ai/embeddings/batch_example.py #13396
Merged
1 of 9 tasks
@Feiyang1

Feiyang1 commented May 30, 2025

Copy link
Copy Markdown
Contributor Author

Hi, I tried running the batch embedding sample in generative_ai/embeddings/batch_example.py, but I get an error 400 with the message Do not support publisher model gemini-embedding-001 - does gemini-embedding-001 actually support batch embedding (yet?)

Unfortunately gemini-embedding-001 doesn't support batch_predict at the moment. I've created #13396 to revert the change. Sorry for the confusion.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gemini-code-assist

gemini-code-assist Bot commented May 30, 2025

Copy link
Copy Markdown
Contributor

Thanks for the update, @Feiyang1!

It's good to know that gemini-embedding-001 indeed doesn't support batch prediction at this time. Thanks for confirming and for creating the new PR to revert the change. This helps clarify the situation for users trying to run the batch embedding sample.

Appreciate you addressing this quickly!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@glasnt glasnt mentioned this pull request May 30, 2025
chore(generative_ai): unmark test as fixture #13397
Merged
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iennae iennae iennae approved these changes
+2 more reviewers
@glasnt glasnt glasnt left review comments
@gemini-code-assist gemini-code-assist[bot] gemini-code-assist[bot] requested changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@iennae iennae

Labels

samples Issues that are directly related to samples.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@Feiyang1 @glasnt @zeevox @iennae @kokoro-team
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.