랭킹으로 돌아가기

google/gemma_pytorch

Pythonai.google.dev/gemma

The official PyTorch implementation of Google's Gemma models

gemmagooglepytorch
스타 성장
스타
5.7k
포크
600
주간 성장
이슈
21
5k5.5k
2024년 2월2024년 11월2025년 9월2026년 7월
아티팩트PyPIpip install gemma_pytorch
README

Gemma in PyTorch

Gemma is a family of lightweight, state-of-the art open models built from research and technology used to create Google Gemini models. They include both text-only and multimodal decoder-only large language models, with open weights, pre-trained variants, and instruction-tuned variants. For more details, please check out the following links:

This is the official PyTorch implementation of Gemma models. We provide model and inference implementations using both PyTorch and PyTorch/XLA, and support running inference on CPU, GPU and TPU.

Updates

  • [March 12th, 2025 🔥] Support Gemma v3. You can find the checkpoints on Kaggle and Hugging Face

  • [June 26th, 2024] Support Gemma v2. You can find the checkpoints on Kaggle and Hugging Face

  • [April 9th, 2024] Support CodeGemma. You can find the checkpoints on Kaggle and Hugging Face

  • [April 5, 2024] Support Gemma v1.1. You can find the v1.1 checkpoints on Kaggle and Hugging Face.

Download Gemma model checkpoint

You can find the model checkpoints on Kaggle:

Alternatively, you can find the model checkpoints on the Hugging Face Hub here. To download the models, go the the model repository of the model of interest and click the Files and versions tab, and download the model and tokenizer files. For programmatic downloading, if you have huggingface_hub installed, you can also run:

huggingface-cli download google/gemma-3-4b-it-pytorch

The following model sizes are available:

  • Gemma 3:
    • Text only: 1b
    • Multimodal: 4b, 12b, 27b_v3
  • Gemma 2:
    • Text only: 2b-v2, 9b, 27b
  • Gemma:
    • Text only: 2b, 7b

Note that you can choose between the 1B, 4B, 12B, and 27B variants.

VARIANT=<1b, 2b, 2b-v2, 4b, 7b, 9b, 12b, 27b, 27b_v3>
CKPT_PATH=<Insert ckpt path here>

Try it free on Colab

Follow the steps at https://ai.google.dev/gemma/docs/pytorch_gemma.

Try it out with PyTorch

Prerequisite: make sure you have setup docker permission properly as a non-root user.

sudo usermod -aG docker $USER
newgrp docker

Build the docker image.

DOCKER_URI=gemma:${USER}

docker build -f docker/Dockerfile ./ -t ${DOCKER_URI}

Run Gemma inference on CPU.

NOTE: This is a multimodal example. Use a multimodal variant.

docker run -t --rm \
    -v ${CKPT_PATH}:/tmp/ckpt \
    ${DOCKER_URI} \
    python scripts/run_multimodal.py \
    --ckpt=/tmp/ckpt \
    --variant="${VARIANT}" \
    # add `--quant` for the int8 quantized model.

Run Gemma inference on GPU.

NOTE: This is a multimodal example. Use a multimodal variant.

docker run -t --rm \
    --gpus all \
    -v ${CKPT_PATH}:/tmp/ckpt \
    ${DOCKER_URI} \
    python scripts/run_multimodal.py \
    --device=cuda \
    --ckpt=/tmp/ckpt \
    --variant="${VARIANT}"
    # add `--quant` for the int8 quantized model.

Try It out with PyTorch/XLA

Build the docker image (CPU, TPU).

DOCKER_URI=gemma_xla:${USER}

docker build -f docker/xla.Dockerfile ./ -t ${DOCKER_URI}

Build the docker image (GPU).

DOCKER_URI=gemma_xla_gpu:${USER}

docker build -f docker/xla_gpu.Dockerfile ./ -t ${DOCKER_URI}

Run Gemma inference on CPU.

NOTE: This is a multimodal example. Use a multimodal variant.

docker run -t --rm \
    --shm-size 4gb \
    -e PJRT_DEVICE=CPU \
    -v ${CKPT_PATH}:/tmp/ckpt \
    ${DOCKER_URI} \
    python scripts/run_xla.py \
    --ckpt=/tmp/ckpt \
    --variant="${VARIANT}" \
    # add `--quant` for the int8 quantized model.

Run Gemma inference on TPU.

Note: be sure to use the docker container built from xla.Dockerfile.

