GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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.
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.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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.
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.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.
There was an error while loading. Please reload this page.
|
|
||
| textembedding_model = language_models.TextEmbeddingModel.from_pretrained( | ||
| "textembedding-gecko@003" | ||
| "gemini-embedding-001" |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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:
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?output_dimensionality=256 (used in code_retrieval_example.py and document_retrieval_example.py) a valid, supported, and optimal setting for gemini-embedding-001?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.
There was an error while loading. Please reload this page.
| from vertexai.language_models import TextEmbeddingInput, TextEmbeddingModel | ||
|
|
||
| MODEL_NAME = "text-embedding-005" | ||
| MODEL_NAME = "gemini-embedding-001" |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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.
There was an error while loading. Please reload this page.
| 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", |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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.
There was an error while loading. Please reload this page.
| task = "RETRIEVAL_DOCUMENT" | ||
|
|
||
| model = TextEmbeddingModel.from_pretrained("text-embedding-005") | ||
| model = TextEmbeddingModel.from_pretrained("gemini-embedding-001") |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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.
There was an error while loading. Please reload this page.
|
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I'm glad we have tests to catch errors in code snippets. Updated the code and test. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@skarukas ptal |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| embeddings = [] | ||
| # gemini-embedding-001 takes one input at a time | ||
| for text in texts: |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Updated
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -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] | |||
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Hi, I tried running the batch embedding sample in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hi @zeevox, thanks for reporting this issue. The error message This pull request updated the model name in several embedding examples, including It's best to refer to the official documentation for the Thanks again for catching this and providing the detailed error message! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Hi! If you could create a new issue with the code you ran and the error you received, we can investigate. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for the suggestion, @glasnt! Creating a new issue is indeed the best way to track and investigate this specific model compatibility problem further. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Unfortunately gemini-embedding-001 doesn't support batch_predict at the moment. I've created #13396 to revert the change. Sorry for the confusion. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for the update, @Feiyang1! It's good to know that Appreciate you addressing this quickly! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.