# Repository Briefing: google-deepmind/gemma
> Source: https://repoforai.com/repo/google-deepmind/gemma (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/google-deepmind/gemma
- **Official Docs / Website**: https://gemma-llm.readthedocs.io
- **Category**: LLMs & Inference (大模型与推理微调)
- **Primary Language**: Python
- **License**: Apache-2.0
- **Engineering Health**: A+ (92/100 · Maintenance 35/35 · Adoption 23/25 · Releases 14/20 · License 20/20)
- **Latest Release**: v4.0.1 (2026-05-20) — https://github.com/google-deepmind/gemma/releases
- **Review Snapshot**: 2026-12-04
- **Deployment / Stack Signals**: Local AI, GPU, API
- **Momentum**: 5,901 ★ total (+2 24h / +23 7d) · 1,062 forks
- **When to Use**: Best for: Python/JAX teams that need local Gemma inference, multimodal chat with a compatible checkpoint, or a starting point for fine-tuning. Skip if: You need a ready-to-run inference endpoint, managed accelerator capacity, or support for Python versions older than 3.12.

## Overview
```text
### Architecture & Core Mechanics
Gemma is a Python SDK built on JAX. The `gemma.gm` interface separates model construction, checkpoint loading, and text sampling: instantiate a model in `gm.nn`, load matching weights with `gm.ckpts.load_params`, then pass both objects to `gm.text.ChatSampler`. This gives application code explicit control over the model–checkpoint pairing.

The package runs inside the Python process on the selected JAX backend. A `ChatSampler` configured with `multi_turn=True` supports successive chat calls; the integration surface is a Python object, not a network protocol. The source tree separates the library in `gemma/` from runnable examples in `examples/` and walkthroughs in `colabs/` and `docs/`.

### Key Capabilities & Differentiators
The same `ChatSampler` API works across Gemma 2, 3, 3n, and 4. The Gemma 4 example pairs `gm.nn.Gemma4_E4B()` with the `GEMMA4_E4B_IT` checkpoint. In the multimodal example, the caller places `<|image|>` markers in the prompt, passes two images through the `images` argument, and asks a follow-up question in a later turn.

A common sampler interface reduces integration changes across model generations, but does not imply that every checkpoint accepts images or has the same hardware requirements. Beyond inference, the project provides fine-tuning and sampling scripts in `examples/` and tutorials for fine-tuning and LoRA sampling. JAX supports execution on CPU, GPU, and TPU.

### Trade-offs & Limitations
The SDK is a good fit when you want direct model and parameter access for Gemma inference or adaptation in a JAX application. Compared with a standalone open-source inference server, it lets you call the model directly from Python but leaves network serving, concurrency limits, and monitoring to your application or a separate serving layer. It is not a substitute for a packaged endpoint.

A managed API reduces responsibility for accelerator setup and capacity; local execution gives you more control over where inference runs but makes sizing and runtime compatibility your responsibility. The library code is Apache-2.0. Evaluate the selected checkpoint’s terms separately before commercial hosting or redistribution; the code license alone does not answer those questions.

### Hardware & Deployment Guide
Use Python 3.12 or newer, install JAX for the intended CPU, GPU, or TPU backend, then run `pip install gemma`. Download the weights separately and load the checkpoint that matches the model. The demonstrated deployment path is local or self-hosted Python execution; if remote callers need access, plan to put a service around that code rather than expecting the sampler to expose an endpoint.

For GPU sizing, the supplied references are 8 GB or more for the 2B checkpoint and 24 GB or more for the 7B checkpoint. Neither figure sizes the Gemma 4 E4B example. Test the exact checkpoint under expected context lengths, image inputs, and concurrency before choosing hardware. v4.0.0 introduced Gemma 4; v4.0.1 corrected the `dialog` dependency requirement to `>= 1.1.0`.
```

## Key Capabilities
```text
- Runtime: `gemma` is a JAX-based Python package requiring Python 3.12 or newer.
- Checkpoint integration: `gm.nn.Gemma4_E4B()` can be paired with `gm.ckpts.CheckpointPath.GEMMA4_E4B_IT` via `gm.ckpts.load_params`.
- Chat API: `gm.text.ChatSampler` spans Gemma 2, 3, 3n, and 4 and exposes an explicit `multi_turn` option.
- Image input: The chat example pairs `<|image|>` placeholders with an `images` argument and follows up in a second turn.
- Adaptation: `examples/` contains sampling and fine-tuning scripts; tutorials cover fine-tuning and LoRA sampling.
- Release compatibility: v4.0.0 added Gemma 4, and v4.0.1 corrected the `dialog` requirement to `>= 1.1.0`.
```

## Quick Start / Clone
```bash
pip install gemma
```
