MCPcopy
hub / github.com/google-deepmind/gemma

github.com/google-deepmind/gemma @v4.0.1 sqlite

repository ↗ · DeepWiki ↗ · release v4.0.1 ↗
963 symbols 2,891 edges 145 files 565 documented · 59%
README

Gemma

Unittests PyPI version Documentation Status

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.
  2. Run

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

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

Learn more about Gemma

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 before submitting a pull request.

This is not an official Google product.

Core symbols most depended-on inside this repo

apply
called by 47
gemma/gm/nn/_transformer_like.py
init
called by 32
gemma/gm/nn/_transformer_like.py
pad
called by 23
gemma/gm/utils/_types.py
map
called by 22
gemma/gm/data/_tasks.py
encode
called by 11
gemma/gm/nn/_modules.py
split
called by 11
gemma/gm/text/_tokenizer.py
make_config
called by 8
gemma/research/t5gemma/config.py
init_cache
called by 8
gemma/gm/nn/gemma3n/_modules.py

Shape

Method 419
Function 331
Class 205
Route 8

Languages

Python100%

Modules by API surface

gemma/gm/ckpts/_checkpoint.py33 symbols
gemma/gm/nn/gemma3n/_modules.py32 symbols
gemma/gm/nn/gemma4/audio/_modules.py29 symbols
gemma/peft/_quantization.py25 symbols
gemma/gm/text/_tokenizer.py25 symbols
gemma/research/t5gemma/sampling.py24 symbols
gemma/gm/nn/gemma4/_modules.py24 symbols
gemma/gm/nn/gemma3n/_modules_test.py23 symbols
gemma/gm/text/_sampler.py22 symbols
gemma/research/t5gemma/modules.py21 symbols
gemma/gm/nn/gemma4/_transformer.py21 symbols
gemma/gm/nn/_quantization.py20 symbols

Dependencies from manifests, versioned

absl-py
dialog1.1 · 1×

For agents

$ claude mcp add gemma \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact