google-deepmind/gemma

Python

Open original ↗

Captured source

source ↗
published Feb 20, 2024seen 5dcaptured 8hhttp 200method plain

google-deepmind/gemma

Description: Gemma open-weight LLM library, from Google DeepMind

Language: Python

License: Apache-2.0

Stars: 5379

Forks: 946

Open issues: 273

Created: 2024-02-20T18:39:01Z

Pushed: 2026-06-10T18:44:11Z

Default branch: main

Fork: no

Archived: no

README:

Gemma

![Unittests](https://github.com/google-deepmind/gemma/actions/workflows/pytest_and_autopublish.yml) ![PyPI version](https://badge.fury.io/py/gemma) ![Documentation Status](https://gemma-llm.readthedocs.io/en/latest/?badge=latest)

Gemma is a family of open-weights Large Language Model (LLM) by Google DeepMind, based on Gemini research and technology.

This repository contains the implementation of the `gemma` PyPI package. A JAX library to use and fine-tune Gemma.

For examples and use cases, see our documentation. Please report issues and feedback in our GitHub.

Installation

1. Install JAX for CPU, GPU or TPU. Follow the instructions on the JAX website. 1. Run

pip install gemma

Examples

Here is a minimal example to have a multi-turn, multi-modal conversation with Gemma:

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 2:

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:

Additionally, our examples/ folder contain additional scripts to fine-tune and sample with Gemma.

Learn more about Gemma

Gemma ecosystem

Downloading the models

To download the model weights. See our documentation.

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.*