RichardErkhov commited on
Commit
84f120c
1 Parent(s): 644d792

uploaded readme

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