Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Migrate Tuning Notebooks from Vertex AI SDK to Gen AI SDK #1810

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

holtskinner
Copy link
Collaborator

  • Additional formatting updates

@holtskinner holtskinner requested a review from a team as a code owner March 10, 2025 17:17
Copy link

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

Choose a reason for hiding this comment

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

Hello @holtskinner, 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

This pull request migrates the tuning notebooks from the Vertex AI SDK to the Gen AI SDK. It removes the old notebook and adds two new notebooks: gen_ai_sdk_supervised_finetuning_using_gemini_on_multiple_images.ipynb and gen_ai_sdk_supervised_finetuning_using_gemini_qa.ipynb. The first notebook demonstrates supervised fine-tuning with Gemini 1.5 Flash for change detection using the Google Gen AI SDK, while the second demonstrates supervised fine-tuning with Gemini 1.5 Flash for Q&A using the Google Gen AI SDK. Additional formatting updates were also included.

Highlights

  • SDK Migration: The core change involves migrating the tuning notebooks to use the new Google Gen AI SDK, providing a unified interface to Gemini models.
  • New Notebooks: Two new notebooks are added, focusing on specific use cases: change detection with multiple images and question answering.
  • Code Modernization: The notebooks are updated to use the latest Google Cloud libraries and best practices for generative AI model tuning.

Changelog

Click here to see the changelog
  • gemini/tuning/gen_ai_sdk_supervised_finetuning_using_gemini_on_multiple_images.ipynb
    • This file is new, and contains a Colab notebook demonstrating supervised fine-tuning of Gemini 1.5 Flash for a change detection task using multiple images as input.
    • It includes sections for installing required packages, authenticating with Google Cloud, preparing multimodal data, and running the fine-tuning job.
    • It also includes helper functions for saving JSONL files, creating tuning samples, sampling test images, and plotting images from URIs.
  • gemini/tuning/gen_ai_sdk_supervised_finetuning_using_gemini_qa.ipynb
    • This file is new, and contains a Colab notebook demonstrating supervised fine-tuning of Gemini 1.5 Flash for a question answering task using the Google Gen AI SDK.
    • It includes sections for installing required packages, authenticating with Google Cloud, preparing the SQuAD dataset, and running the fine-tuning job.
    • It also includes helper functions for calculating EM and F1 scores, converting DataFrames to JSONL format, and plotting training metrics.
  • gemini/tuning/supervised_finetuning_using_gemini.ipynb
    • The dataset citation was updated to use bibtex format.
  • gemini/tuning/supervised_finetuning_using_gemini_on_multiple_images.ipynb
    • The notebook title was updated to include 'using the Google Gen AI SDK'.
    • The author list was updated to include Erwin Huizenga.
    • The dataset citation was updated to use bibtex format.
    • The installation instructions were updated to install the Google Gen AI SDK.
    • The Google Cloud project initialization was updated to use the Google Gen AI SDK.
    • The code for creating a Cloud Storage bucket was commented out.
    • The import statements were updated to remove vertexai.preview imports.
    • The code for tuning the Gemini model was updated to use the Google Gen AI SDK.
  • gemini/tuning/supervised_finetuning_using_gemini_qa.ipynb
    • The notebook title was updated to include 'using the Google Gen AI SDK'.
    • The Google Cloud Skills Boost link was removed.
    • The cost estimation link was updated.
    • The installation instructions were updated to install the Google Gen AI SDK.
    • The Google Cloud project initialization was updated to use the Google Gen AI SDK.
    • The code for creating a Cloud Storage bucket was commented out.
    • The import statements were updated to remove vertexai.preview imports.
    • The code for tuning the Gemini model was updated to use the Google Gen AI SDK.
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.


Trivia time!

What is the file extension for a bibtex file?

Click here for the answer
The file extension for a bibtex file is .bib

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.

Copy link

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

Choose a reason for hiding this comment

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

Code Review

The pull request migrates the tuning notebooks from Vertex AI SDK to Gen AI SDK, which is a good step towards using the latest tools. However, there are several areas where the code can be improved for clarity, consistency, and robustness. The review focuses on correctness, maintainability, and efficiency, providing specific suggestions for code improvements.

Summary of Findings

  • Incorrect Citation Style: The notebook uses plain for citations instead ofbibtex, which is more appropriate for academic references.
  • Inconsistent Terminology: The notebook mixes references to Vertex AI SDK and Google Gen AI SDK, which can be confusing. It should consistently refer to the Google Gen AI SDK after the migration.
  • Hardcoded Values: The notebook contains hardcoded values that should be parameterized or read from environment variables for better flexibility and reusability.
  • Missing Error Handling: The notebook lacks comprehensive error handling for file operations and API calls, which can lead to unexpected failures.
  • Inconsistent Dataset Preparation: The training and validation datasets are prepared differently in some notebooks, leading to potential inconsistencies.

Merge Readiness

The pull request is not yet ready for merging. There are several medium to high severity issues that need to be addressed before merging. Specifically, the inconsistencies in dataset preparation, the lack of comprehensive error handling, and the incorrect citation styles should be fixed. After addressing these issues, another review should be performed to ensure the code is ready for merging. I am unable to approve this pull request, and users should have others review and approve this code before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant