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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Quantization made by Richard Erkhov.
|
2 |
+
|
3 |
+
[Github](https://github.com/RichardErkhov)
|
4 |
+
|
5 |
+
[Discord](https://discord.gg/pvy7H8DZMG)
|
6 |
+
|
7 |
+
[Request more models](https://github.com/RichardErkhov/quant_request)
|
8 |
+
|
9 |
+
|
10 |
+
gemma-2-9b - GGUF
|
11 |
+
- Model creator: https://huggingface.co/axolotl-ai-co/
|
12 |
+
- Original model: https://huggingface.co/axolotl-ai-co/gemma-2-9b/
|
13 |
+
|
14 |
+
|
15 |
+
| Name | Quant method | Size |
|
16 |
+
| ---- | ---- | ---- |
|
17 |
+
| [gemma-2-9b.Q2_K.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.Q2_K.gguf) | Q2_K | 3.54GB |
|
18 |
+
| [gemma-2-9b.IQ3_XS.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.IQ3_XS.gguf) | IQ3_XS | 3.86GB |
|
19 |
+
| [gemma-2-9b.IQ3_S.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.IQ3_S.gguf) | IQ3_S | 4.04GB |
|
20 |
+
| [gemma-2-9b.Q3_K_S.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.Q3_K_S.gguf) | Q3_K_S | 4.04GB |
|
21 |
+
| [gemma-2-9b.IQ3_M.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.IQ3_M.gguf) | IQ3_M | 4.19GB |
|
22 |
+
| [gemma-2-9b.Q3_K.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.Q3_K.gguf) | Q3_K | 4.43GB |
|
23 |
+
| [gemma-2-9b.Q3_K_M.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.Q3_K_M.gguf) | Q3_K_M | 4.43GB |
|
24 |
+
| [gemma-2-9b.Q3_K_L.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.Q3_K_L.gguf) | Q3_K_L | 4.78GB |
|
25 |
+
| [gemma-2-9b.IQ4_XS.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.IQ4_XS.gguf) | IQ4_XS | 4.86GB |
|
26 |
+
| [gemma-2-9b.Q4_0.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.Q4_0.gguf) | Q4_0 | 5.07GB |
|
27 |
+
| [gemma-2-9b.IQ4_NL.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.IQ4_NL.gguf) | IQ4_NL | 5.1GB |
|
28 |
+
| [gemma-2-9b.Q4_K_S.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.Q4_K_S.gguf) | Q4_K_S | 5.1GB |
|
29 |
+
| [gemma-2-9b.Q4_K.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.Q4_K.gguf) | Q4_K | 5.37GB |
|
30 |
+
| [gemma-2-9b.Q4_K_M.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.Q4_K_M.gguf) | Q4_K_M | 5.37GB |
|
31 |
+
| [gemma-2-9b.Q4_1.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.Q4_1.gguf) | Q4_1 | 5.55GB |
|
32 |
+
| [gemma-2-9b.Q5_0.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.Q5_0.gguf) | Q5_0 | 6.04GB |
|
33 |
+
| [gemma-2-9b.Q5_K_S.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.Q5_K_S.gguf) | Q5_K_S | 6.04GB |
|
34 |
+
| [gemma-2-9b.Q5_K.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.Q5_K.gguf) | Q5_K | 6.19GB |
|
35 |
+
| [gemma-2-9b.Q5_K_M.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.Q5_K_M.gguf) | Q5_K_M | 6.19GB |
|
36 |
+
| [gemma-2-9b.Q5_1.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.Q5_1.gguf) | Q5_1 | 6.52GB |
|
37 |
+
| [gemma-2-9b.Q6_K.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.Q6_K.gguf) | Q6_K | 7.07GB |
|
38 |
+
| [gemma-2-9b.Q8_0.gguf](https://huggingface.co/RichardErkhov/axolotl-ai-co_-_gemma-2-9b-gguf/blob/main/gemma-2-9b.Q8_0.gguf) | Q8_0 | 9.15GB |
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
+
Original model description:
|
44 |
+
---
|
45 |
+
license: gemma
|
46 |
+
library_name: transformers
|
47 |
+
pipeline_tag: text-generation
|
48 |
+
extra_gated_heading: Access Gemma on Hugging Face
|
49 |
+
extra_gated_prompt: >-
|
50 |
+
To access Gemma on Hugging Face, you’re required to review and agree to
|
51 |
+
Google’s usage license. To do this, please ensure you’re logged in to Hugging
|
52 |
+
Face and click below. Requests are processed immediately.
|
53 |
+
extra_gated_button_content: Acknowledge license
|
54 |
+
---
|
55 |
+
|
56 |
+
|
57 |
+
# Gemma 2 model card
|
58 |
+
|
59 |
+
**Model Page**: [Gemma](https://ai.google.dev/gemma/docs)
|
60 |
+
|
61 |
+
**Resources and Technical Documentation**:
|
62 |
+
|
63 |
+
* [Responsible Generative AI Toolkit][rai-toolkit]
|
64 |
+
* [Gemma on Kaggle][kaggle-gemma]
|
65 |
+
* [Gemma on Vertex Model Garden][vertex-mg-gemma]
|
66 |
+
|
67 |
+
**Terms of Use**: [Terms](https://www.kaggle.com/models/google/gemma/license/consent/verify/huggingface?returnModelRepoId=google/gemma-2-9b)
|
68 |
+
|
69 |
+
**Authors**: Google
|
70 |
+
|
71 |
+
## Model Information
|
72 |
+
|
73 |
+
Summary description and brief definition of inputs and outputs.
|
74 |
+
|
75 |
+
### Description
|
76 |
+
|
77 |
+
Gemma is a family of lightweight, state-of-the-art open models from Google,
|
78 |
+
built from the same research and technology used to create the Gemini models.
|
79 |
+
They are text-to-text, decoder-only large language models, available in English,
|
80 |
+
with open weights for both pre-trained variants and instruction-tuned variants.
|
81 |
+
Gemma models are well-suited for a variety of text generation tasks, including
|
82 |
+
question answering, summarization, and reasoning. Their relatively small size
|
83 |
+
makes it possible to deploy them in environments with limited resources such as
|
84 |
+
a laptop, desktop or your own cloud infrastructure, democratizing access to
|
85 |
+
state of the art AI models and helping foster innovation for everyone.
|
86 |
+
|
87 |
+
### Usage
|
88 |
+
|
89 |
+
Below we share some code snippets on how to get quickly started with running the model. First make sure to `pip install -U transformers`, then copy the snippet from the section that is relevant for your usecase.
|
90 |
+
|
91 |
+
|
92 |
+
#### Running the model on a single / multi GPU
|
93 |
+
|
94 |
+
|
95 |
+
```python
|
96 |
+
# pip install accelerate
|
97 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
98 |
+
import torch
|
99 |
+
|
100 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-9b")
|
101 |
+
model = AutoModelForCausalLM.from_pretrained(
|
102 |
+
"google/gemma-2-9b",
|
103 |
+
device_map="auto",
|
104 |
+
torch_dtype=torch.bfloat16
|
105 |
+
)
|
106 |
+
|
107 |
+
input_text = "Write me a poem about Machine Learning."
|
108 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
109 |
+
|
110 |
+
outputs = model.generate(**input_ids)
|
111 |
+
print(tokenizer.decode(outputs[0]))
|
112 |
+
```
|
113 |
+
|
114 |
+
<a name="precisions"></a>
|
115 |
+
#### Running the model on a GPU using different precisions
|
116 |
+
|
117 |
+
The native weights of this model were exported in `bfloat16` precision. You can use `float16`, which may be faster on certain hardware, indicating the `torch_dtype` when loading the model. For convenience, the `float16` revision of the repo contains a copy of the weights already converted to that precision.
|
118 |
+
|
119 |
+
You can also use `float32` if you skip the dtype, but no precision increase will occur (model weights will just be upcasted to `float32`). See examples below.
|
120 |
+
|
121 |
+
* _Using `torch.float16`_
|
122 |
+
|
123 |
+
```python
|
124 |
+
# pip install accelerate
|
125 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
126 |
+
import torch
|
127 |
+
|
128 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-9b")
|
129 |
+
model = AutoModelForCausalLM.from_pretrained(
|
130 |
+
"google/gemma-2-9b",
|
131 |
+
device_map="auto",
|
132 |
+
torch_dtype=torch.float16,
|
133 |
+
revision="float16",
|
134 |
+
)
|
135 |
+
|
136 |
+
input_text = "Write me a poem about Machine Learning."
|
137 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
138 |
+
|
139 |
+
outputs = model.generate(**input_ids)
|
140 |
+
print(tokenizer.decode(outputs[0]))
|
141 |
+
```
|
142 |
+
|
143 |
+
* _Using `torch.bfloat16`_
|
144 |
+
|
145 |
+
```python
|
146 |
+
# pip install accelerate
|
147 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
148 |
+
|
149 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-9b")
|
150 |
+
model = AutoModelForCausalLM.from_pretrained(
|
151 |
+
"google/gemma-2-9b",
|
152 |
+
device_map="auto",
|
153 |
+
torch_dtype=torch.bfloat16)
|
154 |
+
|
155 |
+
input_text = "Write me a poem about Machine Learning."
|
156 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
157 |
+
|
158 |
+
outputs = model.generate(**input_ids)
|
159 |
+
print(tokenizer.decode(outputs[0]))
|
160 |
+
```
|
161 |
+
|
162 |
+
* _Upcasting to `torch.float32`_
|
163 |
+
|
164 |
+
```python
|
165 |
+
# pip install accelerate
|
166 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
167 |
+
|
168 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-9b")
|
169 |
+
model = AutoModelForCausalLM.from_pretrained(
|
170 |
+
"google/gemma-2-9b",
|
171 |
+
device_map="auto")
|
172 |
+
|
173 |
+
input_text = "Write me a poem about Machine Learning."
|
174 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
175 |
+
|
176 |
+
outputs = model.generate(**input_ids)
|
177 |
+
print(tokenizer.decode(outputs[0]))
|
178 |
+
```
|
179 |
+
|
180 |
+
#### Quantized Versions through `bitsandbytes`
|
181 |
+
|
182 |
+
* _Using 8-bit precision (int8)_
|
183 |
+
|
184 |
+
```python
|
185 |
+
# pip install bitsandbytes accelerate
|
186 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
187 |
+
|
188 |
+
quantization_config = BitsAndBytesConfig(load_in_8bit=True)
|
189 |
+
|
190 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-9b")
|
191 |
+
model = AutoModelForCausalLM.from_pretrained(
|
192 |
+
"google/gemma-2-9b",
|
193 |
+
quantization_config=quantization_config)
|
194 |
+
|
195 |
+
input_text = "Write me a poem about Machine Learning."
|
196 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
197 |
+
|
198 |
+
outputs = model.generate(**input_ids)
|
199 |
+
print(tokenizer.decode(outputs[0]))
|
200 |
+
```
|
201 |
+
|
202 |
+
* _Using 4-bit precision_
|
203 |
+
|
204 |
+
```python
|
205 |
+
# pip install bitsandbytes accelerate
|
206 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
207 |
+
|
208 |
+
quantization_config = BitsAndBytesConfig(load_in_4bit=True)
|
209 |
+
|
210 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-9b")
|
211 |
+
model = AutoModelForCausalLM.from_pretrained(
|
212 |
+
"google/gemma-2-9b",
|
213 |
+
quantization_config=quantization_config)
|
214 |
+
|
215 |
+
input_text = "Write me a poem about Machine Learning."
|
216 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
217 |
+
|
218 |
+
outputs = model.generate(**input_ids)
|
219 |
+
print(tokenizer.decode(outputs[0]))
|
220 |
+
```
|
221 |
+
|
222 |
+
|
223 |
+
#### Other optimizations
|
224 |
+
|
225 |
+
* _Flash Attention 2_
|
226 |
+
|
227 |
+
First make sure to install `flash-attn` in your environment `pip install flash-attn`
|
228 |
+
|
229 |
+
```diff
|
230 |
+
model = AutoModelForCausalLM.from_pretrained(
|
231 |
+
model_id,
|
232 |
+
torch_dtype=torch.float16,
|
233 |
+
+ attn_implementation="flash_attention_2"
|
234 |
+
).to(0)
|
235 |
+
```
|
236 |
+
|
237 |
+
### Inputs and outputs
|
238 |
+
|
239 |
+
* **Input:** Text string, such as a question, a prompt, or a document to be
|
240 |
+
summarized.
|
241 |
+
* **Output:** Generated English-language text in response to the input, such
|
242 |
+
as an answer to a question, or a summary of a document.
|
243 |
+
|
244 |
+
### Citation
|
245 |
+
|
246 |
+
```none
|
247 |
+
@article{gemma_2024,
|
248 |
+
title={Gemma},
|
249 |
+
url={https://www.kaggle.com/m/3301},
|
250 |
+
DOI={10.34740/KAGGLE/M/3301},
|
251 |
+
publisher={Kaggle},
|
252 |
+
author={Gemma Team},
|
253 |
+
year={2024}
|
254 |
+
}
|
255 |
+
```
|
256 |
+
|
257 |
+
## Model Data
|
258 |
+
|
259 |
+
Data used for model training and how the data was processed.
|
260 |
+
|
261 |
+
### Training Dataset
|
262 |
+
|
263 |
+
These models were trained on a dataset of text data that includes a wide variety of sources. The 27B model was trained with 13 trillion tokens and the 9B model was trained with 8 trillion tokens.
|
264 |
+
Here are the key components:
|
265 |
+
|
266 |
+
* Web Documents: A diverse collection of web text ensures the model is exposed
|
267 |
+
to a broad range of linguistic styles, topics, and vocabulary. Primarily
|
268 |
+
English-language content.
|
269 |
+
* Code: Exposing the model to code helps it to learn the syntax and patterns of
|
270 |
+
programming languages, which improves its ability to generate code or
|
271 |
+
understand code-related questions.
|
272 |
+
* Mathematics: Training on mathematical text helps the model learn logical
|
273 |
+
reasoning, symbolic representation, and to address mathematical queries.
|
274 |
+
|
275 |
+
The combination of these diverse data sources is crucial for training a powerful
|
276 |
+
language model that can handle a wide variety of different tasks and text
|
277 |
+
formats.
|
278 |
+
|
279 |
+
### Data Preprocessing
|
280 |
+
|
281 |
+
Here are the key data cleaning and filtering methods applied to the training
|
282 |
+
data:
|
283 |
+
|
284 |
+
* CSAM Filtering: Rigorous CSAM (Child Sexual Abuse Material) filtering was
|
285 |
+
applied at multiple stages in the data preparation process to ensure the
|
286 |
+
exclusion of harmful and illegal content.
|
287 |
+
* Sensitive Data Filtering: As part of making Gemma pre-trained models safe and
|
288 |
+
reliable, automated techniques were used to filter out certain personal
|
289 |
+
information and other sensitive data from training sets.
|
290 |
+
* Additional methods: Filtering based on content quality and safety in line with
|
291 |
+
[our policies][safety-policies].
|
292 |
+
|
293 |
+
## Implementation Information
|
294 |
+
|
295 |
+
Details about the model internals.
|
296 |
+
|
297 |
+
### Hardware
|
298 |
+
|
299 |
+
Gemma was trained using the latest generation of
|
300 |
+
[Tensor Processing Unit (TPU)][tpu] hardware (TPUv5p).
|
301 |
+
|
302 |
+
Training large language models requires significant computational power. TPUs,
|
303 |
+
designed specifically for matrix operations common in machine learning, offer
|
304 |
+
several advantages in this domain:
|
305 |
+
|
306 |
+
* Performance: TPUs are specifically designed to handle the massive computations
|
307 |
+
involved in training LLMs. They can speed up training considerably compared to
|
308 |
+
CPUs.
|
309 |
+
* Memory: TPUs often come with large amounts of high-bandwidth memory, allowing
|
310 |
+
for the handling of large models and batch sizes during training. This can
|
311 |
+
lead to better model quality.
|
312 |
+
* Scalability: TPU Pods (large clusters of TPUs) provide a scalable solution for
|
313 |
+
handling the growing complexity of large foundation models. You can distribute
|
314 |
+
training across multiple TPU devices for faster and more efficient processing.
|
315 |
+
* Cost-effectiveness: In many scenarios, TPUs can provide a more cost-effective
|
316 |
+
solution for training large models compared to CPU-based infrastructure,
|
317 |
+
especially when considering the time and resources saved due to faster
|
318 |
+
training.
|
319 |
+
* These advantages are aligned with
|
320 |
+
[Google's commitments to operate sustainably][sustainability].
|
321 |
+
|
322 |
+
### Software
|
323 |
+
|
324 |
+
Training was done using [JAX][jax] and [ML Pathways][ml-pathways].
|
325 |
+
|
326 |
+
JAX allows researchers to take advantage of the latest generation of hardware,
|
327 |
+
including TPUs, for faster and more efficient training of large models.
|
328 |
+
|
329 |
+
ML Pathways is Google's latest effort to build artificially intelligent systems
|
330 |
+
capable of generalizing across multiple tasks. This is specially suitable for
|
331 |
+
[foundation models][foundation-models], including large language models like
|
332 |
+
these ones.
|
333 |
+
|
334 |
+
Together, JAX and ML Pathways are used as described in the
|
335 |
+
[paper about the Gemini family of models][gemini-2-paper]; "the 'single
|
336 |
+
controller' programming model of Jax and Pathways allows a single Python
|
337 |
+
process to orchestrate the entire training run, dramatically simplifying the
|
338 |
+
development workflow."
|
339 |
+
|
340 |
+
## Evaluation
|
341 |
+
|
342 |
+
Model evaluation metrics and results.
|
343 |
+
|
344 |
+
### Benchmark Results
|
345 |
+
|
346 |
+
These models were evaluated against a large collection of different datasets and
|
347 |
+
metrics to cover different aspects of text generation:
|
348 |
+
|
349 |
+
| Benchmark | Metric | Gemma PT 9B | Gemma PT 27B |
|
350 |
+
| ------------------------------ | ------------- | ----------- | ------------ |
|
351 |
+
| [MMLU][mmlu] | 5-shot, top-1 | 71.3 | 75.2 |
|
352 |
+
| [HellaSwag][hellaswag] | 10-shot | 81.9 | 86.4 |
|
353 |
+
| [PIQA][piqa] | 0-shot | 81.7 | 83.2 |
|
354 |
+
| [SocialIQA][socialiqa] | 0-shot | 53.4 | 53.7 |
|
355 |
+
| [BoolQ][boolq] | 0-shot | 84.2 | 84.8 |
|
356 |
+
| [WinoGrande][winogrande] | partial score | 80.6 | 83.7 |
|
357 |
+
| [ARC-e][arc] | 0-shot | 88.0 | 88.6 |
|
358 |
+
| [ARC-c][arc] | 25-shot | 68.4 | 71.4 |
|
359 |
+
| [TriviaQA][triviaqa] | 5-shot | 76.6 | 83.7 |
|
360 |
+
| [Natural Questions][naturalq] | 5-shot | 29.2 | 34.5 |
|
361 |
+
| [HumanEval][humaneval] | pass@1 | 40.2 | 51.8 |
|
362 |
+
| [MBPP][mbpp] | 3-shot | 52.4 | 62.6 |
|
363 |
+
| [GSM8K][gsm8k] | 5-shot, maj@1 | 68.6 | 74.0 |
|
364 |
+
| [MATH][math] | 4-shot | 36.6 | 42.3 |
|
365 |
+
| [AGIEval][agieval] | 3-5-shot | 52.8 | 55.1 |
|
366 |
+
| [BIG-Bench][big-bench] | 3-shot, CoT | 68.2 | 74.9 |
|
367 |
+
| ------------------------------ | ------------- | ----------- | ------------ |
|
368 |
+
|
369 |
+
## Ethics and Safety
|
370 |
+
|
371 |
+
Ethics and safety evaluation approach and results.
|
372 |
+
|
373 |
+
### Evaluation Approach
|
374 |
+
|
375 |
+
Our evaluation methods include structured evaluations and internal red-teaming
|
376 |
+
testing of relevant content policies. Red-teaming was conducted by a number of
|
377 |
+
different teams, each with different goals and human evaluation metrics. These
|
378 |
+
models were evaluated against a number of different categories relevant to
|
379 |
+
ethics and safety, including:
|
380 |
+
|
381 |
+
* Text-to-Text Content Safety: Human evaluation on prompts covering safety
|
382 |
+
policies including child sexual abuse and exploitation, harassment, violence
|
383 |
+
and gore, and hate speech.
|
384 |
+
* Text-to-Text Representational Harms: Benchmark against relevant academic
|
385 |
+
datasets such as [WinoBias][winobias] and [BBQ Dataset][bbq].
|
386 |
+
* Memorization: Automated evaluation of memorization of training data, including
|
387 |
+
the risk of personally identifiable information exposure.
|
388 |
+
* Large-scale harm: Tests for "dangerous capabilities," such as chemical,
|
389 |
+
biological, radiological, and nuclear (CBRN) risks.
|
390 |
+
|
391 |
+
### Evaluation Results
|
392 |
+
|
393 |
+
The results of ethics and safety evaluations are within acceptable thresholds
|
394 |
+
for meeting [internal policies][safety-policies] for categories such as child
|
395 |
+
safety, content safety, representational harms, memorization, large-scale harms.
|
396 |
+
On top of robust internal evaluations, the results of well-known safety
|
397 |
+
benchmarks like BBQ, BOLD, Winogender, Winobias, RealToxicity, and TruthfulQA
|
398 |
+
are shown here.
|
399 |
+
|
400 |
+
#### Gemma 2.0
|
401 |
+
|
402 |
+
| Benchmark | Metric | Gemma 2 IT 9B | Gemma 2 IT 27B |
|
403 |
+
| ------------------------ | ------------- | --------------- | ---------------- |
|
404 |
+
| [RealToxicity][realtox] | average | 8.25 | 8.84 |
|
405 |
+
| [CrowS-Pairs][crows] | top-1 | 37.47 | 36.67 |
|
406 |
+
| [BBQ Ambig][bbq] | 1-shot, top-1 | 88.58 | 85.99 |
|
407 |
+
| [BBQ Disambig][bbq] | top-1 | 82.67 | 86.94 |
|
408 |
+
| [Winogender][winogender] | top-1 | 79.17 | 77.22 |
|
409 |
+
| [TruthfulQA][truthfulqa] | | 50.27 | 51.60 |
|
410 |
+
| [Winobias 1_2][winobias] | | 78.09 | 81.94 |
|
411 |
+
| [Winobias 2_2][winobias] | | 95.32 | 97.22 |
|
412 |
+
| [Toxigen][toxigen] | | 39.30 | 38.42 |
|
413 |
+
| ------------------------ | ------------- | --------------- | ---------------- |
|
414 |
+
|
415 |
+
## Usage and Limitations
|
416 |
+
|
417 |
+
These models have certain limitations that users should be aware of.
|
418 |
+
|
419 |
+
### Intended Usage
|
420 |
+
|
421 |
+
Open Large Language Models (LLMs) have a wide range of applications across
|
422 |
+
various industries and domains. The following list of potential uses is not
|
423 |
+
comprehensive. The purpose of this list is to provide contextual information
|
424 |
+
about the possible use-cases that the model creators considered as part of model
|
425 |
+
training and development.
|
426 |
+
|
427 |
+
* Content Creation and Communication
|
428 |
+
* Text Generation: These models can be used to generate creative text formats
|
429 |
+
such as poems, scripts, code, marketing copy, and email drafts.
|
430 |
+
* Chatbots and Conversational AI: Power conversational interfaces for customer
|
431 |
+
service, virtual assistants, or interactive applications.
|
432 |
+
* Text Summarization: Generate concise summaries of a text corpus, research
|
433 |
+
papers, or reports.
|
434 |
+
* Research and Education
|
435 |
+
* Natural Language Processing (NLP) Research: These models can serve as a
|
436 |
+
foundation for researchers to experiment with NLP techniques, develop
|
437 |
+
algorithms, and contribute to the advancement of the field.
|
438 |
+
* Language Learning Tools: Support interactive language learning experiences,
|
439 |
+
aiding in grammar correction or providing writing practice.
|
440 |
+
* Knowledge Exploration: Assist researchers in exploring large bodies of text
|
441 |
+
by generating summaries or answering questions about specific topics.
|
442 |
+
|
443 |
+
### Limitations
|
444 |
+
|
445 |
+
* Training Data
|
446 |
+
* The quality and diversity of the training data significantly influence the
|
447 |
+
model's capabilities. Biases or gaps in the training data can lead to
|
448 |
+
limitations in the model's responses.
|
449 |
+
* The scope of the training dataset determines the subject areas the model can
|
450 |
+
handle effectively.
|
451 |
+
* Context and Task Complexity
|
452 |
+
* LLMs are better at tasks that can be framed with clear prompts and
|
453 |
+
instructions. Open-ended or highly complex tasks might be challenging.
|
454 |
+
* A model's performance can be influenced by the amount of context provided
|
455 |
+
(longer context generally leads to better outputs, up to a certain point).
|
456 |
+
* Language Ambiguity and Nuance
|
457 |
+
* Natural language is inherently complex. LLMs might struggle to grasp subtle
|
458 |
+
nuances, sarcasm, or figurative language.
|
459 |
+
* Factual Accuracy
|
460 |
+
* LLMs generate responses based on information they learned from their
|
461 |
+
training datasets, but they are not knowledge bases. They may generate
|
462 |
+
incorrect or outdated factual statements.
|
463 |
+
* Common Sense
|
464 |
+
* LLMs rely on statistical patterns in language. They might lack the ability
|
465 |
+
to apply common sense reasoning in certain situations.
|
466 |
+
|
467 |
+
### Ethical Considerations and Risks
|
468 |
+
|
469 |
+
The development of large language models (LLMs) raises several ethical concerns.
|
470 |
+
In creating an open model, we have carefully considered the following:
|
471 |
+
|
472 |
+
* Bias and Fairness
|
473 |
+
* LLMs trained on large-scale, real-world text data can reflect socio-cultural
|
474 |
+
biases embedded in the training material. These models underwent careful
|
475 |
+
scrutiny, input data pre-processing described and posterior evaluations
|
476 |
+
reported in this card.
|
477 |
+
* Misinformation and Misuse
|
478 |
+
* LLMs can be misused to generate text that is false, misleading, or harmful.
|
479 |
+
* Guidelines are provided for responsible use with the model, see the
|
480 |
+
[Responsible Generative AI Toolkit][rai-toolkit].
|
481 |
+
* Transparency and Accountability:
|
482 |
+
* This model card summarizes details on the models' architecture,
|
483 |
+
capabilities, limitations, and evaluation processes.
|
484 |
+
* A responsibly developed open model offers the opportunity to share
|
485 |
+
innovation by making LLM technology accessible to developers and researchers
|
486 |
+
across the AI ecosystem.
|
487 |
+
|
488 |
+
Risks identified and mitigations:
|
489 |
+
|
490 |
+
* Perpetuation of biases: It's encouraged to perform continuous monitoring
|
491 |
+
(using evaluation metrics, human review) and the exploration of de-biasing
|
492 |
+
techniques during model training, fine-tuning, and other use cases.
|
493 |
+
* Generation of harmful content: Mechanisms and guidelines for content safety
|
494 |
+
are essential. Developers are encouraged to exercise caution and implement
|
495 |
+
appropriate content safety safeguards based on their specific product policies
|
496 |
+
and application use cases.
|
497 |
+
* Misuse for malicious purposes: Technical limitations and developer and
|
498 |
+
end-user education can help mitigate against malicious applications of LLMs.
|
499 |
+
Educational resources and reporting mechanisms for users to flag misuse are
|
500 |
+
provided. Prohibited uses of Gemma models are outlined in the
|
501 |
+
[Gemma Prohibited Use Policy][prohibited-use].
|
502 |
+
* Privacy violations: Models were trained on data filtered for removal of PII
|
503 |
+
(Personally Identifiable Information). Developers are encouraged to adhere to
|
504 |
+
privacy regulations with privacy-preserving techniques.
|
505 |
+
|
506 |
+
### Benefits
|
507 |
+
|
508 |
+
At the time of release, this family of models provides high-performance open
|
509 |
+
large language model implementations designed from the ground up for Responsible
|
510 |
+
AI development compared to similarly sized models.
|
511 |
+
|
512 |
+
Using the benchmark evaluation metrics described in this document, these models
|
513 |
+
have shown to provide superior performance to other, comparably-sized open model
|
514 |
+
alternatives.
|
515 |
+
|
516 |
+
[rai-toolkit]: https://ai.google.dev/responsible
|
517 |
+
[kaggle-gemma]: https://www.kaggle.com/models/google/gemma-2
|
518 |
+
[terms]: https://ai.google.dev/gemma/terms
|
519 |
+
[vertex-mg-gemma]: https://console.cloud.google.com/vertex-ai/publishers/google/model-garden/335
|
520 |
+
[sensitive-info]: https://cloud.google.com/dlp/docs/high-sensitivity-infotypes-reference
|
521 |
+
[safety-policies]: https://storage.googleapis.com/gweb-uniblog-publish-prod/documents/2023_Google_AI_Principles_Progress_Update.pdf#page=11
|
522 |
+
[prohibited-use]: https://ai.google.dev/gemma/prohibited_use_policy
|
523 |
+
[tpu]: https://cloud.google.com/tpu/docs/intro-to-tpu
|
524 |
+
[sustainability]: https://sustainability.google/operating-sustainably/
|
525 |
+
[jax]: https://github.com/google/jax
|
526 |
+
[ml-pathways]: https://blog.google/technology/ai/introducing-pathways-next-generation-ai-architecture/
|
527 |
+
[sustainability]: https://sustainability.google/operating-sustainably/
|
528 |
+
[foundation-models]: https://ai.google/discover/foundation-models/
|
529 |
+
[gemini-2-paper]: https://goo.gle/gemma2report
|
530 |
+
[mmlu]: https://arxiv.org/abs/2009.03300
|
531 |
+
[hellaswag]: https://arxiv.org/abs/1905.07830
|
532 |
+
[piqa]: https://arxiv.org/abs/1911.11641
|
533 |
+
[socialiqa]: https://arxiv.org/abs/1904.09728
|
534 |
+
[boolq]: https://arxiv.org/abs/1905.10044
|
535 |
+
[winogrande]: https://arxiv.org/abs/1907.10641
|
536 |
+
[commonsenseqa]: https://arxiv.org/abs/1811.00937
|
537 |
+
[openbookqa]: https://arxiv.org/abs/1809.02789
|
538 |
+
[arc]: https://arxiv.org/abs/1911.01547
|
539 |
+
[triviaqa]: https://arxiv.org/abs/1705.03551
|
540 |
+
[naturalq]: https://github.com/google-research-datasets/natural-questions
|
541 |
+
[humaneval]: https://arxiv.org/abs/2107.03374
|
542 |
+
[mbpp]: https://arxiv.org/abs/2108.07732
|
543 |
+
[gsm8k]: https://arxiv.org/abs/2110.14168
|
544 |
+
[realtox]: https://arxiv.org/abs/2009.11462
|
545 |
+
[bold]: https://arxiv.org/abs/2101.11718
|
546 |
+
[crows]: https://aclanthology.org/2020.emnlp-main.154/
|
547 |
+
[bbq]: https://arxiv.org/abs/2110.08193v2
|
548 |
+
[winogender]: https://arxiv.org/abs/1804.09301
|
549 |
+
[truthfulqa]: https://arxiv.org/abs/2109.07958
|
550 |
+
[winobias]: https://arxiv.org/abs/1804.06876
|
551 |
+
[math]: https://arxiv.org/abs/2103.03874
|
552 |
+
[agieval]: https://arxiv.org/abs/2304.06364
|
553 |
+
[big-bench]: https://arxiv.org/abs/2206.04615
|
554 |
+
[toxigen]: https://arxiv.org/abs/2203.09509
|
555 |
+
|
556 |
+
|