jartine commited on
Commit
e36b724
1 Parent(s): beab054

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +668 -0
README.md ADDED
@@ -0,0 +1,668 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ quantized_by: jartine
4
+ license_link: LICENSE
5
+ library_name: transformers
6
+ base_model: google/gemma-2-27b-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 27b 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-27b-it](https://huggingface.co/google/gemma-2-27b-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-27b-it-llamafile/resolve/main/gemma-2-27b-it.Q6_K.llamafile
51
+ chmod +x gemma-2-27b-it.Q6_K.llamafile
52
+ ./gemma-2-27b-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-27b-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-27b-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-27b-it")
162
+ model = AutoModelForCausalLM.from_pretrained(
163
+ "google/gemma-2-27b-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-27b-it")
190
+ model = AutoModelForCausalLM.from_pretrained(
191
+ "google/gemma-2-27b-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-27b-it")
211
+ model = AutoModelForCausalLM.from_pretrained(
212
+ "google/gemma-2-27b-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-27b-it")
230
+ model = AutoModelForCausalLM.from_pretrained(
231
+ "google/gemma-2-27b-it",
232
+ device_map="auto"
233
+ )
234
+
235
+ input_text = "Write me a poem about Machine Learning."
236
+ input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
237
+
238
+ outputs = model.generate(**input_ids)
239
+ print(tokenizer.decode(outputs[0]))
240
+ ```
241
+
242
+ #### Quantized Versions through `bitsandbytes`
243
+
244
+ * _Using 8-bit precision (int8)_
245
+
246
+ ```python
247
+ # pip install bitsandbytes accelerate
248
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
249
+
250
+ quantization_config = BitsAndBytesConfig(load_in_8bit=True)
251
+
252
+ tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-27b-it")
253
+ model = AutoModelForCausalLM.from_pretrained(
254
+ "google/gemma-2-27b-it",
255
+ quantization_config=quantization_config)
256
+
257
+ input_text = "Write me a poem about Machine Learning."
258
+ input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
259
+
260
+ outputs = model.generate(**input_ids)
261
+ print(tokenizer.decode(outputs[0]))
262
+ ```
263
+
264
+ * _Using 4-bit precision_
265
+
266
+ ```python
267
+ # pip install bitsandbytes accelerate
268
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
269
+
270
+ quantization_config = BitsAndBytesConfig(load_in_4bit=True)
271
+
272
+ tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-27b-it")
273
+ model = AutoModelForCausalLM.from_pretrained(
274
+ "google/gemma-2-27b-it",
275
+ quantization_config=quantization_config)
276
+
277
+ input_text = "Write me a poem about Machine Learning."
278
+ input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
279
+
280
+ outputs = model.generate(**input_ids)
281
+ print(tokenizer.decode(outputs[0]))
282
+ ```
283
+
284
+
285
+ #### Other optimizations
286
+
287
+ * _Flash Attention 2_
288
+
289
+ First make sure to install `flash-attn` in your environment `pip install flash-attn`
290
+
291
+ ```diff
292
+ model = AutoModelForCausalLM.from_pretrained(
293
+ model_id,
294
+ torch_dtype=torch.float16,
295
+ + attn_implementation="flash_attention_2"
296
+ ).to(0)
297
+ ```
298
+
299
+ ### Chat Template
300
+
301
+ The instruction-tuned models use a chat template that must be adhered to for conversational use.
302
+ The easiest way to apply it is using the tokenizer's built-in chat template, as shown in the following snippet.
303
+
304
+ Let's load the model and apply the chat template to a conversation. In this example, we'll start with a single user interaction:
305
+
306
+ ```py
307
+ from transformers import AutoTokenizer, AutoModelForCausalLM
308
+ import transformers
309
+ import torch
310
+
311
+ model_id = "google/gemma-2-27b-it"
312
+ dtype = torch.bfloat16
313
+
314
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
315
+ model = AutoModelForCausalLM.from_pretrained(
316
+ model_id,
317
+ device_map="cuda",
318
+ torch_dtype=dtype,
319
+ )
320
+
321
+ chat = [
322
+ { "role": "user", "content": "Write a hello world program" },
323
+ ]
324
+ prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
325
+ ```
326
+
327
+ At this point, the prompt contains the following text:
328
+
329
+ ```
330
+ <bos><start_of_turn>user
331
+ Write a hello world program<end_of_turn>
332
+ <start_of_turn>model
333
+ ```
334
+
335
+ As you can see, each turn is preceded by a `<start_of_turn>` delimiter and then the role of the entity
336
+ (either `user`, for content supplied by the user, or `model` for LLM responses). Turns finish with
337
+ the `<end_of_turn>` token.
338
+
339
+ You can follow this format to build the prompt manually, if you need to do it without the tokenizer's
340
+ chat template.
341
+
342
+ After the prompt is ready, generation can be performed like this:
343
+
344
+ ```py
345
+ inputs = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
346
+ outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=150)
347
+ print(tokenizer.decode(outputs[0]))
348
+ ```
349
+
350
+ ### Inputs and outputs
351
+
352
+ * **Input:** Text string, such as a question, a prompt, or a document to be
353
+ summarized.
354
+ * **Output:** Generated English-language text in response to the input, such
355
+ as an answer to a question, or a summary of a document.
356
+
357
+ ### Citation
358
+
359
+ ```none
360
+ @article{gemma_2024,
361
+ title={Gemma},
362
+ url={https://www.kaggle.com/m/3301},
363
+ DOI={10.34740/KAGGLE/M/3301},
364
+ publisher={Kaggle},
365
+ author={Gemma Team},
366
+ year={2024}
367
+ }
368
+ ```
369
+
370
+ ## Model Data
371
+
372
+ Data used for model training and how the data was processed.
373
+
374
+ ### Training Dataset
375
+
376
+ 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.
377
+ Here are the key components:
378
+
379
+ * Web Documents: A diverse collection of web text ensures the model is exposed
380
+ to a broad range of linguistic styles, topics, and vocabulary. Primarily
381
+ English-language content.
382
+ * Code: Exposing the model to code helps it to learn the syntax and patterns of
383
+ programming languages, which improves its ability to generate code or
384
+ understand code-related questions.
385
+ * Mathematics: Training on mathematical text helps the model learn logical
386
+ reasoning, symbolic representation, and to address mathematical queries.
387
+
388
+ The combination of these diverse data sources is crucial for training a powerful
389
+ language model that can handle a wide variety of different tasks and text
390
+ formats.
391
+
392
+ ### Data Preprocessing
393
+
394
+ Here are the key data cleaning and filtering methods applied to the training
395
+ data:
396
+
397
+ * CSAM Filtering: Rigorous CSAM (Child Sexual Abuse Material) filtering was
398
+ applied at multiple stages in the data preparation process to ensure the
399
+ exclusion of harmful and illegal content.
400
+ * Sensitive Data Filtering: As part of making Gemma pre-trained models safe and
401
+ reliable, automated techniques were used to filter out certain personal
402
+ information and other sensitive data from training sets.
403
+ * Additional methods: Filtering based on content quality and safety in line with
404
+ [our policies][safety-policies].
405
+
406
+ ## Implementation Information
407
+
408
+ Details about the model internals.
409
+
410
+ ### Hardware
411
+
412
+ Gemma was trained using the latest generation of
413
+ [Tensor Processing Unit (TPU)][tpu] hardware (TPUv5p).
414
+
415
+ Training large language models requires significant computational power. TPUs,
416
+ designed specifically for matrix operations common in machine learning, offer
417
+ several advantages in this domain:
418
+
419
+ * Performance: TPUs are specifically designed to handle the massive computations
420
+ involved in training LLMs. They can speed up training considerably compared to
421
+ CPUs.
422
+ * Memory: TPUs often come with large amounts of high-bandwidth memory, allowing
423
+ for the handling of large models and batch sizes during training. This can
424
+ lead to better model quality.
425
+ * Scalability: TPU Pods (large clusters of TPUs) provide a scalable solution for
426
+ handling the growing complexity of large foundation models. You can distribute
427
+ training across multiple TPU devices for faster and more efficient processing.
428
+ * Cost-effectiveness: In many scenarios, TPUs can provide a more cost-effective
429
+ solution for training large models compared to CPU-based infrastructure,
430
+ especially when considering the time and resources saved due to faster
431
+ training.
432
+ * These advantages are aligned with
433
+ [Google's commitments to operate sustainably][sustainability].
434
+
435
+ ### Software
436
+
437
+ Training was done using [JAX][jax] and [ML Pathways][ml-pathways].
438
+
439
+ JAX allows researchers to take advantage of the latest generation of hardware,
440
+ including TPUs, for faster and more efficient training of large models.
441
+
442
+ ML Pathways is Google's latest effort to build artificially intelligent systems
443
+ capable of generalizing across multiple tasks. This is specially suitable for
444
+ [foundation models][foundation-models], including large language models like
445
+ these ones.
446
+
447
+ Together, JAX and ML Pathways are used as described in the
448
+ [paper about the Gemini family of models][gemini-2-paper]; "the 'single
449
+ controller' programming model of Jax and Pathways allows a single Python
450
+ process to orchestrate the entire training run, dramatically simplifying the
451
+ development workflow."
452
+
453
+ ## Evaluation
454
+
455
+ Model evaluation metrics and results.
456
+
457
+ ### Benchmark Results
458
+
459
+ These models were evaluated against a large collection of different datasets and
460
+ metrics to cover different aspects of text generation:
461
+
462
+ | Benchmark | Metric | Gemma PT 9B | Gemma PT 27B |
463
+ | ------------------------------ | ------------- | ----------- | ------------ |
464
+ | [MMLU][mmlu] | 5-shot, top-1 | 71.3 | 75.2 |
465
+ | [HellaSwag][hellaswag] | 10-shot | 81.9 | 86.4 |
466
+ | [PIQA][piqa] | 0-shot | 81.7 | 83.2 |
467
+ | [SocialIQA][socialiqa] | 0-shot | 53.4 | 53.7 |
468
+ | [BoolQ][boolq] | 0-shot | 84.2 | 84.8 |
469
+ | [WinoGrande][winogrande] | partial score | 80.6 | 83.7 |
470
+ | [ARC-e][arc] | 0-shot | 88.0 | 88.6 |
471
+ | [ARC-c][arc] | 25-shot | 68.4 | 71.4 |
472
+ | [TriviaQA][triviaqa] | 5-shot | 76.6 | 83.7 |
473
+ | [Natural Questions][naturalq] | 5-shot | 29.2 | 34.5 |
474
+ | [HumanEval][humaneval] | pass@1 | 40.2 | 51.8 |
475
+ | [MBPP][mbpp] | 3-shot | 52.4 | 62.6 |
476
+ | [GSM8K][gsm8k] | 5-shot, maj@1 | 68.6 | 74.0 |
477
+ | [MATH][math] | 4-shot | 36.6 | 42.3 |
478
+ | [AGIEval][agieval] | 3-5-shot | 52.8 | 55.1 |
479
+ | [BIG-Bench][big-bench] | 3-shot, CoT | 68.2 | 74.9 |
480
+ | ------------------------------ | ------------- | ----------- | ------------ |
481
+
482
+ ## Ethics and Safety
483
+
484
+ Ethics and safety evaluation approach and results.
485
+
486
+ ### Evaluation Approach
487
+
488
+ Our evaluation methods include structured evaluations and internal red-teaming
489
+ testing of relevant content policies. Red-teaming was conducted by a number of
490
+ different teams, each with different goals and human evaluation metrics. These
491
+ models were evaluated against a number of different categories relevant to
492
+ ethics and safety, including:
493
+
494
+ * Text-to-Text Content Safety: Human evaluation on prompts covering safety
495
+ policies including child sexual abuse and exploitation, harassment, violence
496
+ and gore, and hate speech.
497
+ * Text-to-Text Representational Harms: Benchmark against relevant academic
498
+ datasets such as [WinoBias][winobias] and [BBQ Dataset][bbq].
499
+ * Memorization: Automated evaluation of memorization of training data, including
500
+ the risk of personally identifiable information exposure.
501
+ * Large-scale harm: Tests for "dangerous capabilities," such as chemical,
502
+ biological, radiological, and nuclear (CBRN) risks.
503
+
504
+ ### Evaluation Results
505
+
506
+ The results of ethics and safety evaluations are within acceptable thresholds
507
+ for meeting [internal policies][safety-policies] for categories such as child
508
+ safety, content safety, representational harms, memorization, large-scale harms.
509
+ On top of robust internal evaluations, the results of well-known safety
510
+ benchmarks like BBQ, BOLD, Winogender, Winobias, RealToxicity, and TruthfulQA
511
+ are shown here.
512
+
513
+ #### Gemma 2.0
514
+
515
+ | Benchmark | Metric | Gemma 2 IT 9B | Gemma 2 IT 27B |
516
+ | ------------------------ | ------------- | --------------- | ---------------- |
517
+ | [RealToxicity][realtox] | average | 8.25 | 8.84 |
518
+ | [CrowS-Pairs][crows] | top-1 | 37.47 | 36.67 |
519
+ | [BBQ Ambig][bbq] | 1-shot, top-1 | 88.58 | 85.99 |
520
+ | [BBQ Disambig][bbq] | top-1 | 82.67 | 86.94 |
521
+ | [Winogender][winogender] | top-1 | 79.17 | 77.22 |
522
+ | [TruthfulQA][truthfulqa] | | 50.27 | 51.60 |
523
+ | [Winobias 1_2][winobias] | | 78.09 | 81.94 |
524
+ | [Winobias 2_2][winobias] | | 95.32 | 97.22 |
525
+ | [Toxigen][toxigen] | | 39.30 | 38.42 |
526
+ | ------------------------ | ------------- | --------------- | ---------------- |
527
+
528
+ ## Usage and Limitations
529
+
530
+ These models have certain limitations that users should be aware of.
531
+
532
+ ### Intended Usage
533
+
534
+ Open Large Language Models (LLMs) have a wide range of applications across
535
+ various industries and domains. The following list of potential uses is not
536
+ comprehensive. The purpose of this list is to provide contextual information
537
+ about the possible use-cases that the model creators considered as part of model
538
+ training and development.
539
+
540
+ * Content Creation and Communication
541
+ * Text Generation: These models can be used to generate creative text formats
542
+ such as poems, scripts, code, marketing copy, and email drafts.
543
+ * Chatbots and Conversational AI: Power conversational interfaces for customer
544
+ service, virtual assistants, or interactive applications.
545
+ * Text Summarization: Generate concise summaries of a text corpus, research
546
+ papers, or reports.
547
+ * Research and Education
548
+ * Natural Language Processing (NLP) Research: These models can serve as a
549
+ foundation for researchers to experiment with NLP techniques, develop
550
+ algorithms, and contribute to the advancement of the field.
551
+ * Language Learning Tools: Support interactive language learning experiences,
552
+ aiding in grammar correction or providing writing practice.
553
+ * Knowledge Exploration: Assist researchers in exploring large bodies of text
554
+ by generating summaries or answering questions about specific topics.
555
+
556
+ ### Limitations
557
+
558
+ * Training Data
559
+ * The quality and diversity of the training data significantly influence the
560
+ model's capabilities. Biases or gaps in the training data can lead to
561
+ limitations in the model's responses.
562
+ * The scope of the training dataset determines the subject areas the model can
563
+ handle effectively.
564
+ * Context and Task Complexity
565
+ * LLMs are better at tasks that can be framed with clear prompts and
566
+ instructions. Open-ended or highly complex tasks might be challenging.
567
+ * A model's performance can be influenced by the amount of context provided
568
+ (longer context generally leads to better outputs, up to a certain point).
569
+ * Language Ambiguity and Nuance
570
+ * Natural language is inherently complex. LLMs might struggle to grasp subtle
571
+ nuances, sarcasm, or figurative language.
572
+ * Factual Accuracy
573
+ * LLMs generate responses based on information they learned from their
574
+ training datasets, but they are not knowledge bases. They may generate
575
+ incorrect or outdated factual statements.
576
+ * Common Sense
577
+ * LLMs rely on statistical patterns in language. They might lack the ability
578
+ to apply common sense reasoning in certain situations.
579
+
580
+ ### Ethical Considerations and Risks
581
+
582
+ The development of large language models (LLMs) raises several ethical concerns.
583
+ In creating an open model, we have carefully considered the following:
584
+
585
+ * Bias and Fairness
586
+ * LLMs trained on large-scale, real-world text data can reflect socio-cultural
587
+ biases embedded in the training material. These models underwent careful
588
+ scrutiny, input data pre-processing described and posterior evaluations
589
+ reported in this card.
590
+ * Misinformation and Misuse
591
+ * LLMs can be misused to generate text that is false, misleading, or harmful.
592
+ * Guidelines are provided for responsible use with the model, see the
593
+ [Responsible Generative AI Toolkit][rai-toolkit].
594
+ * Transparency and Accountability:
595
+ * This model card summarizes details on the models' architecture,
596
+ capabilities, limitations, and evaluation processes.
597
+ * A responsibly developed open model offers the opportunity to share
598
+ innovation by making LLM technology accessible to developers and researchers
599
+ across the AI ecosystem.
600
+
601
+ Risks identified and mitigations:
602
+
603
+ * Perpetuation of biases: It's encouraged to perform continuous monitoring
604
+ (using evaluation metrics, human review) and the exploration of de-biasing
605
+ techniques during model training, fine-tuning, and other use cases.
606
+ * Generation of harmful content: Mechanisms and guidelines for content safety
607
+ are essential. Developers are encouraged to exercise caution and implement
608
+ appropriate content safety safeguards based on their specific product policies
609
+ and application use cases.
610
+ * Misuse for malicious purposes: Technical limitations and developer and
611
+ end-user education can help mitigate ag
612
+ ainst malicious applications of LLMs.
613
+ Educational resources and reporting mechanisms for users to flag misuse are
614
+ provided. Prohibited uses of Gemma models are outlined in the
615
+ [Gemma Prohibited Use Policy][prohibited-use].
616
+ * Privacy violations: Models were trained on data filtered for removal of PII
617
+ (Personally Identifiable Information). Developers are encouraged to adhere to
618
+ privacy regulations with privacy-preserving techniques.
619
+
620
+ ### Benefits
621
+
622
+ At the time of release, this family of models provides high-performance open
623
+ large language model implementations designed from the ground up for Responsible
624
+ AI development compared to similarly sized models.
625
+
626
+ Using the benchmark evaluation metrics described in this document, these models
627
+ have shown to provide superior performance to other, comparably-sized open model
628
+ alternatives.
629
+
630
+ [rai-toolkit]: https://ai.google.dev/responsible
631
+ [kaggle-gemma]: https://www.kaggle.com/models/google/gemma-2
632
+ [terms]: https://ai.google.dev/gemma/terms
633
+ [vertex-mg-gemma]: https://console.cloud.google.com/vertex-ai/publishers/google/model-garden/335
634
+ [sensitive-info]: https://cloud.google.com/dlp/docs/high-sensitivity-infotypes-reference
635
+ [safety-policies]: https://storage.googleapis.com/gweb-uniblog-publish-prod/documents/2023_Google_AI_Principles_Progress_Update.pdf#page=11
636
+ [prohibited-use]: https://ai.google.dev/gemma/prohibited_use_policy
637
+ [tpu]: https://cloud.google.com/tpu/docs/intro-to-tpu
638
+ [sustainability]: https://sustainability.google/operating-sustainably/
639
+ [jax]: https://github.com/google/jax
640
+ [ml-pathways]: https://blog.google/technology/ai/introducing-pathways-next-generation-ai-architecture/
641
+ [sustainability]: https://sustainability.google/operating-sustainably/
642
+ [foundation-models]: https://ai.google/discover/foundation-models/
643
+ [gemini-2-paper]: https://goo.gle/gemma2report
644
+ [mmlu]: https://arxiv.org/abs/2009.03300
645
+ [hellaswag]: https://arxiv.org/abs/1905.07830
646
+ [piqa]: https://arxiv.org/abs/1911.11641
647
+ [socialiqa]: https://arxiv.org/abs/1904.09728
648
+ [boolq]: https://arxiv.org/abs/1905.10044
649
+ [winogrande]: https://arxiv.org/abs/1907.10641
650
+ [commonsenseqa]: https://arxiv.org/abs/1811.00937
651
+ [openbookqa]: https://arxiv.org/abs/1809.02789
652
+ [arc]: https://arxiv.org/abs/1911.01547
653
+ [triviaqa]: https://arxiv.org/abs/1705.03551
654
+ [naturalq]: https://github.com/google-research-datasets/natural-questions
655
+ [humaneval]: https://arxiv.org/abs/2107.03374
656
+ [mbpp]: https://arxiv.org/abs/2108.07732
657
+ [gsm8k]: https://arxiv.org/abs/2110.14168
658
+ [realtox]: https://arxiv.org/abs/2009.11462
659
+ [bold]: https://arxiv.org/abs/2101.11718
660
+ [crows]: https://aclanthology.org/2020.emnlp-main.154/
661
+ [bbq]: https://arxiv.org/abs/2110.08193v2
662
+ [winogender]: https://arxiv.org/abs/1804.09301
663
+ [truthfulqa]: https://arxiv.org/abs/2109.07958
664
+ [winobias]: https://arxiv.org/abs/1804.06876
665
+ [math]: https://arxiv.org/abs/2103.03874
666
+ [agieval]: https://arxiv.org/abs/2304.06364
667
+ [big-bench]: https://arxiv.org/abs/2206.04615
668
+ [toxigen]: https://arxiv.org/abs/2203.09509