Skip to content

Conversation

@bebechien
Copy link
Collaborator

No description provided.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @bebechien, 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!

This pull request involves the migration of a substantial collection of educational and example notebooks related to various Gemma models and their applications. The primary goal is to centralize these resources within the gemma-cookbook repository, making them more accessible and discoverable for developers. The notebooks demonstrate a broad spectrum of functionalities, from basic text generation and image understanding to advanced fine-tuning techniques and integration with diverse machine learning frameworks, ensuring a rich learning experience for users exploring the Gemma ecosystem.

Highlights

  • Notebook Migration: A comprehensive set of Gemma-related notebooks have been migrated from the DevSite to the gemma-cookbook repository, consolidating examples and tutorials in a central location.
  • Diverse Gemma Models: New notebooks introduce various Gemma model variants, including CodeGemma, EmbeddingGemma, FunctionGemma, PaliGemma, and RecurrentGemma, showcasing their unique capabilities.
  • Framework Integration: The migrated content covers integration with multiple popular AI/ML frameworks such as Keras, Hugging Face Transformers, JAX/Flax, PyTorch, and Sentence Transformers.
  • Advanced Use Cases: Tutorials now include advanced topics like fine-tuning (LoRA, QLoRA, full fine-tuning), distributed training, embedding generation, function calling, image analysis, code assistance, and chatbot development.
  • Specific Notebook Additions: Key additions include video analysis with Gemma, AI-assisted programming with CodeGemma and KerasNLP, distributed tuning with Gemma on TPUs, prompting with images using the Gemma library, fine-tuning EmbeddingGemma for domain-specific tasks, and full function calling sequences with FunctionGemma.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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.

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
Contributor

@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

This pull request is a significant contribution, migrating a large number of dev-site notebooks into the gemma-cookbook. The notebooks cover a wide range of topics, from basic inference to fine-tuning for various Gemma family models. While the migration is a great step, I've found several issues across the notebooks, including broken links, typos, grammatical errors, and some critical code errors that would prevent users from running the tutorials successfully. These include incorrect model identifiers, broken image URLs, and flawed code logic in examples. I've provided detailed comments and suggestions for each issue to help improve the quality and usability of these valuable resources.

Comment on lines +507 to +508
"processor = AutoTokenizer.from_pretrained(args.output_dir)\n",
"processor.save_pretrained(\"merged_model\")"
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

There's a NameError here. The variable processor is used, but it was defined as tokenizer earlier in the notebook. This should be corrected to tokenizer to avoid an error when saving.

tokenizer = AutoTokenizer.from_pretrained(args.output_dir)
processor.save_pretrained("merged_model")

Comment on lines +283 to +286
"if model_id == \"google/gemma-3-1b-pt\":\n",
" model_class = AutoModelForCausalLM\n",
"else:\n",
" model_class = AutoModelForImageTextToText\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The code incorrectly selects AutoModelForImageTextToText for text-only models like google/gemma-3-4b-pt. This will cause an error. The correct class for causal language models is AutoModelForCausalLM. Please update the logic to use the correct model class.

if model_id == "google/gemma-3-1b-pt":
    model_class = AutoModelForCausalLM
else:
    model_class = AutoModelForCausalLM

Comment on lines +603 to +604
"id": "QITD66qJvCTO"
},
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The image URLs point to localhost. This will fail for any user running this notebook in a cloud environment like Colab or Kaggle, as the images won't be accessible. To make this tutorial runnable, please host these images publicly and update the URLs, or include them in the repository and load them from a local path.

Comment on lines +358 to +365
"model_config.dtype = \"float32\" if MACHINE_TYPE == \"cpu\" else \"float16\"\n",
"model_config.tokenizer = tokenizer_path"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "zSp7oLLwjKCa"
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The @contextlib.contextmanager decorator is used, but contextlib is not imported. This will raise a NameError. Please add import contextlib at the beginning of the notebook to resolve this.

Comment on lines +603 to +604
"dog_a = read_image(\"http://localhost/images/dog-a.jpg\")\n",
"dog_b = read_image(\"http://localhost/images/dog-b.jpg\")\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The image URLs point to localhost. This will fail for any user running this notebook in a cloud environment like Colab or Kaggle, as the images won't be accessible. To make this tutorial runnable, please host these images publicly and update the URLs, or include them in the repository and load them from a local path.

