Migrate Gemma models to use via API Inference through Google AI Studio #1141
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses #1118
Changes Made
GemmaHandlerfor API inference that converts system prompts to user prompts and disables thinking features (not supported by Gemma models)SUPPORTED_MODELS.mdto reflect provider change from "Self-hosted 💻" to "Google"google/gemma-*togemma-*to match Google AI Studio naming conventionsNonefor all Gemma models (open-source, free via Google AI Studio)Models Added/Migrated
gemma-3-1b-itgemma-3-4b-itgemma-3-12b-itgemma-3-27b-itgemma-3n-e2b-it(new)gemma-3n-e4b-it(new)Important Concerns to Note
Google AI Studio Limitations for Gemma-3n Models
Based on testing, the Gemma-3n models have some issues in Google AI Studio:
gemma-3n-e4b-itappears asgemma-3-4b-itin usage statistics (despite being different models, it groupsgemma-3n-e4b-itwithgemma-3-4b-it)gemma-3n-e2b-itappears asgemma-3-2b-itin usage statistics (even thoughgemma-3-2b-itdoesn't exist)gemma-3n-e4b-itreturnsERROR: 400 INVALID_ARGUMENT: Image input modality is not enabled for models/gemma-3n-e4b-itgemma-3-4b-itworks correctly with images (this also confirms that the API is indeed calling different models despite showing usage forgemma-3n-e4b-itas the same asgemma-3-4b-it)Verification Method: Tested models
gemma-3n-e4b-it,gemma-3-4b-it, andgemma-3n-e2b-itwith identical image inputs - error response (shown above) forgemma-3n-e4b-itand success forgemma-3-4b-itconfirmed they call separate APIs despite UI grouping issues in Google AI Studio dashboard.gemma-3n-e2b-italso had the same error for handling images:ERROR: 400 INVALID_ARGUMENT: Image input modality is not enabled for models/gemma-3n-e2b-itconfirming that it is indeed trying to usegemma-3n-e2b-itdespite it showing up asgemma-3-2b-iton the Google AI Studio usage dashboard. This also confirms multimodal issues across the Gemma 3n models.Fallback to Local Inference
Local inference remains available for users who need full functionality or encounter API issues:
To switch back to local inference:
Change import in
bfcl_eval/constants/model_config.py:Move Gemma model configurations from
api_inference_model_maptolocal_inference_model_mapChange naming back to
google/gemma-*(check Note below)Notes
None(open-source models, free via Google AI Studio).google/gemma-*(HuggingFace convention) togemma-*(Google AI Studio requirement)GemmaHandlerhandles Gemma-specific limitations (no system instructions, no thinking features)Final Note
While this PR enables API access to Gemma models, users requiring multimodal capabilities should continue using local inference until Google resolves the AI Studio limitations for Gemma-3n models. Overall the reliability through Google AI Studio is questionable.