Skip to content

Add image token budget example to Gemma 4 vision notebook - #250

Open
siddhantoon wants to merge 2 commits into
unslothai:mainfrom
siddhantoon:gemma4-vision
Open

siddhantoon wants to merge 2 commits into
unslothai:mainfrom
siddhantoon:gemma4-vision

Conversation

@siddhantoon

Copy link
Copy Markdown

Added a small optional section to the Gemma 4 vision tutorial explaining image token budget.

It shows:

  • how to inspect the default image token usage
  • how to increase processor.image_processor.max_soft_tokens
  • how to compare token counts before and after on the same sample

This helps users understand when higher image token budgets may help for OCR and document intelligence tasks.

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

Copy link
Copy Markdown
Contributor

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 reorders notebook entries in the README and introduces an optional image token budget configuration in several Gemma 4 vision scripts. The feedback correctly identifies that the source Jupyter notebooks are missing from the PR, which is problematic as the modified Python scripts are auto-generated and will be overwritten. Additionally, the reviewer pointed out that moving the data collator import and instantiation into an optional section creates a dependency that will cause NameErrors if a user skips that section; suggestions were provided to move the import and instantiate the collator directly within the trainer setup to maintain modularity.

Comment thread python_scripts/Gemma4_(26B_A4B)-Vision.py
Comment thread python_scripts/Gemma4_(26B_A4B)-Vision.py
Comment thread python_scripts/Gemma4_(26B_A4B)-Vision.py Outdated
Comment thread python_scripts/Gemma4_(31B)-Vision.py
Comment thread python_scripts/Gemma4_(31B)-Vision.py Outdated
Comment thread python_scripts/Gemma4_(E2B)-Vision.py
Comment thread python_scripts/Gemma4_(E2B)-Vision.py Outdated
Comment thread python_scripts/Gemma4_(E4B)-Vision.py
Comment thread python_scripts/Gemma4_(E4B)-Vision.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9bccba0535

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread python_scripts/Gemma4_(E2B)-Vision.py Outdated
@siddhantoon

siddhantoon commented Apr 18, 2026

Copy link
Copy Markdown
Author

Updated all previous concerns raised for dependency import in optional cell. Re check @codex review

@danielhanchen

Copy link
Copy Markdown
Member

The new cell sets the budget to 1120 right before the collator and trainer, so anyone running the notebook top to bottom trains with about four times the image tokens and may run out of memory on a free Colab GPU, could you leave the default in place and show the larger value only as a commented example? Also this edits the generated python_scripts/ copies and reorders unrelated Gemma4 rows in the README, so it would help to drop those and keep the change to the four vision notebooks.

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