Instructions to use kerasformers/gemma-3-12b-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasFormers
How to use kerasformers/gemma-3-12b-it with KerasFormers:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Keras
How to use kerasformers/gemma-3-12b-it with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://kerasformers/gemma-3-12b-it") - Notebooks
- Google Colab
- Kaggle
See our collection for all versions of Gemma 3.
Run Gemma 3 with Keras 3: JAX, PyTorch, or TensorFlow
kerasformers/gemma-3-12b-it
Paper: Gemma 3 Technical Report (arXiv:2503.19786) · HF Papers
Gemma 3 is Google's open Gemma family with a multimodal (image + text) decoder with a SigLIP vision encoder: RMSNorm, GeGLU, RoPE with a
long-context rope scaling, grouped-query attention, alternating local/global
attention, and (4B+) a SigLIP image encoder feeding soft image tokens into the
decoder. Base checkpoints are for completion; -it variants are instruction-tuned.
For more details, see Google's original model card.
Pure-Keras 3 conversion of google/gemma-3-12b-it for
kerasformers. One implementation runs
unmodified on TensorFlow / Torch / JAX.
This is an instruction-tuned checkpoint: use the chat template via Gemma3Processor.
Quick start
import os
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
from PIL import Image
from kerasformers.models.gemma3 import Gemma3Generate, Gemma3Processor
model = Gemma3Generate.from_weights("kerasformers/gemma-3-12b-it")
processor = Gemma3Processor.from_weights("kerasformers/gemma-3-12b-it")
inputs = processor(conversation=[
{"role": "user", "content": [
{"type": "image", "image": Image.open("cat.jpg")},
{"type": "text", "text": "Describe this image in one sentence."},
]}
])
outputs = model.generate(**inputs, max_new_tokens=64)
print(processor.decode(outputs[0]))
All Gemma 3 variants load the same way with from_weights("kerasformers/<variant>"):
| Variant | Hub | Type |
|---|---|---|
gemma-3-270m |
kerasformers/gemma-3-270m |
text / base |
gemma-3-270m-it |
kerasformers/gemma-3-270m-it |
text / instruct |
gemma-3-1b-pt |
kerasformers/gemma-3-1b-pt |
text / base |
gemma-3-1b-it |
kerasformers/gemma-3-1b-it |
text / instruct |
gemma-3-4b-pt |
kerasformers/gemma-3-4b-pt |
multimodal / base |
gemma-3-4b-it |
kerasformers/gemma-3-4b-it |
multimodal / instruct |
gemma-3-12b-pt |
kerasformers/gemma-3-12b-pt |
multimodal / base |
gemma-3-12b-it |
kerasformers/gemma-3-12b-it |
multimodal / instruct |
gemma-3-27b-pt |
kerasformers/gemma-3-27b-pt |
multimodal / base |
gemma-3-27b-it |
kerasformers/gemma-3-27b-it |
multimodal / instruct |
Tips
- Set
KERAS_BACKENDbefore importing Keras / kerasformers. - Loads in bfloat16 by default (the weights are bf16). Pass
load_dtype="float32"for full precision, orquantization="int8"to shrink further. gemma-3-1bis text-only — usegemma-3-4b-itor larger for images.- See Gemma 3 docs and Loading Weights.
- Upstream safetensors still work via the
hf:prefix, e.g.Gemma3Generate.from_weights("hf:google/gemma-3-12b-it").
Special Thanks
A huge thank you to the Google Gemma authors for creating and releasing these models.
License: Gemma (gated). Accept the license on the upstream Hub card before downloading.
- Downloads last month
- -