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

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.

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 introduces a comprehensive guide for performing full model fine-tuning on the Gemma large language model. The guide, presented as a Jupyter notebook, demonstrates how to adapt Gemma to a specific persona using Hugging Face Transformers and the TRL library, with a practical example of training an NPC for a mobile game.

Highlights

  • New Fine-tuning Guide: A new Jupyter notebook, Gemma/[Gemma_3]Full_Model_Finetune_using_HF.ipynb, has been added to provide a step-by-step guide for full model fine-tuning of the Gemma model.
  • Hugging Face Integration: The guide leverages popular Hugging Face libraries, including Transformers and TRL, for efficient model training.
  • NPC Persona Training: It specifically illustrates fine-tuning Gemma to adopt a unique speaking style for a mobile game NPC, using the bebechien/MobileGameNPC dataset.
  • Overfitting as a Feature: The notebook highlights how "overfitting" can be a desirable outcome in specific generative AI applications, such as character consistency for NPCs, by making the model forget general knowledge and adhere strictly to the trained persona.
  • Development Environment Setup: The guide includes instructions for setting up the necessary Python environment and authenticating with Hugging Face.
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 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

@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 introduces a new Jupyter notebook for full model fine-tuning of Gemma models using Hugging Face Transformers and TRL. The notebook is well-structured and provides a good walkthrough. However, I've identified a few critical issues that will prevent it from running successfully. The specified Gemma model is not available on the Hugging Face Hub, an argument in the SFTTrainer instantiation is incorrect, and the header links point to a different notebook. Addressing these points will make the notebook runnable and accurate for users.

},
"outputs": [],
"source": [
"base_model = \"google/gemma-3-270m-it\" # @param [\"google/gemma-3-270m-it\",\"google/gemma-3-1b-it\",\"google/gemma-3-4b-it\",\"google/gemma-3-12b-it\",\"google/gemma-3-27b-it\"] {\"allow-input\":true}\n",

Choose a reason for hiding this comment

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

critical

The model name google/gemma-3-270m-it and the other gemma-3-* models in the parameter list do not appear to be available on the Hugging Face Hub. This will cause an error when trying to load the model. Please update this to use an existing and available Gemma model, for example google/gemma-2-2b-it. The link on line 107 also points to a non-existent model.

base_model = "google/gemma-2-2b-it" # @param ["google/gemma-2-2b-it","google/gemma-2-9b-it"] {"allow-input":true}

" args=args,\n",
" train_dataset=dataset['train'],\n",
" eval_dataset=dataset['test'],\n",
" processing_class=tokenizer,\n",

Choose a reason for hiding this comment

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

critical

The SFTTrainer is being initialized with an incorrect argument processing_class. This will raise a TypeError at runtime. The correct argument name for passing the tokenizer is tokenizer.

    tokenizer=tokenizer,

Comment on lines 42 to 55
" <a target=\"_blank\" href=\"https://ai.google.dev/gemma/docs/core/huggingface_text_finetune_qlora\"><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/generative-ai-docs/blob/main/site/en/gemma/docs/core/huggingface_text_finetune_qlora.ipynb\"\"><img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" />Run in Google Colab</a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/google/generative-ai-docs/blob/main/site/en/gemma/docs/core/huggingface_text_finetune_qlora.ipynb\"><img src=\"https://www.kaggle.com/static/images/logos/kaggle-logo-transparent-300.png\" height=\"32\" width=\"70\"/>Run in Kaggle</a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/google/generative-ai-docs/main/site/en/gemma/docs/core/huggingface_text_finetune_qlora.ipynb\"><img src=\"https://ai.google.dev/images/cloud-icon.svg\" width=\"40\" />Open in Vertex AI</a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://github.com/google/generative-ai-docs/blob/main/site/en/gemma/docs/core/huggingface_text_finetune_qlora.ipynb\"><img src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" />View source on GitHub</a>\n",
" </td>\n",

Choose a reason for hiding this comment

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

high

The links in this header table point to a notebook for QLoRA fine-tuning (huggingface_text_finetune_qlora.ipynb), but this notebook is about full model fine-tuning. This is likely to confuse users. Please update the URLs to point to the correct notebook.

@bebechien bebechien merged commit 64e2aaf into google-gemini:main Aug 14, 2025
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.

1 participant