" <a target=\"_blank\" href=\"https://ai.google.dev/gemma/docs/core/huggingface_inference\"><img src=\"https://ai.google.dev/static/site-assets/images/docs/notebook-site-button.png\" height=\"32\" width=\"32\" />View on ai.google.dev</a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://colab.research.google.com/github/google-gemini/gemma-cookbook/blob/main/DevSite/docs/core/huggingface_inference.ipynb\"\"><img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" />Run in Google Colab</a>\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There's an extra double quote at the end of the href attribute, which makes the HTML invalid and might cause rendering issues or broken links. Please remove it.

    <a target="_blank" href="https://colab.research.google.com/github/google-gemini/gemma-cookbook/blob/main/DevSite/docs/core/huggingface_inference.ipynb"><img src="https://www.tensorflow.org/images/colab_logo_32px.png" />Run in Google Colab</a>

"source": [
"# Video analysis with Gemma\n",
"\n",
"Video data is a rich source of information that can help you accomplish tasks and understand the world around you. Using Gemma with video data can help you understand spacial relationships, interpret human interactions, and assist with situational awareness. This tutorial shows you how to get started processing video data with Gemma using Hugging Face Transformers. The Transformers Python library provides a API for accessing pre-trained generative AI models, including Gemma. For more information, see the [Transformers](https://huggingface.co/docs/transformers/en/index) documentation.\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

I found a couple of typos and a grammatical error in this sentence. "spacial" should be "spatial", and "a API" should be "an API". Correcting these will improve the clarity of the documentation.

Video data is a rich source of information that can help you accomplish tasks and understand the world around you. Using Gemma with video data can help you understand spatial relationships, interpret human interactions, and assist with situational awareness. This tutorial shows you how to get started processing video data with Gemma using Hugging Face Transformers. The Transformers Python library provides an API for accessing pre-trained generative AI models, including Gemma. For more information, see the [Transformers](https://huggingface.co/docs/transformers/en/index) documentation.

" <a target=\"_blank\" href=\"https://ai.google.dev/gemma/docs/capabilities/vision/video-understanding\"><img src=\"https://ai.google.dev/static/site-assets/images/docs/notebook-site-button.png\" height=\"32\" width=\"32\" />View on ai.google.dev</a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://colab.research.google.com/github/google-gemini/gemma-cookbook/blob/main/DevSite/docs/capabilities/vision/video-understanding.ipynb\"\"><img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" />Run in Google Colab</a>\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There's an extra double quote at the end of the href attribute, which makes the HTML invalid and might cause rendering issues or broken links. Please remove it.

    <a target="_blank" href="https://colab.research.google.com/github/google-gemini/gemma-cookbook/blob/main/DevSite/docs/capabilities/vision/video-understanding.ipynb"><img src="https://www.tensorflow.org/images/colab_logo_32px.png" />Run in Google Colab</a>

"id": "3_lX1k54KKrx"
},
"source": [
"Copyright 2024 Google LLC."
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The copyright header is missing the markdown ##### prefix, which is inconsistent with the other notebooks in this PR. For consistency, please add it.

##### Copyright 2024 Google LLC.

Comment on lines +856 to +862
"source": [
"Try the `MTNTDatasetBuilder` out by instantiating the custom `GriffinTokenizer` again, then applying it on the MTNT dataset, and sampling two examples:"
]
},
{
"cell_type": "code",
"execution_count": null,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The output includes a JAX UserWarning: Some donated buffers were not usable. While this may not be a critical error, it can be confusing for users. It would be helpful to add a markdown cell explaining that this warning is expected and can be safely ignored, to improve the user experience.

Copy link
Collaborator

@irbg irbg left a comment

Choose a reason for hiding this comment

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

Suggest dropping the DevSite directory and merging the README note into the root README.md

I'm fine with docs/ being lowercase as it works better with the URL that will be used in Vertex/Kaggle/Colab etc

@bebechien bebechien requested a review from irbg January 7, 2026 02:04
@bebechien bebechien merged commit d359a0e into google-gemini:main Jan 15, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants