google-deepmind/gemma
JAX SDK for local Gemma inference and fine-tuning
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & 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.
gemma is a JAX-based Python package requiring Python 3.12 or newer.gm.nn.Gemma4_E4B() can be paired with gm.ckpts.CheckpointPath.GEMMA4_E4B_IT via gm.ckpts.load_params.gm.text.ChatSampler spans Gemma 2, 3, 3n, and 4 and exposes an explicit multi_turn option.<|image|> placeholders with an images argument and follows up in a second turn.examples/ contains sampling and fine-tuning scripts; tutorials cover fine-tuning and LoRA sampling.dialog requirement to >= 1.1.0.Python/JAX teams that need local Gemma inference, multimodal chat with a compatible checkpoint, or a starting point for fine-tuning.
You need a ready-to-run inference endpoint, managed accelerator capacity, or support for Python versions older than 3.12.
Quick Start & Installation
pip install gemmaComparison vs. Top LLMs & Inference Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| gemma ★ | 5.9k | +23 | Python | Apache-2.0 | JAX SDK for local Gemma inference and fine-tuning |
| DeepSpeed | 43.4k | +33 | Python | Apache-2.0 | PyTorch runtime for distributed training and inference under GPU memory constrai |
| agent-lightning | 19k | +30 | Python | MIT | Proxy-based reinforcement learning for agents in their existing harnesses |
| ludwig | 11.8k | +6 | Python | Apache-2.0 | YAML-first framework for fine-tuning, training, and serving LLMs and multimodal |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/google-deepmind/gemma.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about gemma
How do I integrate Gemma into an application?
gm.nn.Gemma4_E4B(), load its matching parameters with gm.ckpts.load_params, and pass both to gm.text.ChatSampler. Use multi_turn=True for a conversation. This is an in-process Python API; a network service must provide its own request and session handling.Which accelerator and how much VRAM should I budget?
Does Apache-2.0 cover commercial self-hosting of the weights?
When should I choose this SDK over an inference server or hosted API?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy