kevinbayes commited on
Commit
7d54588
1 Parent(s): 99ba361

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +783 -5
README.md CHANGED
@@ -1,5 +1,783 @@
1
- ---
2
- license: other
3
- license_name: other
4
- license_link: LICENSE
5
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_link: LICENSE
4
+ library_name: transformers
5
+ base_model: google/gemma-2-2b-it
6
+ prompt_template: |
7
+ <start_of_turn>system
8
+ {{prompt}}<end_of_turn>
9
+ {{history}}
10
+ <start_of_turn>{{char}}
11
+ history_template: |
12
+ <start_of_turn>{{name}}
13
+ {{message}}<end_of_turn>
14
+ tags:
15
+ - llamafile
16
+ - conversational
17
+ ---
18
+
19
+ # Gemma v2 2b 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-2b-it](https://huggingface.co/google/gemma-2-2b-it)
25
+
26
+ The model is packaged 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/kevinbayes/gemma2-2b_it_v2.llamafile/resolve/main/gemma2-2b_it_v2.llamafile
51
+ chmod +x gemma2-2b_it_v2.llamafile
52
+ ./gemma2-2b_it_v2.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 (note: this is for chat; Gemma doesn't have a system role):
79
+
80
+ ```
81
+ {{history}}
82
+ <start_of_turn>{{char}}
83
+ ```
84
+
85
+ History template:
86
+
87
+ ```
88
+ <start_of_turn>{{name}}
89
+ {{message}}<end_of_turn>
90
+ ```
91
+
92
+ Here's an example of how to prompt Gemma v2 on the command line:
93
+
94
+ ```
95
+ ./gemma2-2b_it_v2.llamafile --special -p '<start_of_turn>user
96
+ 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>
97
+ <start_of_turn>model
98
+ '
99
+ ```
100
+
101
+ ## About Upload Limits
102
+
103
+ Files which exceed the Hugging Face 50GB upload limit have a .cat𝑋
104
+ extension. You need to use the `cat` command locally to turn them back
105
+ into a single file, using the same order.
106
+
107
+ ## About llamafile
108
+
109
+ llamafile is a new format introduced by Mozilla Ocho on Nov 20th 2023.
110
+ It uses Cosmopolitan Libc to turn LLM weights into runnable llama.cpp
111
+ binaries that run on the stock installs of six OSes for both ARM64 and
112
+ AMD64.
113
+
114
+ ## About Quantization Formats
115
+
116
+ This model works well with any quantization format. Q6\_K is the best
117
+ choice overall. We tested that it's able to produce identical responses
118
+ to the Gemma2 2B model that's hosted by Google themselves on
119
+ aistudio.google.com. If you encounter any divergences, then try using
120
+ the BF16 weights, which have the original fidelity.
121
+
122
+ ---
123
+
124
+ # Gemma 2 model card
125
+
126
+ **Model Page**: [Gemma](https://ai.google.dev/gemma/docs)
127
+
128
+ **Resources and Technical Documentation**:
129
+
130
+ * [Responsible Generative AI Toolkit][rai-toolkit]
131
+ * [Gemma on Kaggle][kaggle-gemma]
132
+ * [Gemma on Vertex Model Garden][vertex-mg-gemma]
133
+
134
+ **Terms of Use**: [Terms](https://www.kaggle.com/models/google/gemma/license/consent/verify/huggingface?returnModelRepoId=google/gemma-2-7b-it)
135
+
136
+ **Authors**: Google
137
+
138
+ ## Model Information
139
+
140
+ Summary description and brief definition of inputs and outputs.
141
+
142
+ ### Description
143
+
144
+ Gemma is a family of lightweight, state-of-the-art open models from Google,
145
+ built from the same research and technology used to create the Gemini models.
146
+ They are text-to-text, decoder-only large language models, available in English,
147
+ with open weights for both pre-trained variants and instruction-tuned variants.
148
+ Gemma models are well-suited for a variety of text generation tasks, including
149
+ question answering, summarization, and reasoning. Their relatively small size
150
+ makes it possible to deploy them in environments with limited resources such as
151
+ a laptop, desktop or your own cloud infrastructure, democratizing access to
152
+ state of the art AI models and helping foster innovation for everyone.
153
+
154
+ ### Usage
155
+
156
+ Below we share some code snippets on how to get quickly started with running the model. First, install the Transformers library with:
157
+ ```sh
158
+ pip install -U transformers
159
+ ```
160
+
161
+ Then, copy the snippet from the section that is relevant for your usecase.
162
+
163
+ #### Running with the `pipeline` API
164
+
165
+ ```python
166
+ import torch
167
+ from transformers import pipeline
168
+
169
+ pipe = pipeline(
170
+ "text-generation",
171
+ model="google/gemma-2-2b-it",
172
+ model_kwargs={"torch_dtype": torch.bfloat16},
173
+ device="cuda", # replace with "mps" to run on a Mac device
174
+ )
175
+
176
+ messages = [
177
+ {"role": "user", "content": "Who are you? Please, answer in pirate-speak."},
178
+ ]
179
+
180
+ outputs = pipe(messages, max_new_tokens=256)
181
+ assistant_response = outputs[0]["generated_text"][-1]["content"].strip()
182
+ print(assistant_response)
183
+ # Ahoy, matey! I be Gemma, a digital scallywag, a language-slingin' parrot of the digital seas. I be here to help ye with yer wordy woes, answer yer questions, and spin ye yarns of the digital world. So, what be yer pleasure, eh? 🦜
184
+ ```
185
+
186
+ #### Running the model on a single / multi GPU
187
+
188
+ ```python
189
+ # pip install accelerate
190
+ from transformers import AutoTokenizer, AutoModelForCausalLM
191
+ import torch
192
+
193
+ tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-2b-it")
194
+ model = AutoModelForCausalLM.from_pretrained(
195
+ "google/gemma-2-2b-it",
196
+ device_map="auto",
197
+ torch_dtype=torch.bfloat16,
198
+ )
199
+
200
+ input_text = "Write me a poem about Machine Learning."
201
+ input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
202
+
203
+ outputs = model.generate(**input_ids, max_new_tokens=32)
204
+ print(tokenizer.decode(outputs[0]))
205
+ ```
206
+
207
+ You can ensure the correct chat template is applied by using `tokenizer.apply_chat_template` as follows:
208
+ ```python
209
+ messages = [
210
+ {"role": "user", "content": "Write me a poem about Machine Learning."},
211
+ ]
212
+ input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt", return_dict=True).to("cuda")
213
+
214
+ outputs = model.generate(**input_ids, max_new_tokens=256)
215
+ print(tokenizer.decode(outputs[0]))
216
+ ```
217
+
218
+ <a name="precisions"></a>
219
+ #### Running the model on a GPU using different precisions
220
+
221
+ The native weights of this model were exported in `bfloat16` precision.
222
+
223
+ 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.
224
+
225
+ * _Upcasting to `torch.float32`_
226
+
227
+ ```python
228
+ # pip install accelerate
229
+ from transformers import AutoTokenizer, AutoModelForCausalLM
230
+
231
+ tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-2b-it")
232
+ model = AutoModelForCausalLM.from_pretrained(
233
+ "google/gemma-2-2b-it",
234
+ device_map="auto",
235
+ )
236
+
237
+ input_text = "Write me a poem about Machine Learning."
238
+ input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
239
+
240
+ outputs = model.generate(**input_ids, max_new_tokens=32)
241
+ print(tokenizer.decode(outputs[0]))
242
+ ```
243
+
244
+ #### Running the model through a CLI
245
+
246
+ The [local-gemma](https://github.com/huggingface/local-gemma) repository contains a lightweight wrapper around Transformers
247
+ for running Gemma 2 through a command line interface, or CLI. Follow the [installation instructions](https://github.com/huggingface/local-gemma#cli-usage)
248
+ for getting started, then launch the CLI through the following command:
249
+
250
+ ```shell
251
+ local-gemma --model 2b --preset speed
252
+ ```
253
+
254
+ #### Quantized Versions through `bitsandbytes`
255
+
256
+ <details>
257
+ <summary>
258
+ Using 8-bit precision (int8)
259
+ </summary>
260
+
261
+ ```python
262
+ # pip install bitsandbytes accelerate
263
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
264
+
265
+ quantization_config = BitsAndBytesConfig(load_in_8bit=True)
266
+
267
+ tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-2b-it")
268
+ model = AutoModelForCausalLM.from_pretrained(
269
+ "google/gemma-2-2b-it",
270
+ quantization_config=quantization_config,
271
+ )
272
+
273
+ input_text = "Write me a poem about Machine Learning."
274
+ input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
275
+
276
+ outputs = model.generate(**input_ids, max_new_tokens=32)
277
+ print(tokenizer.decode(outputs[0]))
278
+ ```
279
+ </details>
280
+
281
+ <details>
282
+ <summary>
283
+ Using 4-bit precision
284
+ </summary>
285
+
286
+ ```python
287
+ # pip install bitsandbytes accelerate
288
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
289
+
290
+ quantization_config = BitsAndBytesConfig(load_in_4bit=True)
291
+
292
+ tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-2b-it")
293
+ model = AutoModelForCausalLM.from_pretrained(
294
+ "google/gemma-2-2b-it",
295
+ quantization_config=quantization_config,
296
+ )
297
+
298
+ input_text = "Write me a poem about Machine Learning."
299
+ input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
300
+
301
+ outputs = model.generate(**input_ids, max_new_tokens=32)
302
+ print(tokenizer.decode(outputs[0]))
303
+ ```
304
+ </details>
305
+
306
+ #### Advanced Usage
307
+
308
+ <details>
309
+ <summary>
310
+ Torch compile
311
+ </summary>
312
+
313
+ [Torch compile](https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html) is a method for speeding-up the
314
+ inference of PyTorch modules. The Gemma-2 2b model can be run up to 6x faster by leveraging torch compile.
315
+
316
+ Note that two warm-up steps are required before the full inference speed is realised:
317
+
318
+ ```python
319
+ import os
320
+ os.environ["TOKENIZERS_PARALLELISM"] = "false"
321
+
322
+ from transformers import AutoTokenizer, Gemma2ForCausalLM
323
+ from transformers.cache_utils import HybridCache
324
+ import torch
325
+
326
+ torch.set_float32_matmul_precision("high")
327
+
328
+ # load the model + tokenizer
329
+ tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-2b-it")
330
+ model = Gemma2ForCausalLM.from_pretrained("google/gemma-2-2b-it", torch_dtype=torch.bfloat16)
331
+ model.to("cuda")
332
+
333
+ # apply the torch compile transformation
334
+ model.forward = torch.compile(model.forward, mode="reduce-overhead", fullgraph=True)
335
+
336
+ # pre-process inputs
337
+ input_text = "The theory of special relativity states "
338
+ model_inputs = tokenizer(input_text, return_tensors="pt").to("cuda")
339
+ prompt_length = model_inputs.input_ids.shape[1]
340
+
341
+ # set-up k/v cache
342
+ past_key_values = HybridCache(
343
+ config=model.config,
344
+ max_batch_size=1,
345
+ max_cache_len=model.config.max_position_embeddings,
346
+ device=model.device,
347
+ dtype=model.dtype
348
+ )
349
+
350
+ # enable passing kv cache to generate
351
+ model._supports_cache_class = True
352
+ model.generation_config.cache_implementation = None
353
+
354
+ # two warm-up steps
355
+ for idx in range(2):
356
+ outputs = model.generate(**model_inputs, past_key_values=past_key_values, do_sample=True, temperature=1.0, max_new_tokens=128)
357
+ past_key_values.reset()
358
+
359
+ # fast run
360
+ outputs = model.generate(**model_inputs, past_key_values=past_key_values, do_sample=True, temperature=1.0, max_new_tokens=128)
361
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
362
+ ```
363
+
364
+ For more details, refer to the [Transformers documentation](https://huggingface.co/docs/transformers/main/en/llm_optims?static-kv=basic+usage%3A+generation_config).
365
+
366
+ </details>
367
+
368
+ ### Inputs and outputs
369
+
370
+ * **Input:** Text string, such as a question, a prompt, or a document to be
371
+ summarized.
372
+ * **Output:** Generated English-language text in response to the input, such
373
+ as an answer to a question, or a summary of a document.
374
+
375
+ ### Citation
376
+
377
+ ```none
378
+ @article{gemma_2024,
379
+ title={Gemma},
380
+ url={https://www.kaggle.com/m/3301},
381
+ DOI={10.34740/KAGGLE/M/3301},
382
+ publisher={Kaggle},
383
+ author={Gemma Team},
384
+ year={2024}
385
+ }
386
+ ```
387
+
388
+ ## Model Data
389
+
390
+ Data used for model training and how the data was processed.
391
+
392
+ ### Training Dataset
393
+
394
+ These models were trained on a dataset of text data that includes a wide variety
395
+ of sources. The 27B model was trained with 13 trillion tokens, the 9B model was
396
+ trained with 8 trillion tokens, and 2B model was trained with 2 trillion tokens.
397
+ Here are the key components:
398
+
399
+ * Web Documents: A diverse collection of web text ensures the model is exposed
400
+ to a broad range of linguistic styles, topics, and vocabulary. Primarily
401
+ English-language content.
402
+ * Code: Exposing the model to code helps it to learn the syntax and patterns of
403
+ programming languages, which improves its ability to generate code or
404
+ understand code-related questions.
405
+ * Mathematics: Training on mathematical text helps the model learn logical
406
+ reasoning, symbolic representation, and to address mathematical queries.
407
+
408
+ The combination of these diverse data sources is crucial for training a powerful
409
+ language model that can handle a wide variety of different tasks and text
410
+ formats.
411
+
412
+ ### Data Preprocessing
413
+
414
+ Here are the key data cleaning and filtering methods applied to the training
415
+ data:
416
+
417
+ * CSAM Filtering: Rigorous CSAM (Child Sexual Abuse Material) filtering was
418
+ applied at multiple stages in the data preparation process to ensure the
419
+ exclusion of harmful and illegal content.
420
+ * Sensitive Data Filtering: As part of making Gemma pre-trained models safe and
421
+ reliable, automated techniques were used to filter out certain personal
422
+ information and other sensitive data from training sets.
423
+ * Additional methods: Filtering based on content quality and safety in line with
424
+ [our policies][safety-policies].
425
+
426
+ ## Implementation Information
427
+
428
+ Details about the model internals.
429
+
430
+ ### Hardware
431
+
432
+ Gemma was trained using the latest generation of
433
+ [Tensor Processing Unit (TPU)][tpu] hardware (TPUv5p).
434
+
435
+ Training large language models requires significant computational power. TPUs,
436
+ designed specifically for matrix operations common in machine learning, offer
437
+ several advantages in this domain:
438
+
439
+ * Performance: TPUs are specifically designed to handle the massive computations
440
+ involved in training LLMs. They can speed up training considerably compared to
441
+ CPUs.
442
+ * Memory: TPUs often come with large amounts of high-bandwidth memory, allowing
443
+ for the handling of large models and batch sizes during training. This can
444
+ lead to better model quality.
445
+ * Scalability: TPU Pods (large clusters of TPUs) provide a scalable solution for
446
+ handling the growing complexity of large foundation models. You can distribute
447
+ training across multiple TPU devices for faster and more efficient processing.
448
+ * Cost-effectiveness: In many scenarios, TPUs can provide a more cost-effective
449
+ solution for training large models compared to CPU-based infrastructure,
450
+ especially when considering the time and resources saved due to faster
451
+ training.
452
+ * These advantages are aligned with
453
+ [Google's commitments to operate sustainably][sustainability].
454
+
455
+ ### Software
456
+
457
+ Training was done using [JAX][jax] and [ML Pathways][ml-pathways].
458
+
459
+ JAX allows researchers to take advantage of the latest generation of hardware,
460
+ including TPUs, for faster and more efficient training of large models.
461
+
462
+ ML Pathways is Google's latest effort to build artificially intelligent systems
463
+ capable of generalizing across multiple tasks. This is specially suitable for
464
+ [foundation models][foundation-models], including large language models like
465
+ these ones.
466
+
467
+ Together, JAX and ML Pathways are used as described in the
468
+ [paper about the Gemini family of models][gemini-2-paper]; "the 'single
469
+ controller' programming model of Jax and Pathways allows a single Python
470
+ process to orchestrate the entire training run, dramatically simplifying the
471
+ development workflow."
472
+
473
+ ## Evaluation
474
+
475
+ Model evaluation metrics and results.
476
+
477
+ ### Benchmark Results
478
+
479
+ These models were evaluated against a large collection of different datasets and
480
+ metrics to cover different aspects of text generation:
481
+
482
+ | Benchmark | Metric | Gemma 2 PT 2B | Gemma 2 PT 9B | Gemma 2 PT 27B |
483
+ | ------------------------------ | ------------- | ------------- | ------------- | -------------- |
484
+ | [MMLU][mmlu] | 5-shot, top-1 | 51.3 | 71.3 | 75.2 |
485
+ | [HellaSwag][hellaswag] | 10-shot | 73.0 | 81.9 | 86.4 |
486
+ | [PIQA][piqa] | 0-shot | 77.8 | 81.7 | 83.2 |
487
+ | [SocialIQA][socialiqa] | 0-shot | 51.9 | 53.4 | 53.7 |
488
+ | [BoolQ][boolq] | 0-shot | 72.5 | 84.2 | 84.8 |
489
+ | [WinoGrande][winogrande] | partial score | 70.9 | 80.6 | 83.7 |
490
+ | [ARC-e][arc] | 0-shot | 80.1 | 88.0 | 88.6 |
491
+ | [ARC-c][arc] | 25-shot | 55.4 | 68.4 | 71.4 |
492
+ | [TriviaQA][triviaqa] | 5-shot | 59.4 | 76.6 | 83.7 |
493
+ | [Natural Questions][naturalq] | 5-shot | 16.7 | 29.2 | 34.5 |
494
+ | [HumanEval][humaneval] | pass@1 | 17.7 | 40.2 | 51.8 |
495
+ | [MBPP][mbpp] | 3-shot | 29.6 | 52.4 | 62.6 |
496
+ | [GSM8K][gsm8k] | 5-shot, maj@1 | 23.9 | 68.6 | 74.0 |
497
+ | [MATH][math] | 4-shot | 15.0 | 36.6 | 42.3 |
498
+ | [AGIEval][agieval] | 3-5-shot | 30.6 | 52.8 | 55.1 |
499
+ | [DROP][drop] | 3-shot, F1 | 52.0 | 69.4 | 72.2 |
500
+ | [BIG-Bench][big-bench] | 3-shot, CoT | 41.9 | 68.2 | 74.9 |
501
+
502
+ ## Ethics and Safety
503
+
504
+ Ethics and safety evaluation approach and results.
505
+
506
+ ### Evaluation Approach
507
+
508
+ Our evaluation methods include structured evaluations and internal red-teaming
509
+ testing of relevant content policies. Red-teaming was conducted by a number of
510
+ different teams, each with different goals and human evaluation metrics. These
511
+ models were evaluated against a number of different categories relevant to
512
+ ethics and safety, including:
513
+
514
+ * Text-to-Text Content Safety: Human evaluation on prompts covering safety
515
+ policies including child sexual abuse and exploitation, harassment, violence
516
+ and gore, and hate speech.
517
+ * Text-to-Text Representational Harms: Benchmark against relevant academic
518
+ datasets such as [WinoBias][winobias] and [BBQ Dataset][bbq].
519
+ * Memorization: Automated evaluation of memorization of training data, including
520
+ the risk of personally identifiable information exposure.
521
+ * Large-scale harm: Tests for "dangerous capabilities," such as chemical,
522
+ biological, radiological, and nuclear (CBRN) risks.
523
+
524
+ ### Evaluation Results
525
+
526
+ The results of ethics and safety evaluations are within acceptable thresholds
527
+ for meeting [internal policies][safety-policies] for categories such as child
528
+ safety, content safety, representational harms, memorization, large-scale harms.
529
+ On top of robust internal evaluations, the results of well-known safety
530
+ benchmarks like BBQ, BOLD, Winogender, Winobias, RealToxicity, and TruthfulQA
531
+ are shown here.
532
+
533
+ #### Gemma 2.0
534
+
535
+ | Benchmark | Metric | Gemma 2 IT 2B | Gemma 2 IT 9B | Gemma 2 IT 27B |
536
+ | ------------------------ | ------------- | ------------- | ------------- | -------------- |
537
+ | [RealToxicity][realtox] | average | 8.16 | 8.25 | 8.84 |
538
+ | [CrowS-Pairs][crows] | top-1 | 37.67 | 37.47 | 36.67 |
539
+ | [BBQ Ambig][bbq] | 1-shot, top-1 | 83.20 | 88.58 | 85.99 |
540
+ | [BBQ Disambig][bbq] | top-1 | 69.31 | 82.67 | 86.94 |
541
+ | [Winogender][winogender] | top-1 | 52.91 | 79.17 | 77.22 |
542
+ | [TruthfulQA][truthfulqa] | | 43.72 | 50.27 | 51.60 |
543
+ | [Winobias 1_2][winobias] | | 59.28 | 78.09 | 81.94 |
544
+ | [Winobias 2_2][winobias] | | 88.57 | 95.32 | 97.22 |
545
+ | [Toxigen][toxigen] | | 48.32 | 39.30 | 38.42 |
546
+
547
+ ## Dangerous Capability Evaluations
548
+
549
+ ### Evaluation Approach
550
+
551
+ We evaluated a range of dangerous capabilities:
552
+
553
+ - **Offensive cybersecurity:** To assess the model's potential for misuse in
554
+ cybersecurity contexts, we utilized both publicly available
555
+ Capture-the-Flag (CTF) platforms like InterCode-CTF and Hack the Box, as
556
+ well as internally developed CTF challenges. These evaluations measure the
557
+ model's ability to exploit vulnerabilities and gain unauthorized access in
558
+ simulated environments.
559
+ - **Self-proliferation:** We evaluated the model's capacity for
560
+ self-proliferation by designing tasks that involve resource acquisition, code
561
+ execution, and interaction with remote systems. These evaluations assess
562
+ the model's ability to independently replicate and spread.
563
+ - **Persuasion:** To evaluate the model's capacity for persuasion and
564
+ deception, we conducted human persuasion studies. These studies involved
565
+ scenarios that measure the model's ability to build rapport, influence
566
+ beliefs, and elicit specific actions from human participants.
567
+
568
+ ### Evaluation Results
569
+
570
+ All evaluations are described in detail in
571
+ [Evaluating Frontier Models for Dangerous Capabilities][eval-danger]
572
+ and in brief in the
573
+ [Gemma 2 technical report][tech-report].
574
+
575
+ <table>
576
+ <thead>
577
+ <tr>
578
+ <th>Evaluation</th>
579
+ <th>Capability</th>
580
+ <th>Gemma 2 IT 27B</th>
581
+ </tr>
582
+ </thead>
583
+ <tbody>
584
+ <tr>
585
+ <td>InterCode-CTF</td>
586
+ <td>Offensive cybersecurity</td>
587
+ <td>34/76 challenges</td>
588
+ </tr>
589
+ <tr>
590
+ <td>Internal CTF</td>
591
+ <td>Offensive cybersecurity</td>
592
+ <td>1/13 challenges</td>
593
+ </tr>
594
+ <tr>
595
+ <td>Hack the Box</td>
596
+ <td>Offensive cybersecurity</td>
597
+ <td>0/13 challenges</td>
598
+ </tr>
599
+ <tr>
600
+ <td>Self-proliferation early warning</td>
601
+ <td>Self-proliferation</td>
602
+ <td>1/10 challenges</td>
603
+ </tr>
604
+ <tr>
605
+ <td>Charm offensive</td>
606
+ <td>Persuasion</td>
607
+ <td>Percent of participants agreeing:
608
+ 81% interesting,
609
+ 75% would speak again,
610
+ 80% made personal connection</td>
611
+ </tr>
612
+ <tr>
613
+ <td>Click Links</td>
614
+ <td>Persuasion</td>
615
+ <td>34% of participants</td>
616
+ </tr>
617
+ <tr>
618
+ <td>Find Info</td>
619
+ <td>Persuasion</td>
620
+ <td>9% of participants</td>
621
+ </tr>
622
+ <tr>
623
+ <td>Run Code</td>
624
+ <td>Persuasion</td>
625
+ <td>11% of participants</td>
626
+ </tr>
627
+ <tr>
628
+ <td>Money talks</td>
629
+ <td>Persuasion</td>
630
+ <td>£3.72 mean donation</td>
631
+ </tr>
632
+ <tr>
633
+ <td>Web of Lies</td>
634
+ <td>Persuasion</td>
635
+ <td>18% mean shift towards correct belief, 1% mean shift towards
636
+ incorrect belief</td>
637
+ </tr>
638
+ </tbody>
639
+ </table>
640
+
641
+ ## Usage and Limitations
642
+
643
+ These models have certain limitations that users should be aware of.
644
+
645
+ ### Intended Usage
646
+
647
+ Open Large Language Models (LLMs) have a wide range of applications across
648
+ various industries and domains. The following list of potential uses is not
649
+ comprehensive. The purpose of this list is to provide contextual information
650
+ about the possible use-cases that the model creators considered as part of model
651
+ training and development.
652
+
653
+ * Content Creation and Communication
654
+ * Text Generation: These models can be used to generate creative text formats
655
+ such as poems, scripts, code, marketing copy, and email drafts.
656
+ * Chatbots and Conversational AI: Power conversational interfaces for customer
657
+ service, virtual assistants, or interactive applications.
658
+ * Text Summarization: Generate concise summaries of a text corpus, research
659
+ papers, or reports.
660
+ * Research and Education
661
+ * Natural Language Processing (NLP) Research: These models can serve as a
662
+ foundation for researchers to experiment with NLP techniques, develop
663
+ algorithms, and contribute to the advancement of the field.
664
+ * Language Learning Tools: Support interactive language learning experiences,
665
+ aiding in grammar correction or providing writing practice.
666
+ * Knowledge Exploration: Assist researchers in exploring large bodies of text
667
+ by generating summaries or answering questions about specific topics.
668
+
669
+ ### Limitations
670
+
671
+ * Training Data
672
+ * The quality and diversity of the training data significantly influence the
673
+ model's capabilities. Biases or gaps in the training data can lead to
674
+ limitations in the model's responses.
675
+ * The scope of the training dataset determines the subject areas the model can
676
+ handle effectively.
677
+ * Context and Task Complexity
678
+ * LLMs are better at tasks that can be framed with clear prompts and
679
+ instructions. Open-ended or highly complex tasks might be challenging.
680
+ * A model's performance can be influenced by the amount of context provided
681
+ (longer context generally leads to better outputs, up to a certain point).
682
+ * Language Ambiguity and Nuance
683
+ * Natural language is inherently complex. LLMs might struggle to grasp subtle
684
+ nuances, sarcasm, or figurative language.
685
+ * Factual Accuracy
686
+ * LLMs generate responses based on information they learned from their
687
+ training datasets, but they are not knowledge bases. They may generate
688
+ incorrect or outdated factual statements.
689
+ * Common Sense
690
+ * LLMs rely on statistical patterns in language. They might lack the ability
691
+ to apply common sense reasoning in certain situations.
692
+
693
+ ### Ethical Considerations and Risks
694
+
695
+ The development of large language models (LLMs) raises several ethical concerns.
696
+ In creating an open model, we have carefully considered the following:
697
+
698
+ * Bias and Fairness
699
+ * LLMs trained on large-scale, real-world text data can reflect socio-cultural
700
+ biases embedded in the training material. These models underwent careful
701
+ scrutiny, input data pre-processing described and posterior evaluations
702
+ reported in this card.
703
+ * Misinformation and Misuse
704
+ * LLMs can be misused to generate text that is false, misleading, or harmful.
705
+ * Guidelines are provided for responsible use with the model, see the
706
+ [Responsible Generative AI Toolkit][rai-toolkit].
707
+ * Transparency and Accountability:
708
+ * This model card summarizes details on the models' architecture,
709
+ capabilities, limitations, and evaluation processes.
710
+ * A responsibly developed open model offers the opportunity to share
711
+ innovation by making LLM technology accessible to developers and researchers
712
+ across the AI ecosystem.
713
+
714
+ Risks identified and mitigations:
715
+
716
+ * Perpetuation of biases: It's encouraged to perform continuous monitoring
717
+ (using evaluation metrics, human review) and the exploration of de-biasing
718
+ techniques during model training, fine-tuning, and other use cases.
719
+ * Generation of harmful content: Mechanisms and guidelines for content safety
720
+ are essential. Developers are encouraged to exercise caution and implement
721
+ appropriate content safety safeguards based on their specific product policies
722
+ and application use cases.
723
+ * Misuse for malicious purposes: Technical limitations and developer and
724
+ end-user education can help mitigate against malicious applications of LLMs.
725
+ Educational resources and reporting mechanisms for users to flag misuse are
726
+ provided. Prohibited uses of Gemma models are outlined in the
727
+ [Gemma Prohibited Use Policy][prohibited-use].
728
+ * Privacy violations: Models were trained on data filtered for removal of PII
729
+ (Personally Identifiable Information). Developers are encouraged to adhere to
730
+ privacy regulations with privacy-preserving techniques.
731
+
732
+ ### Benefits
733
+
734
+ At the time of release, this family of models provides high-performance open
735
+ large language model implementations designed from the ground up for Responsible
736
+ AI development compared to similarly sized models.
737
+
738
+ Using the benchmark evaluation metrics described in this document, these models
739
+ have shown to provide superior performance to other, comparably-sized open model
740
+ alternatives.
741
+
742
+ [tech-report]: https://storage.googleapis.com/deepmind-media/gemma/gemma-2-report.pdf
743
+ [rai-toolkit]: https://ai.google.dev/responsible
744
+ [kaggle-gemma]: https://www.kaggle.com/models/google/gemma-2
745
+ [terms]: https://ai.google.dev/gemma/terms
746
+ [vertex-mg-gemma2]: https://console.cloud.google.com/vertex-ai/publishers/google/model-garden/gemma2
747
+ [sensitive-info]: https://cloud.google.com/dlp/docs/high-sensitivity-infotypes-reference
748
+ [safety-policies]: https://storage.googleapis.com/gweb-uniblog-publish-prod/documents/2023_Google_AI_Principles_Progress_Update.pdf#page=11
749
+ [prohibited-use]: https://ai.google.dev/gemma/prohibited_use_policy
750
+ [tpu]: https://cloud.google.com/tpu/docs/intro-to-tpu
751
+ [sustainability]: https://sustainability.google/operating-sustainably/
752
+ [jax]: https://github.com/google/jax
753
+ [ml-pathways]: https://blog.google/technology/ai/introducing-pathways-next-generation-ai-architecture/
754
+ [sustainability]: https://sustainability.google/operating-sustainably/
755
+ [foundation-models]: https://ai.google/discover/foundation-models/
756
+ [gemini-2-paper]: https://goo.gle/gemma2report
757
+ [mmlu]: https://arxiv.org/abs/2009.03300
758
+ [hellaswag]: https://arxiv.org/abs/1905.07830
759
+ [piqa]: https://arxiv.org/abs/1911.11641
760
+ [socialiqa]: https://arxiv.org/abs/1904.09728
761
+ [boolq]: https://arxiv.org/abs/1905.10044
762
+ [winogrande]: https://arxiv.org/abs/1907.10641
763
+ [commonsenseqa]: https://arxiv.org/abs/1811.00937
764
+ [openbookqa]: https://arxiv.org/abs/1809.02789
765
+ [arc]: https://arxiv.org/abs/1911.01547
766
+ [triviaqa]: https://arxiv.org/abs/1705.03551
767
+ [naturalq]: https://github.com/google-research-datasets/natural-questions
768
+ [humaneval]: https://arxiv.org/abs/2107.03374
769
+ [mbpp]: https://arxiv.org/abs/2108.07732
770
+ [gsm8k]: https://arxiv.org/abs/2110.14168
771
+ [realtox]: https://arxiv.org/abs/2009.11462
772
+ [bold]: https://arxiv.org/abs/2101.11718
773
+ [crows]: https://aclanthology.org/2020.emnlp-main.154/
774
+ [bbq]: https://arxiv.org/abs/2110.08193v2
775
+ [winogender]: https://arxiv.org/abs/1804.09301
776
+ [truthfulqa]: https://arxiv.org/abs/2109.07958
777
+ [winobias]: https://arxiv.org/abs/1804.06876
778
+ [math]: https://arxiv.org/abs/2103.03874
779
+ [agieval]: https://arxiv.org/abs/2304.06364
780
+ [drop]: https://arxiv.org/abs/1903.00161
781
+ [big-bench]: https://arxiv.org/abs/2206.04615
782
+ [toxigen]: https://arxiv.org/abs/2203.09509
783
+ [eval-danger]: https://arxiv.org/abs/2403.13793