Instructions to use google/gemma-4-12B-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/gemma-4-12B-it with Transformers:
# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("google/gemma-4-12B-it") model = AutoModelForImageTextToText.from_pretrained("google/gemma-4-12B-it") - Notebooks
- Google Colab
- Kaggle
fix: chat template — null handling, reasoning preservation, turn-tag balance, input validation
#35
by lucianommartins - opened
Summary
Improves Gemma4 chat template:
Bug fixes
Nonevalues now render asnullinstead of Python'sNone- String-typed
tool_calls[].function.argumentsnow raises a clear error instead of silently producing malformed DSL - Prior-turn reasoning/thinking is preserved across multi-turn tool-call chains (
preserve_thinkingflag, default=true) - Consecutive assistant messages now produce balanced
<|turn>model/<turn|>tags via forward-scan continuation detection
Improvements
enable_thinkingnormalized once with| default(false), eliminating repetitiveis defined andchecksimage_urlandinput_audiocontent types now map to<|image|>and<|audio|>(OpenAI compatibility)- Empty
messages=[]handled gracefully instead of crashing - Unmatched
tool_call_idin tool responses falls back to'unknown'instead of crashing - Consistent
.get()access preventsStrictUndefinederrors for optional message keys - O(1) backward scan for model-turn continuation (was O(n) per message)