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