docker run -t --rm \
    --shm-size 4gb \
    -e PJRT_DEVICE=TPU \
    -v ${CKPT_PATH}:/tmp/ckpt \
    ${DOCKER_URI} \
    python scripts/run_xla.py \
    --ckpt=/tmp/ckpt \
    --variant="${VARIANT}" \
    # add `--quant` for the int8 quantized model.

Run Gemma inference on GPU.

Note: be sure to use the docker container built from xla_gpu.Dockerfile.

docker run -t --rm --privileged \
    --shm-size=16g --net=host --gpus all \
    -e USE_CUDA=1 \
    -e PJRT_DEVICE=CUDA \
    -v ${CKPT_PATH}:/tmp/ckpt \
    ${DOCKER_URI} \
    python scripts/run_xla.py \
    --ckpt=/tmp/ckpt \
    --variant="${VARIANT}" \
    # add `--quant` for the int8 quantized model.

Tokenizer Notes

99 unused tokens are reserved in the pretrained tokenizer model to assist with more efficient training/fine-tuning. Unused tokens are in the string format of <unused[0-97]> with token id range of [7-104].

"<unused0>": 7,
"<unused1>": 8,
"<unused2>": 9,
...
"<unused98>": 104,

Disclaimer

This is not an officially supported Google product.

관련 저장소
ollama/ollama

Get up and running with Kimi-K2.6, GLM-5.2, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

GoGo ModulesMIT Licensellamallm
ollama.com
176.6k17.1k
huggingface/transformers

🤗 Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.

PythonPyPIApache License 2.0nlpnatural-language-processing
huggingface.co/transformers
162.8k34k
hiyouga/LlamaFactory

Unified Efficient Fine-Tuning of 100+ LLMs & VLMs (ACL 2024)

PythonPyPIApache License 2.0fine-tuningllama
llamafactory.readthedocs.io
73.4k9k
unslothai/unsloth

Unsloth is a local UI for training and running Gemma 4, Qwen3.6, DeepSeek, Kimi, GLM and other models.

PythonPyPIApache License 2.0fine-tuningllama
unsloth.ai/docs
68.7k6.2k
GaiZhenbiao/ChuanhuChatGPT

GUI for ChatGPT API and many LLMs. Supports agents, file-based QA, GPT finetuning and query with web search. All with a neat UI.

PythonPyPIGNU General Public License v3.0chatbotchatgpt-api
huggingface.co/spaces/JohnSmith9982/ChuanhuChatGPT
15.3k2.2k
xorbitsai/inference

Swap GPT for any LLM by changing a single line of code. Xinference lets you run open-source, speech, and multimodal models on cloud, on-prem, or your laptop — all through one unified, production-ready inference API.

PythonPyPIApache License 2.0ggmlpytorch
inference.readthedocs.io
9.4k847
yangjianxin1/Firefly

Firefly: 大模型训练工具,支持训练Qwen2.5、Qwen2、Yi1.5、Phi-3、Llama3、Gemma、MiniCPM、Yi、Deepseek、Orion、Xverse、Mixtral-8x7B、Zephyr、Mistral、Baichuan2、Llma2、Llama、Qwen、Baichuan、ChatGLM2、InternLM、Ziya2、Vicuna、Bloom等大模型

PythonPyPIgptalpaca
6.6k584
clusterzx/paperless-ai

An automated document analyzer for Paperless-ngx using OpenAI API, Ollama, Deepseek-r1, Azure and all OpenAI API compatible Services to automatically analyze and tag your documents.

JavaScriptnpmMIT Licenseaiautomation
clusterzx.github.io/paperless-ai/
5.8k316
google-gemma/cookbook

A collection of guides and examples for the Gemma open models from Google.

Jupyter NotebookApache License 2.0codegemmagemma
ai.google.dev/gemma/
3.9k640
deta/surf

Personal AI Notebooks. Organize files & webpages and generate notes from them. Open source, local & open data, open model choice (incl. local).

TypeScriptnpmApache License 2.0localproductivity
deta.surf
3.5k254
cactus-compute/needle

26m agentic model for tiny devices

PythonPyPIMIT Licensecactusgemini
cactuscompute.com
3.3k246
nicedreamzapp/claude-code-local

Run Claude Code 100% on-device with local AI on Apple Silicon. MLX-native Anthropic-API server, 65 tok/s Qwen 3.5 122B, Llama 3.3 70B, Gemma 4 31B. Private, offline, airgap-ready. Built for NDA / legal / healthcare workflows.

PythonPyPIMIT Licenseabliteratedai-privacy
nicedreamzwholesale.com/airgap/
3k568