google-deepmind/gemma
GitHub: google-deepmind/gemma
来自Google DeepMind的开源大语言模型库,支持文本生成、多模态理解和模型微调。
Stars: 4453 | Forks: 772
# Gemma
[](https://github.com/google-deepmind/gemma/actions/workflows/pytest_and_autopublish.yml)
[](https://badge.fury.io/py/gemma)
[](https://gemma-llm.readthedocs.io/en/latest/?badge=latest)
[Gemma](https://ai.google.dev/gemma) 是由 [Google DeepMind](https://deepmind.google/) 推出的开源权重大型语言模型系列,基于 Gemini 研究和技术。
本仓库包含 [`gemma`](https://pypi.org/project/gemma/) PyPI 包的实现。这是一个用于使用和微调 Gemma 的 [JAX](https://github.com/jax-ml/jax) 库。
有关示例和用例,请参阅我们的[文档](https://gemma-llm.readthedocs.io/)。请在 [我们的 GitHub](https://github.com/google-deepmind/gemma/issues) 上报告问题和反馈。
### 安装
1. 为 CPU、GPU 或 TPU 安装 JAX。请按照 [JAX 网站](https://jax.readthedocs.io/en/latest/installation.html) 上的说明进行操作。
2. 运行
pip install gemma
### 示例
以下是一个最小的多轮、多模态对话示例:
```
from gemma import gm
# 模型和参数
model = gm.nn.Gemma3_4B()
params = gm.ckpts.load_params(gm.ckpts.CheckpointPath.GEMMA3_4B_IT)
# 多轮对话示例
sampler = gm.text.ChatSampler(
model=model,
params=params,
multi_turn=True,
)
prompt = """Which of the two images do you prefer?
Image 1:
Image 2:
Write your answer as a poem."""
out0 = sampler.chat(prompt, images=[image1, image2])
out1 = sampler.chat('What about the other image ?')
```
我们的文档包含各种 Colab 和教程,包括:
* [采样](https://gemma-llm.readthedocs.io/en/latest/colab_sampling.html)
* [多模态](https://gemma-llm.readthedocs.io/en/latest/colab_multimodal.html)
* [微调](https://gemma-llm.readthedocs.io/en/latest/colab_finetuning.html)
* [LoRA](https://gemma-llm.readthedocs.io/en/latest/colab_lora_sampling.html)
* ...
此外,我们的 [examples/](https://github.com/google-deepmind/gemma/tree/main/examples) 文件夹中还包含用于微调和采样的其他脚本。
### 了解更多关于 Gemma
* 使用此库:[Gemma 文档](https://gemma-llm.readthedocs.io/)
* 模型能力和指标的技术报告:
* [Gemma 1](https://goo.gle/GemmaReport)
* [Gemma 2](https://goo.gle/gemma2report)
* [Gemma 3](https://storage.googleapis.com/deepmind-media/gemma/Gemma3Report.pdf)
* 其他 Gemma 实现和 [Gemma 生态系统](https://ai.google.dev/gemma/docs) 上的文档
### 下载模型
如何下载模型权重,请参阅[我们的文档](https://gemma-llm.readthedocs.io/en/latest/checkpoints.html)。
### 系统要求
Gemma 可以在 CPU、GPU 和 TPU 上运行。对于 GPU,我们建议 2B 检查点使用 8GB+ GPU 内存,7B 检查点使用 24GB+ GPU 内存。
### 贡献
我们欢迎贡献!在提交 Pull Request 之前,请阅读我们的[贡献指南](./CONTRIBUTING.md)。
*这不是官方 Google 产品。*
标签:Apex, DLL 劫持, Gemma, Google DeepMind, JAX, LLM, PyPI, Python, Transformer, Unmanaged PE, 人工智能, 多模态, 大语言模型, 开源搜索引擎, 开源模型, 文本生成, 无后门, 机器学习, 模型微调, 模型推理, 深度学习, 生成式AI, 用户模式Hook绕过, 索引, 聊天模型, 逆向工具, 预训练模型