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