RichardErkhov commited on
Commit
82365bb
1 Parent(s): 4938896

uploaded readme

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