Skip to main content

Gemma open-weight LLM library from Google DeepMind.

Project description

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

    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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gemma-4.0.0.tar.gz (161.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gemma-4.0.0-py3-none-any.whl (245.0 kB view details)

Uploaded Python 3

File details

Details for the file gemma-4.0.0.tar.gz.

File metadata

  • Download URL: gemma-4.0.0.tar.gz
  • Upload date:
  • Size: 161.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for gemma-4.0.0.tar.gz
Algorithm Hash digest
SHA256 47f3de5d7bee5426e919465a44eeb0e02e742b31344e53a6ad61fd7a978ceed1
MD5 f4a18f3710988037f9eb919270e3d75a
BLAKE2b-256 a64063f2ce9442cb0aa7c2593792e6a03638b4cdd24d16f9dbcc6e794aaf0e56

See more details on using hashes here.

File details

Details for the file gemma-4.0.0-py3-none-any.whl.

File metadata

  • Download URL: gemma-4.0.0-py3-none-any.whl
  • Upload date:
  • Size: 245.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for gemma-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c957a592cc1c5beedca01cad12baa31c6fb9893c34eca016660e6ec4ca58c36
MD5 1ea60dc691ecb24ce84e7ca4e41fd77b
BLAKE2b-256 a274fb45d6836022b0dc0cd2d691f482e5f48c6c83f01a03a0aecab4384aebca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page