jartine commited on
Commit
eea79de
1 Parent(s): 5c8cf1c

Update README.md

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