Gemma 4

Models & AI Labs 💻 Python ⚖️ Apache-2.0 🟢 Actively maintained
5.7k stars

Gemma is a family of open-weights Large Language Models by Google DeepMind, and this repository provides a JAX library to use and fine-tune them. It solves the problem of accessing and interacting with Gemma models programmatically, supporting multi-turn, multi-modal conversations. It is for developers who want to integrate or fine-tune Gemma models in their applications.

✨ Key features

  • Multi-turn, multi-modal conversation support
  • Fine-tuning and LoRA capabilities
  • Works with Gemma versions 2, 3, 3n, 4
  • Runs on CPU, GPU, and TPU
  • PyPI package for easy installation

🎯 Use cases

  • Build chatbots with multi-turn dialogue
  • Process and reason about images in conversations
  • Fine-tune Gemma models on custom datasets
  • Apply LoRA for efficient model adaptation

📦 Installation

🧰 Requirements: Requires JAX installed for CPU, GPU, or TPU; Python environment with pip.

pip install gemma

Before that, install JAX for CPU, GPU or TPU following the instructions on the JAX website.

🚀 Usage

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 ?')

⚠️ Good to know

This is not an official Google product; GPU memory recommendations are 8GB+ for 2B checkpoint and 24GB+ for 7B checkpoint.

❓ FAQ

What are the system requirements to run Gemma?

Gemma can run on CPU, GPU, and TPU. For GPU, it is recommended to have at least 8GB RAM for the 2B checkpoint and 24GB RAM for the 7B checkpoint.

Which Gemma versions are supported?

The ChatSampler API works with all Gemma versions: 2, 3, 3n, and 4.

How do I download the model weights?

Instructions for downloading model weights are provided in the documentation at https://gemma-llm.readthedocs.io/en/latest/checkpoints.html.

Can I fine-tune Gemma models?

Yes, the library supports fine-tuning and LoRA, with examples and tutorials available in the documentation.

📊 Repository

Stars★ 5,716
Forks🍴 1,016
Open issues🐛 328
Last commit🕒 Sep 3, 2026
Created📅 Feb 2024
Language💻 Python
License⚖️ Apache-2.0

🤖 Overview, features, install steps and FAQ were generated from the project's README on Sep 4, 2026. Always check the original source before running commands.