### Index ```{eval-rst} .. toctree:: :hidden: :caption: Guides colab_sampling colab_multimodal colab_finetuning colab_tool_use colab_sharding colab_tokenizer colab_lora_sampling colab_lora_finetuning peft checkpoints research .. toctree:: :hidden: :caption: Links GitHub Issues Ecosystem .. toctree:: :hidden: :caption: API api/gm/index api/peft/index ``` ```{include} ../README.md ``` --- ### Checkpoints # Checkpoints ## Kaggle Hub Gemma models are available on Kaggle Hub for various formats: * [Gemma 4](https://www.kaggle.com/models/google/gemma-4/) * [Gemma 3](https://www.kaggle.com/models/google/gemma-3/) * [Gemma 2](https://www.kaggle.com/models/google/gemma-2/) * [Gemma 1](https://www.kaggle.com/models/google/gemma/) To manually download the model: * Select one of the **Flax** model variations * Click the "Download" button to download the model archive * Extract the model files from the archive The archive contains both the model weights and the tokenizer, like: ``` 2b/ # Directory containing model weights tokenizer.model # Tokenizer ``` To programmatically download the model: ```python import kagglehub kagglehub.login() weights_dir = kagglehub.model_download(f'google/gemma-3/flax/gemma3-4b-it') ``` ### v4 NOTE: Gemma 4 Flax checkpoints will be updated on Kaggle when possible.
### v3 | Size | Variant | Quantized | Name | | ---- | ----------- | --------- | ---------------------------------------- | | 1B | Pre-trained | | `google/gemma-3/flax/gemma3-1b` | : : (PT) : : : | 4B | Pre-trained | | `google/gemma-3/flax/gemma3-4b` | : : (PT) : : : | 12B | Pre-trained | | `google/gemma-3/flax/gemma3-12b` | : : (PT) : : : | 27B | Pre-trained | | `google/gemma-3/flax/gemma3-27b` | : : (PT) : : : | 1B | Instruction | | `google/gemma-3/flax/gemma3-1b-it` | : : Tuned (IT) : : : | 4B | Instruction | | `google/gemma-3/flax/gemma3-4b-it` | : : Tuned (IT) : : : | 12B | Instruction | | `google/gemma-3/flax/gemma3-12b-it` | : : Tuned (IT) : : : | 27B | Instruction | | `google/gemma-3/flax/gemma3-27b-it` | : : Tuned (IT) : : : | 1B | Instruction | Y | `google/gemma-3/flax/gemma3-1b-it-int4` | : : Tuned (IT) : : : | 4B | Instruction | Y | `google/gemma-3/flax/gemma3-4b-it-int4` | : : Tuned (IT) : : : | 12B | Instruction | Y | `google/gemma-3/flax/gemma3-12b-it-int4` | : : Tuned (IT) : : : | 27B | Instruction | Y | `google/gemma-3/flax/gemma3-27b-it-int4` | : : Tuned (IT) : : :
### v2 Size | Variant | Name ---- | ---------------------- | ----------------------------------- 2.6B | Pre-trained (PT) | `google/gemma-2/flax/gemma2-2b` 9B | Pre-trained (PT) | `google/gemma-2/flax/gemma2-9b` 27B | Pre-trained (PT) | `google/gemma-2/flax/gemma2-27b` 2.6B | Instruction Tuned (IT) | `google/gemma-2/flax/gemma2-2b-it` 9B | Instruction Tuned (IT) | `google/gemma-2/flax/gemma2-9b-it` 27B | Instruction Tuned (IT) | `google/gemma-2/flax/gemma2-27b-it`
--- ### Research # Research ## Custom transformer For experimentation, you might want to create smaller custom versions of Transformer, rather than using the default official "Gemma" pre-trained ones. Here is an example to create a text-only, 12 layers transformer: ```python class MyTinyTransformer(gm.nn.Transformer): config: gm.nn.config.TransformerConfig = gm.nn.config.TransformerConfig( final_logit_softcap=None, num_embed=262144, # Vocab size, matching the tokenizer embed_dim=896, hidden_dim=4 * 896, num_heads=4, head_dim=256, num_kv_heads=1, use_post_attn_norm=True, use_post_ffw_norm=True, use_qk_norm=True, attention_types=gm.nn.config.make_attention_layers_types( pattern=gm.nn.config.GEMMA3_ATTENTION_PATTERN, num_layers=12, ), query_pre_attn_norm=gm.nn.config.QueryPreAttentionNormalisation.BY_ONE_OVER_SQRT_HEAD_DIM, attn_logits_soft_cap=None, sliding_window_size=512, transpose_gating_einsum=True, local_base_frequency=10_000, global_base_frequency=1_000_000, vision_encoder=None, # Text-only ) INFO = gm.nn.config.ModelInfo( tokenizer_version=3, # Auto-select the tokenizer in the sampler ) ``` ## Gemma-related projects The Gemma repository also contain various non-official research projects around Gemma, located in the [research/](https://github.com/google-deepmind/gemma/tree/main/gemma/research/) directory: * [`t5gemma`](https://github.com/google-deepmind/gemma/blob/main/gemma/research/t5gemma/README.md): Encoder/decoder Gemma architecture, based on Gemma 2. --- ### CHANGELOG # Changelog ## [Unreleased] ## [4.1.0] - 2026-06-11 - Release Diffusion Gemma ## [4.0.1] - 2026-05-20 - Fix `dialog` dependency requirement to be `>= 1.1.0`. ## [4.0.0] - 2026-04-17 * Add Gemma 4. ## [1.0.0] - 2022-01-01 * Initial release [Unreleased]: https://github.com/google-deepmind/gemma/compare/v4.1.0...HEAD [4.1.0]: https://github.com/google-deepmind/gemma/compare/v4.0.1...v4.1.0 [4.0.1]: https://github.com/google-deepmind/gemma/compare/v4.0.0...v4.0.1 [4.0.0]: https://github.com/google-deepmind/gemma/compare/v0.1.0...v4.0.0 [1.0.0]: https://github.com/google-deepmind/gemma/releases/tag/v0.1.0 --- ### CONTRIBUTING # How to Contribute We would love to accept your patches and contributions to this project. ## Before you begin ### Sign our Contributor License Agreement Contributions to this project must be accompanied by a [Contributor License Agreement](https://cla.developers.google.com/about) (CLA). You (or your employer) retain the copyright to your contribution; this simply gives us permission to use and redistribute your contributions as part of the project. If you or your current employer have already signed the Google CLA (even if it was for a different project), you probably don't need to do it again. Visit to see your current agreements or to sign a new one. ### Review our Community Guidelines This project follows [Google's Open Source Community Guidelines](https://opensource.google/conduct/). ## Contribution process ### Code Reviews All submissions, including submissions by project members, require review. We use [GitHub pull requests](https://docs.github.com/articles/about-pull-requests) for this purpose. --- ### README # Gemma [](https://github.com/google-deepmind/gemma/actions/workflows/pytest_and_autopublish.yml) [](https://badge.fury.io/py/gemma) [](https://gemma-llm.readthedocs.io/en/latest/?badge=latest) [Gemma](https://ai.google.dev/gemma) is a family of open-weights Large Language Model (LLM) by [Google DeepMind](https://deepmind.google/), based on Gemini research and technology. This repository contains the implementation of the [`gemma`](https://pypi.org/project/gemma/) PyPI package. A [JAX](https://github.com/jax-ml/jax) library to use and fine-tune Gemma. For examples and use cases, see our [documentation](https://gemma-llm.readthedocs.io/). Please report issues and feedback in [our GitHub](https://github.com/google-deepmind/gemma/issues). ### Installation 1. Install JAX for CPU, GPU or TPU. Follow the instructions on [the JAX website](https://jax.readthedocs.io/en/latest/installation.html). 1. Run ```sh pip install gemma ``` ### Examples Here is a minimal example to have a multi-turn, multi-modal conversation with Gemma: ```python from gemma import gm # Model and parameters (Gemma 4) model = gm.nn.Gemma4_E4B() params = gm.ckpts.load_params(gm.ckpts.CheckpointPath.GEMMA4_E4B_IT) # Example of multi-turn conversation sampler = gm.text.ChatSampler( model=model, params=params, multi_turn=True, ) prompt = """Which of the 2 images do you prefer ? Image 1: <|image|> Image 2: <|image|> Write your answer as a poem.""" out0 = sampler.chat(prompt, images=[image1, image2]) out1 = sampler.chat('What about the other image ?') ``` The same `ChatSampler` API works with all Gemma versions (2, 3, 3n, 4). Our documentation contains various Colabs and tutorials, including: * [Sampling](https://gemma-llm.readthedocs.io/en/latest/colab_sampling.html) * [Multi-modal](https://gemma-llm.readthedocs.io/en/latest/colab_multimodal.html) * [Fine-tuning](https://gemma-llm.readthedocs.io/en/latest/colab_finetuning.html) * [LoRA](https://gemma-llm.readthedocs.io/en/latest/colab_lora_sampling.html) * ... Additionally, our [examples/](https://github.com/google-deepmind/gemma/tree/main/examples) folder contain additional scripts to fine-tune and sample with Gemma. ### Learn more about Gemma * To use this library: [Gemma documentation](https://gemma-llm.readthedocs.io/) * Technical reports for metrics and model capabilities: * [Gemma 1](https://goo.gle/GemmaReport) * [Gemma 2](https://goo.gle/gemma2report) * [Gemma 3](https://storage.googleapis.com/deepmind-media/gemma/Gemma3Report.pdf) * [Gemma 4](https://ai.google.dev/gemma/docs/core/model_card_4) * Other Gemma implementations and doc on the [Gemma ecosystem](https://ai.google.dev/gemma/docs) ### Downloading the models To download the model weights. See [our documentation](https://gemma-llm.readthedocs.io/en/latest/checkpoints.html). ### System Requirements Gemma can run on a CPU, GPU and TPU. For GPU, we recommend 8GB+ RAM on GPU for The 2B checkpoint and 24GB+ RAM on GPU are used for the 7B checkpoint. ### Contributing We welcome contributions! Please read our [Contributing Guidelines](./CONTRIBUTING.md) before submitting a pull request. *This is not an official Google product.* ---