Update README.md
Browse files
README.md
CHANGED
|
@@ -11,8 +11,11 @@ pipeline_tag: text-generation
|
|
| 11 |
library_name: transformers
|
| 12 |
---
|
| 13 |
<div>
|
| 14 |
-
<p style="margin-
|
| 15 |
-
<
|
|
|
|
|
|
|
|
|
|
| 16 |
</p>
|
| 17 |
<div style="display: flex; gap: 5px; align-items: center; ">
|
| 18 |
<a href="https://github.com/unslothai/unsloth/">
|
|
@@ -21,12 +24,186 @@ library_name: transformers
|
|
| 21 |
<a href="https://discord.gg/unsloth">
|
| 22 |
<img src="https://github.com/unslothai/unsloth/raw/main/images/Discord%20button.png" width="173">
|
| 23 |
</a>
|
| 24 |
-
<a href="https://docs.unsloth.ai/">
|
| 25 |
<img src="https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/images/documentation%20green%20button.png" width="143">
|
| 26 |
</a>
|
| 27 |
</div>
|
|
|
|
| 28 |
</div>
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
# Gemma 3 model card
|
| 32 |
|
|
|
|
| 11 |
library_name: transformers
|
| 12 |
---
|
| 13 |
<div>
|
| 14 |
+
<p style="margin-bottom: 0; margin-top: 0;">
|
| 15 |
+
<strong>See <a href="https://huggingface.co/collections/unsloth/gemma-3-67d12b7e8816ec6efa7e4e5b">our collection</a> for all versions of Gemma 3 including GGUF, 4-bit & 16-bit formats.</strong>
|
| 16 |
+
</p>
|
| 17 |
+
<p style="margin-bottom: 0;">
|
| 18 |
+
<em><a href="https://docs.unsloth.ai/basics/tutorial-how-to-run-gemma-3-effectively">Read our Guide</a> to see how to Run Gemma 3 correctly.</em>
|
| 19 |
</p>
|
| 20 |
<div style="display: flex; gap: 5px; align-items: center; ">
|
| 21 |
<a href="https://github.com/unslothai/unsloth/">
|
|
|
|
| 24 |
<a href="https://discord.gg/unsloth">
|
| 25 |
<img src="https://github.com/unslothai/unsloth/raw/main/images/Discord%20button.png" width="173">
|
| 26 |
</a>
|
| 27 |
+
<a href="https://docs.unsloth.ai/basics/tutorial-how-to-run-deepseek-r1-on-your-own-local-device">
|
| 28 |
<img src="https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/images/documentation%20green%20button.png" width="143">
|
| 29 |
</a>
|
| 30 |
</div>
|
| 31 |
+
<h1 style="margin-top: 0rem;">✨ Fine-tune Gemma 3 with Unsloth!</h1>
|
| 32 |
</div>
|
| 33 |
|
| 34 |
+
- Fine-tune Gemma 3 (270M) for free using our Google [Colab notebook here](https://docs.unsloth.ai/get-started/unsloth-notebooks)!
|
| 35 |
+
- Read our Blog about Gemma 3 support: [unsloth.ai/blog/gemma3](https://unsloth.ai/blog/gemma3)
|
| 36 |
+
- View the rest of our notebooks in our [docs here](https://docs.unsloth.ai/get-started/unsloth-notebooks).
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
| Unsloth supports | Free Notebooks | Performance | Memory use |
|
| 40 |
+
|-----------------|--------------------------------------------------------------------------------------------------------------------------|-------------|----------|
|
| 41 |
+
| **Gemma 3 (4B)** | [▶️ Start on Colab](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma3_(4B).ipynb) | 2x faster | 80% less |
|
| 42 |
+
| **Gemma-3n-E4B** | [▶️ Start on Colab](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma3N_(4B)-Conversational.ipynb) | 2x faster | 60% less |
|
| 43 |
+
| **Gemma-3n-E4B (Audio)** | [▶️ Start on Colab](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma3N_(4B)-Audio.ipynb) | 2x faster | 60% less |
|
| 44 |
+
| **GRPO with Gemma 3 (1B)** | [▶️ Start on Colab](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma3_(1B)-GRPO.ipynb) | 2x faster | 80% less |
|
| 45 |
+
| **Gemma 3 (4B) Vision** | [▶️ Start on Colab](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma3_(4B)-Vision.ipynb) | 2x faster | 60% less |
|
| 46 |
+
|
| 47 |
+
# Gemma 3 model card
|
| 48 |
+
|
| 49 |
+
**Model Page**: [Gemma](https://ai.google.dev/gemma/docs/core)
|
| 50 |
+
|
| 51 |
+
**Resources and Technical Documentation**:
|
| 52 |
+
|
| 53 |
+
* [Gemma 3 Technical Report][g3-tech-report]
|
| 54 |
+
* [Responsible Generative AI Toolkit][rai-toolkit]
|
| 55 |
+
* [Gemma on Kaggle][kaggle-gemma]
|
| 56 |
+
* [Gemma on Vertex Model Garden][vertex-mg-gemma3]
|
| 57 |
+
|
| 58 |
+
**Terms of Use**: [Terms][terms]
|
| 59 |
+
|
| 60 |
+
**Authors**: Google DeepMind
|
| 61 |
+
|
| 62 |
+
## Model Information
|
| 63 |
+
|
| 64 |
+
Summary description and brief definition of inputs and outputs.
|
| 65 |
+
|
| 66 |
+
### Description
|
| 67 |
+
|
| 68 |
+
Gemma is a family of lightweight, state-of-the-art open models from Google,
|
| 69 |
+
built from the same research and technology used to create the Gemini models.
|
| 70 |
+
Gemma 3 models are multimodal, handling text and image input and generating text
|
| 71 |
+
output, with open weights for both pre-trained variants and instruction-tuned
|
| 72 |
+
variants. Gemma 3 has a large, 128K context window, multilingual support in over
|
| 73 |
+
140 languages, and is available in more sizes than previous versions. Gemma 3
|
| 74 |
+
models are well-suited for a variety of text generation and image understanding
|
| 75 |
+
tasks, including question answering, summarization, and reasoning. Their
|
| 76 |
+
relatively small size makes it possible to deploy them in environments with
|
| 77 |
+
limited resources such as laptops, desktops or your own cloud infrastructure,
|
| 78 |
+
democratizing access to state of the art AI models and helping foster innovation
|
| 79 |
+
for everyone.
|
| 80 |
+
|
| 81 |
+
### Inputs and outputs
|
| 82 |
+
|
| 83 |
+
- **Input:**
|
| 84 |
+
- Text string, such as a question, a prompt, or a document to be summarized
|
| 85 |
+
- Images, normalized to 896 x 896 resolution and encoded to 256 tokens
|
| 86 |
+
each
|
| 87 |
+
- Total input context of 128K tokens for the 4B, 12B, and 27B sizes, and
|
| 88 |
+
32K tokens for the 1B and 270M sizes.
|
| 89 |
+
|
| 90 |
+
- **Output:**
|
| 91 |
+
- Generated text in response to the input, such as an answer to a
|
| 92 |
+
question, analysis of image content, or a summary of a document
|
| 93 |
+
- Total output context up to 128K tokens for the 4B, 12B, and 27B sizes,
|
| 94 |
+
and 32K tokens for the 1B and 270M sizes per request, subtracting the
|
| 95 |
+
request input tokens
|
| 96 |
+
|
| 97 |
+
### Citation
|
| 98 |
+
|
| 99 |
+
```none
|
| 100 |
+
@article{gemma_2025,
|
| 101 |
+
title={Gemma 3},
|
| 102 |
+
url={https://arxiv.org/abs/2503.19786},
|
| 103 |
+
publisher={Google DeepMind},
|
| 104 |
+
author={Gemma Team},
|
| 105 |
+
year={2025}
|
| 106 |
+
}
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
## Model Data
|
| 110 |
+
|
| 111 |
+
Data used for model training and how the data was processed.
|
| 112 |
+
|
| 113 |
+
### Training Dataset
|
| 114 |
+
|
| 115 |
+
These models were trained on a dataset of text data that includes a wide variety
|
| 116 |
+
of sources. The 27B model was trained with 14 trillion tokens, the 12B model was
|
| 117 |
+
trained with 12 trillion tokens, 4B model was trained with 4 trillion tokens,
|
| 118 |
+
the 1B with 2 trillion tokens, and the 270M with 6 trillion tokens. The
|
| 119 |
+
knowledge cutoff date for the training data was August 2024. Here are the key
|
| 120 |
+
components:
|
| 121 |
+
|
| 122 |
+
- Web Documents: A diverse collection of web text ensures the model is
|
| 123 |
+
exposed to a broad range of linguistic styles, topics, and vocabulary. The
|
| 124 |
+
training dataset includes content in over 140 languages.
|
| 125 |
+
- Code: Exposing the model to code helps it to learn the syntax and
|
| 126 |
+
patterns of programming languages, which improves its ability to generate
|
| 127 |
+
code and understand code-related questions.
|
| 128 |
+
- Mathematics: Training on mathematical text helps the model learn logical
|
| 129 |
+
reasoning, symbolic representation, and to address mathematical queries.
|
| 130 |
+
- Images: A wide range of images enables the model to perform image
|
| 131 |
+
analysis and visual data extraction tasks.
|
| 132 |
+
|
| 133 |
+
The combination of these diverse data sources is crucial for training a powerful
|
| 134 |
+
multimodal model that can handle a wide variety of different tasks and data
|
| 135 |
+
formats.
|
| 136 |
+
|
| 137 |
+
### Data Preprocessing
|
| 138 |
+
|
| 139 |
+
Here are the key data cleaning and filtering methods applied to the training
|
| 140 |
+
data:
|
| 141 |
+
|
| 142 |
+
- CSAM Filtering: Rigorous CSAM (Child Sexual Abuse Material) filtering
|
| 143 |
+
was applied at multiple stages in the data preparation process to ensure
|
| 144 |
+
the exclusion of harmful and illegal content.
|
| 145 |
+
- Sensitive Data Filtering: As part of making Gemma pre-trained models
|
| 146 |
+
safe and reliable, automated techniques were used to filter out certain
|
| 147 |
+
personal information and other sensitive data from training sets.
|
| 148 |
+
- Additional methods: Filtering based on content quality and safety in
|
| 149 |
+
line with [our policies][safety-policies].
|
| 150 |
+
|
| 151 |
+
## Implementation Information
|
| 152 |
+
|
| 153 |
+
Details about the model internals.
|
| 154 |
+
|
| 155 |
+
### Hardware
|
| 156 |
+
|
| 157 |
+
Gemma was trained using [Tensor Processing Unit (TPU)][tpu] hardware (TPUv4p,
|
| 158 |
+
TPUv5p and TPUv5e). Training vision-language models (VLMS) requires significant
|
| 159 |
+
computational power. TPUs, designed specifically for matrix operations common in
|
| 160 |
+
machine learning, offer several advantages in this domain:
|
| 161 |
+
|
| 162 |
+
- Performance: TPUs are specifically designed to handle the massive
|
| 163 |
+
computations involved in training VLMs. They can speed up training
|
| 164 |
+
considerably compared to CPUs.
|
| 165 |
+
- Memory: TPUs often come with large amounts of high-bandwidth memory,
|
| 166 |
+
allowing for the handling of large models and batch sizes during training.
|
| 167 |
+
This can lead to better model quality.
|
| 168 |
+
- Scalability: TPU Pods (large clusters of TPUs) provide a scalable
|
| 169 |
+
solution for handling the growing complexity of large foundation models.
|
| 170 |
+
You can distribute training across multiple TPU devices for faster and more
|
| 171 |
+
efficient processing.
|
| 172 |
+
- Cost-effectiveness: In many scenarios, TPUs can provide a more
|
| 173 |
+
cost-effective solution for training large models compared to CPU-based
|
| 174 |
+
infrastructure, especially when considering the time and resources saved
|
| 175 |
+
due to faster training.
|
| 176 |
+
- These advantages are aligned with
|
| 177 |
+
[Google's commitments to operate sustainably][sustainability].
|
| 178 |
+
|
| 179 |
+
### Software
|
| 180 |
+
|
| 181 |
+
Training was done using [JAX][jax] and [ML Pathways][ml-pathways].
|
| 182 |
+
|
| 183 |
+
JAX allows researchers to take advantage of the latest generation of hardware,
|
| 184 |
+
including TPUs, for faster and more efficient training of large models. ML
|
| 185 |
+
Pathways is Google's latest effort to build artificially intelligent systems
|
| 186 |
+
capable of generalizing across multiple tasks. This is specially suitable for
|
| 187 |
+
foundation models, including large language models like these ones.
|
| 188 |
+
|
| 189 |
+
Together, JAX and ML Pathways are used as described in the
|
| 190 |
+
[paper about the Gemini family of models][gemini-2-paper]; *"the 'single
|
| 191 |
+
controller' programming model of Jax and Pathways allows a single Python
|
| 192 |
+
process to orchestrate the entire training run, dramatically simplifying the
|
| 193 |
+
development workflow."*
|
| 194 |
+
|
| 195 |
+
## Evaluation
|
| 196 |
+
|
| 197 |
+
Model evaluation metrics and results.
|
| 198 |
+
|
| 199 |
+
### Benchmark Results
|
| 200 |
+
|
| 201 |
+
These models were evaluated against a large collection of different datasets and
|
| 202 |
+
metrics to cover different aspects of text generation. Evaluation results marked
|
| 203 |
+
with **IT** are for instruction-tuned models. Evaluation results marked with
|
| 204 |
+
**PT** are for pre-trained models.
|
| 205 |
+
|
| 206 |
+
|
| 207 |
|
| 208 |
# Gemma 3 model card
|
| 209 |
|