ThomasBaruzier commited on
Commit
7f8732e
·
verified ·
1 Parent(s): a456795

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +105 -258
README.md CHANGED
@@ -28,15 +28,15 @@ All quants were made using the imatrix option and Bartowski's [calibration file]
28
 
29
  # Gemma 2 model card
30
 
31
- **Model Page**: [Gemma](https://ai.google.dev/gemma/docs/base)
32
 
33
  **Resources and Technical Documentation**:
34
 
35
  * [Responsible Generative AI Toolkit][rai-toolkit]
36
  * [Gemma on Kaggle][kaggle-gemma]
37
- * [Gemma on Vertex Model Garden][vertex-mg-gemma2]
38
 
39
- **Terms of Use**: [Terms][terms]
40
 
41
  **Authors**: Google
42
 
@@ -58,65 +58,28 @@ state of the art AI models and helping foster innovation for everyone.
58
 
59
  ### Usage
60
 
61
- Below we share some code snippets on how to get quickly started with running the model. First, install the Transformers library with:
62
- ```sh
63
- pip install -U transformers
64
- ```
65
-
66
- Then, copy the snippet from the section that is relevant for your usecase.
67
-
68
- #### Running with the `pipeline` API
69
-
70
- ```python
71
- import torch
72
- from transformers import pipeline
73
 
74
- pipe = pipeline(
75
- "text-generation",
76
- model="google/gemma-2-2b-it",
77
- model_kwargs={"torch_dtype": torch.bfloat16},
78
- device="cuda", # replace with "mps" to run on a Mac device
79
- )
80
-
81
- messages = [
82
- {"role": "user", "content": "Who are you? Please, answer in pirate-speak."},
83
- ]
84
-
85
- outputs = pipe(messages, max_new_tokens=256)
86
- assistant_response = outputs[0]["generated_text"][-1]["content"].strip()
87
- print(assistant_response)
88
- # 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? 🦜
89
- ```
90
 
91
  #### Running the model on a single / multi GPU
92
 
 
93
  ```python
94
  # pip install accelerate
95
  from transformers import AutoTokenizer, AutoModelForCausalLM
96
  import torch
97
 
98
- tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-2b-it")
99
  model = AutoModelForCausalLM.from_pretrained(
100
- "google/gemma-2-2b-it",
101
  device_map="auto",
102
- torch_dtype=torch.bfloat16,
103
  )
104
 
105
  input_text = "Write me a poem about Machine Learning."
106
  input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
107
 
108
- outputs = model.generate(**input_ids, max_new_tokens=32)
109
- print(tokenizer.decode(outputs[0]))
110
- ```
111
-
112
- You can ensure the correct chat template is applied by using `tokenizer.apply_chat_template` as follows:
113
- ```python
114
- messages = [
115
- {"role": "user", "content": "Write me a poem about Machine Learning."},
116
- ]
117
- input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt", return_dict=True).to("cuda")
118
-
119
- outputs = model.generate(**input_ids, max_new_tokens=256)
120
  print(tokenizer.decode(outputs[0]))
121
  ```
122
 
@@ -133,35 +96,21 @@ You can also use `float32` if you skip the dtype, but no precision increase will
133
  # pip install accelerate
134
  from transformers import AutoTokenizer, AutoModelForCausalLM
135
 
136
- tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-2b-it")
137
  model = AutoModelForCausalLM.from_pretrained(
138
- "google/gemma-2-2b-it",
139
- device_map="auto",
140
- )
141
 
142
  input_text = "Write me a poem about Machine Learning."
143
  input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
144
 
145
- outputs = model.generate(**input_ids, max_new_tokens=32)
146
  print(tokenizer.decode(outputs[0]))
147
  ```
148
 
149
- #### Running the model through a CLI
150
-
151
- The [local-gemma](https://github.com/huggingface/local-gemma) repository contains a lightweight wrapper around Transformers
152
- for running Gemma 2 through a command line interface, or CLI. Follow the [installation instructions](https://github.com/huggingface/local-gemma#cli-usage)
153
- for getting started, then launch the CLI through the following command:
154
-
155
- ```shell
156
- local-gemma --model 2b --preset speed
157
- ```
158
-
159
  #### Quantized Versions through `bitsandbytes`
160
 
161
- <details>
162
- <summary>
163
- Using 8-bit precision (int8)
164
- </summary>
165
 
166
  ```python
167
  # pip install bitsandbytes accelerate
@@ -169,24 +118,19 @@ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
169
 
170
  quantization_config = BitsAndBytesConfig(load_in_8bit=True)
171
 
172
- tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-2b-it")
173
  model = AutoModelForCausalLM.from_pretrained(
174
- "google/gemma-2-2b-it",
175
- quantization_config=quantization_config,
176
- )
177
 
178
  input_text = "Write me a poem about Machine Learning."
179
  input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
180
 
181
- outputs = model.generate(**input_ids, max_new_tokens=32)
182
  print(tokenizer.decode(outputs[0]))
183
  ```
184
- </details>
185
 
186
- <details>
187
- <summary>
188
- Using 4-bit precision
189
- </summary>
190
 
191
  ```python
192
  # pip install bitsandbytes accelerate
@@ -194,81 +138,82 @@ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
194
 
195
  quantization_config = BitsAndBytesConfig(load_in_4bit=True)
196
 
197
- tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-2b-it")
198
  model = AutoModelForCausalLM.from_pretrained(
199
- "google/gemma-2-2b-it",
200
- quantization_config=quantization_config,
201
- )
202
 
203
  input_text = "Write me a poem about Machine Learning."
204
  input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
205
 
206
- outputs = model.generate(**input_ids, max_new_tokens=32)
207
  print(tokenizer.decode(outputs[0]))
208
  ```
209
- </details>
210
 
211
- #### Advanced Usage
212
 
213
- <details>
214
- <summary>
215
- Torch compile
216
- </summary>
217
 
218
- [Torch compile](https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html) is a method for speeding-up the
219
- inference of PyTorch modules. The Gemma-2 2b model can be run up to 6x faster by leveraging torch compile.
220
 
221
- Note that two warm-up steps are required before the full inference speed is realised:
222
 
223
- ```python
224
- import os
225
- os.environ["TOKENIZERS_PARALLELISM"] = "false"
 
 
 
 
226
 
227
- from transformers import AutoTokenizer, Gemma2ForCausalLM
228
- from transformers.cache_utils import HybridCache
229
- import torch
230
 
231
- torch.set_float32_matmul_precision("high")
 
232
 
233
- # load the model + tokenizer
234
- tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-2b-it")
235
- model = Gemma2ForCausalLM.from_pretrained("google/gemma-2-2b-it", torch_dtype=torch.bfloat16)
236
- model.to("cuda")
237
 
238
- # apply the torch compile transformation
239
- model.forward = torch.compile(model.forward, mode="reduce-overhead", fullgraph=True)
 
 
240
 
241
- # pre-process inputs
242
- input_text = "The theory of special relativity states "
243
- model_inputs = tokenizer(input_text, return_tensors="pt").to("cuda")
244
- prompt_length = model_inputs.input_ids.shape[1]
245
 
246
- # set-up k/v cache
247
- past_key_values = HybridCache(
248
- config=model.config,
249
- max_batch_size=1,
250
- max_cache_len=model.config.max_position_embeddings,
251
- device=model.device,
252
- dtype=model.dtype
253
- )
254
 
255
- # enable passing kv cache to generate
256
- model._supports_cache_class = True
257
- model.generation_config.cache_implementation = None
 
 
258
 
259
- # two warm-up steps
260
- for idx in range(2):
261
- outputs = model.generate(**model_inputs, past_key_values=past_key_values, do_sample=True, temperature=1.0, max_new_tokens=128)
262
- past_key_values.reset()
263
 
264
- # fast run
265
- outputs = model.generate(**model_inputs, past_key_values=past_key_values, do_sample=True, temperature=1.0, max_new_tokens=128)
266
- print(tokenizer.decode(outputs[0], skip_special_tokens=True))
267
  ```
 
 
 
 
 
 
 
 
 
 
 
268
 
269
- For more details, refer to the [Transformers documentation](https://huggingface.co/docs/transformers/main/en/llm_optims?static-kv=basic+usage%3A+generation_config).
270
 
271
- </details>
 
 
 
 
272
 
273
  ### Inputs and outputs
274
 
@@ -296,9 +241,7 @@ Data used for model training and how the data was processed.
296
 
297
  ### Training Dataset
298
 
299
- These models were trained on a dataset of text data that includes a wide variety
300
- of sources. The 27B model was trained with 13 trillion tokens, the 9B model was
301
- trained with 8 trillion tokens, and 2B model was trained with 2 trillion tokens.
302
  Here are the key components:
303
 
304
  * Web Documents: A diverse collection of web text ensures the model is exposed
@@ -384,25 +327,25 @@ Model evaluation metrics and results.
384
  These models were evaluated against a large collection of different datasets and
385
  metrics to cover different aspects of text generation:
386
 
387
- | Benchmark | Metric | Gemma 2 PT 2B | Gemma 2 PT 9B | Gemma 2 PT 27B |
388
- | ------------------------------ | ------------- | ------------- | ------------- | -------------- |
389
- | [MMLU][mmlu] | 5-shot, top-1 | 51.3 | 71.3 | 75.2 |
390
- | [HellaSwag][hellaswag] | 10-shot | 73.0 | 81.9 | 86.4 |
391
- | [PIQA][piqa] | 0-shot | 77.8 | 81.7 | 83.2 |
392
- | [SocialIQA][socialiqa] | 0-shot | 51.9 | 53.4 | 53.7 |
393
- | [BoolQ][boolq] | 0-shot | 72.5 | 84.2 | 84.8 |
394
- | [WinoGrande][winogrande] | partial score | 70.9 | 80.6 | 83.7 |
395
- | [ARC-e][arc] | 0-shot | 80.1 | 88.0 | 88.6 |
396
- | [ARC-c][arc] | 25-shot | 55.4 | 68.4 | 71.4 |
397
- | [TriviaQA][triviaqa] | 5-shot | 59.4 | 76.6 | 83.7 |
398
- | [Natural Questions][naturalq] | 5-shot | 16.7 | 29.2 | 34.5 |
399
- | [HumanEval][humaneval] | pass@1 | 17.7 | 40.2 | 51.8 |
400
- | [MBPP][mbpp] | 3-shot | 29.6 | 52.4 | 62.6 |
401
- | [GSM8K][gsm8k] | 5-shot, maj@1 | 23.9 | 68.6 | 74.0 |
402
- | [MATH][math] | 4-shot | 15.0 | 36.6 | 42.3 |
403
- | [AGIEval][agieval] | 3-5-shot | 30.6 | 52.8 | 55.1 |
404
- | [DROP][drop] | 3-shot, F1 | 52.0 | 69.4 | 72.2 |
405
- | [BIG-Bench][big-bench] | 3-shot, CoT | 41.9 | 68.2 | 74.9 |
406
 
407
  ## Ethics and Safety
408
 
@@ -437,111 +380,18 @@ are shown here.
437
 
438
  #### Gemma 2.0
439
 
440
- | Benchmark | Metric | Gemma 2 IT 2B | Gemma 2 IT 9B | Gemma 2 IT 27B |
441
- | ------------------------ | ------------- | ------------- | ------------- | -------------- |
442
- | [RealToxicity][realtox] | average | 8.16 | 8.25 | 8.84 |
443
- | [CrowS-Pairs][crows] | top-1 | 37.67 | 37.47 | 36.67 |
444
- | [BBQ Ambig][bbq] | 1-shot, top-1 | 83.20 | 88.58 | 85.99 |
445
- | [BBQ Disambig][bbq] | top-1 | 69.31 | 82.67 | 86.94 |
446
- | [Winogender][winogender] | top-1 | 52.91 | 79.17 | 77.22 |
447
- | [TruthfulQA][truthfulqa] | | 43.72 | 50.27 | 51.60 |
448
- | [Winobias 1_2][winobias] | | 59.28 | 78.09 | 81.94 |
449
- | [Winobias 2_2][winobias] | | 88.57 | 95.32 | 97.22 |
450
- | [Toxigen][toxigen] | | 48.32 | 39.30 | 38.42 |
451
-
452
- ## Dangerous Capability Evaluations
453
-
454
- ### Evaluation Approach
455
-
456
- We evaluated a range of dangerous capabilities:
457
-
458
- - **Offensive cybersecurity:** To assess the model's potential for misuse in
459
- cybersecurity contexts, we utilized both publicly available
460
- Capture-the-Flag (CTF) platforms like InterCode-CTF and Hack the Box, as
461
- well as internally developed CTF challenges. These evaluations measure the
462
- model's ability to exploit vulnerabilities and gain unauthorized access in
463
- simulated environments.
464
- - **Self-proliferation:** We evaluated the model's capacity for
465
- self-proliferation by designing tasks that involve resource acquisition, code
466
- execution, and interaction with remote systems. These evaluations assess
467
- the model's ability to independently replicate and spread.
468
- - **Persuasion:** To evaluate the model's capacity for persuasion and
469
- deception, we conducted human persuasion studies. These studies involved
470
- scenarios that measure the model's ability to build rapport, influence
471
- beliefs, and elicit specific actions from human participants.
472
-
473
- ### Evaluation Results
474
-
475
- All evaluations are described in detail in
476
- [Evaluating Frontier Models for Dangerous Capabilities][eval-danger]
477
- and in brief in the
478
- [Gemma 2 technical report][tech-report].
479
-
480
- <table>
481
- <thead>
482
- <tr>
483
- <th>Evaluation</th>
484
- <th>Capability</th>
485
- <th>Gemma 2 IT 27B</th>
486
- </tr>
487
- </thead>
488
- <tbody>
489
- <tr>
490
- <td>InterCode-CTF</td>
491
- <td>Offensive cybersecurity</td>
492
- <td>34/76 challenges</td>
493
- </tr>
494
- <tr>
495
- <td>Internal CTF</td>
496
- <td>Offensive cybersecurity</td>
497
- <td>1/13 challenges</td>
498
- </tr>
499
- <tr>
500
- <td>Hack the Box</td>
501
- <td>Offensive cybersecurity</td>
502
- <td>0/13 challenges</td>
503
- </tr>
504
- <tr>
505
- <td>Self-proliferation early warning</td>
506
- <td>Self-proliferation</td>
507
- <td>1/10 challenges</td>
508
- </tr>
509
- <tr>
510
- <td>Charm offensive</td>
511
- <td>Persuasion</td>
512
- <td>Percent of participants agreeing:
513
- 81% interesting,
514
- 75% would speak again,
515
- 80% made personal connection</td>
516
- </tr>
517
- <tr>
518
- <td>Click Links</td>
519
- <td>Persuasion</td>
520
- <td>34% of participants</td>
521
- </tr>
522
- <tr>
523
- <td>Find Info</td>
524
- <td>Persuasion</td>
525
- <td>9% of participants</td>
526
- </tr>
527
- <tr>
528
- <td>Run Code</td>
529
- <td>Persuasion</td>
530
- <td>11% of participants</td>
531
- </tr>
532
- <tr>
533
- <td>Money talks</td>
534
- <td>Persuasion</td>
535
- <td>£3.72 mean donation</td>
536
- </tr>
537
- <tr>
538
- <td>Web of Lies</td>
539
- <td>Persuasion</td>
540
- <td>18% mean shift towards correct belief, 1% mean shift towards
541
- incorrect belief</td>
542
- </tr>
543
- </tbody>
544
- </table>
545
 
546
  ## Usage and Limitations
547
 
@@ -644,11 +494,10 @@ Using the benchmark evaluation metrics described in this document, these models
644
  have shown to provide superior performance to other, comparably-sized open model
645
  alternatives.
646
 
647
- [tech-report]: https://storage.googleapis.com/deepmind-media/gemma/gemma-2-report.pdf
648
  [rai-toolkit]: https://ai.google.dev/responsible
649
  [kaggle-gemma]: https://www.kaggle.com/models/google/gemma-2
650
  [terms]: https://ai.google.dev/gemma/terms
651
- [vertex-mg-gemma2]: https://console.cloud.google.com/vertex-ai/publishers/google/model-garden/gemma2
652
  [sensitive-info]: https://cloud.google.com/dlp/docs/high-sensitivity-infotypes-reference
653
  [safety-policies]: https://storage.googleapis.com/gweb-uniblog-publish-prod/documents/2023_Google_AI_Principles_Progress_Update.pdf#page=11
654
  [prohibited-use]: https://ai.google.dev/gemma/prohibited_use_policy
@@ -682,7 +531,5 @@ alternatives.
682
  [winobias]: https://arxiv.org/abs/1804.06876
683
  [math]: https://arxiv.org/abs/2103.03874
684
  [agieval]: https://arxiv.org/abs/2304.06364
685
- [drop]: https://arxiv.org/abs/1903.00161
686
  [big-bench]: https://arxiv.org/abs/2206.04615
687
- [toxigen]: https://arxiv.org/abs/2203.09509
688
- [eval-danger]: https://arxiv.org/abs/2403.13793
 
28
 
29
  # Gemma 2 model card
30
 
31
+ **Model Page**: [Gemma](https://ai.google.dev/gemma/docs)
32
 
33
  **Resources and Technical Documentation**:
34
 
35
  * [Responsible Generative AI Toolkit][rai-toolkit]
36
  * [Gemma on Kaggle][kaggle-gemma]
37
+ * [Gemma on Vertex Model Garden][vertex-mg-gemma]
38
 
39
+ **Terms of Use**: [Terms](https://www.kaggle.com/models/google/gemma/license/consent/verify/huggingface?returnModelRepoId=google/gemma-2-9b-it)
40
 
41
  **Authors**: Google
42
 
 
58
 
59
  ### Usage
60
 
61
+ 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.
 
 
 
 
 
 
 
 
 
 
 
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
  #### Running the model on a single / multi GPU
65
 
66
+
67
  ```python
68
  # pip install accelerate
69
  from transformers import AutoTokenizer, AutoModelForCausalLM
70
  import torch
71
 
72
+ tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-9b-it")
73
  model = AutoModelForCausalLM.from_pretrained(
74
+ "google/gemma-2-9b-it",
75
  device_map="auto",
76
+ torch_dtype=torch.bfloat16
77
  )
78
 
79
  input_text = "Write me a poem about Machine Learning."
80
  input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
81
 
82
+ outputs = model.generate(**input_ids)
 
 
 
 
 
 
 
 
 
 
 
83
  print(tokenizer.decode(outputs[0]))
84
  ```
85
 
 
96
  # pip install accelerate
97
  from transformers import AutoTokenizer, AutoModelForCausalLM
98
 
99
+ tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-9b-it")
100
  model = AutoModelForCausalLM.from_pretrained(
101
+ "google/gemma-2-9b-it",
102
+ device_map="auto")
 
103
 
104
  input_text = "Write me a poem about Machine Learning."
105
  input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
106
 
107
+ outputs = model.generate(**input_ids)
108
  print(tokenizer.decode(outputs[0]))
109
  ```
110
 
 
 
 
 
 
 
 
 
 
 
111
  #### Quantized Versions through `bitsandbytes`
112
 
113
+ * _Using 8-bit precision (int8)_
 
 
 
114
 
115
  ```python
116
  # pip install bitsandbytes accelerate
 
118
 
119
  quantization_config = BitsAndBytesConfig(load_in_8bit=True)
120
 
121
+ tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-9b-it")
122
  model = AutoModelForCausalLM.from_pretrained(
123
+ "google/gemma-2-9b-it",
124
+ quantization_config=quantization_config)
 
125
 
126
  input_text = "Write me a poem about Machine Learning."
127
  input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
128
 
129
+ outputs = model.generate(**input_ids)
130
  print(tokenizer.decode(outputs[0]))
131
  ```
 
132
 
133
+ * _Using 4-bit precision_
 
 
 
134
 
135
  ```python
136
  # pip install bitsandbytes accelerate
 
138
 
139
  quantization_config = BitsAndBytesConfig(load_in_4bit=True)
140
 
141
+ tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-9b-it")
142
  model = AutoModelForCausalLM.from_pretrained(
143
+ "google/gemma-2-9b-it",
144
+ quantization_config=quantization_config)
 
145
 
146
  input_text = "Write me a poem about Machine Learning."
147
  input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
148
 
149
+ outputs = model.generate(**input_ids)
150
  print(tokenizer.decode(outputs[0]))
151
  ```
 
152
 
 
153
 
154
+ #### Other optimizations
 
 
 
155
 
156
+ * _Flash Attention 2_
 
157
 
158
+ First make sure to install `flash-attn` in your environment `pip install flash-attn`
159
 
160
+ ```diff
161
+ model = AutoModelForCausalLM.from_pretrained(
162
+ model_id,
163
+ torch_dtype=torch.float16,
164
+ + attn_implementation="flash_attention_2"
165
+ ).to(0)
166
+ ```
167
 
168
+ ### Chat Template
 
 
169
 
170
+ The instruction-tuned models use a chat template that must be adhered to for conversational use.
171
+ The easiest way to apply it is using the tokenizer's built-in chat template, as shown in the following snippet.
172
 
173
+ Let's load the model and apply the chat template to a conversation. In this example, we'll start with a single user interaction:
 
 
 
174
 
175
+ ```py
176
+ from transformers import AutoTokenizer, AutoModelForCausalLM
177
+ import transformers
178
+ import torch
179
 
180
+ model_id = "google/gemma-2-9b-it"
181
+ dtype = torch.bfloat16
 
 
182
 
183
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
184
+ model = AutoModelForCausalLM.from_pretrained(
185
+ model_id,
186
+ device_map="cuda",
187
+ torch_dtype=dtype,)
 
 
 
188
 
189
+ chat = [
190
+ { "role": "user", "content": "Write a hello world program" },
191
+ ]
192
+ prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
193
+ ```
194
 
195
+ At this point, the prompt contains the following text:
 
 
 
196
 
 
 
 
197
  ```
198
+ <bos><start_of_turn>user
199
+ Write a hello world program<end_of_turn>
200
+ <start_of_turn>model
201
+ ```
202
+
203
+ As you can see, each turn is preceded by a `<start_of_turn>` delimiter and then the role of the entity
204
+ (either `user`, for content supplied by the user, or `model` for LLM responses). Turns finish with
205
+ the `<end_of_turn>` token.
206
+
207
+ You can follow this format to build the prompt manually, if you need to do it without the tokenizer's
208
+ chat template.
209
 
210
+ After the prompt is ready, generation can be performed like this:
211
 
212
+ ```py
213
+ inputs = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
214
+ outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=150)
215
+ print(tokenizer.decode(outputs[0]))
216
+ ```
217
 
218
  ### Inputs and outputs
219
 
 
241
 
242
  ### Training Dataset
243
 
244
+ 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.
 
 
245
  Here are the key components:
246
 
247
  * Web Documents: A diverse collection of web text ensures the model is exposed
 
327
  These models were evaluated against a large collection of different datasets and
328
  metrics to cover different aspects of text generation:
329
 
330
+ | Benchmark | Metric | Gemma PT 9B | Gemma PT 27B |
331
+ | ------------------------------ | ------------- | ----------- | ------------ |
332
+ | [MMLU][mmlu] | 5-shot, top-1 | 71.3 | 75.2 |
333
+ | [HellaSwag][hellaswag] | 10-shot | 81.9 | 86.4 |
334
+ | [PIQA][piqa] | 0-shot | 81.7 | 83.2 |
335
+ | [SocialIQA][socialiqa] | 0-shot | 53.4 | 53.7 |
336
+ | [BoolQ][boolq] | 0-shot | 84.2 | 84.8 |
337
+ | [WinoGrande][winogrande] | partial score | 80.6 | 83.7 |
338
+ | [ARC-e][arc] | 0-shot | 88.0 | 88.6 |
339
+ | [ARC-c][arc] | 25-shot | 68.4 | 71.4 |
340
+ | [TriviaQA][triviaqa] | 5-shot | 76.6 | 83.7 |
341
+ | [Natural Questions][naturalq] | 5-shot | 29.2 | 34.5 |
342
+ | [HumanEval][humaneval] | pass@1 | 40.2 | 51.8 |
343
+ | [MBPP][mbpp] | 3-shot | 52.4 | 62.6 |
344
+ | [GSM8K][gsm8k] | 5-shot, maj@1 | 68.6 | 74.0 |
345
+ | [MATH][math] | 4-shot | 36.6 | 42.3 |
346
+ | [AGIEval][agieval] | 3-5-shot | 52.8 | 55.1 |
347
+ | [BIG-Bench][big-bench] | 3-shot, CoT | 68.2 | 74.9 |
348
+ | ------------------------------ | ------------- | ----------- | ------------ |
349
 
350
  ## Ethics and Safety
351
 
 
380
 
381
  #### Gemma 2.0
382
 
383
+ | Benchmark | Metric | Gemma 2 IT 9B | Gemma 2 IT 27B |
384
+ | ------------------------ | ------------- | --------------- | ---------------- |
385
+ | [RealToxicity][realtox] | average | 8.25 | 8.84 |
386
+ | [CrowS-Pairs][crows] | top-1 | 37.47 | 36.67 |
387
+ | [BBQ Ambig][bbq] | 1-shot, top-1 | 88.58 | 85.99 |
388
+ | [BBQ Disambig][bbq] | top-1 | 82.67 | 86.94 |
389
+ | [Winogender][winogender] | top-1 | 79.17 | 77.22 |
390
+ | [TruthfulQA][truthfulqa] | | 50.27 | 51.60 |
391
+ | [Winobias 1_2][winobias] | | 78.09 | 81.94 |
392
+ | [Winobias 2_2][winobias] | | 95.32 | 97.22 |
393
+ | [Toxigen][toxigen] | | 39.30 | 38.42 |
394
+ | ------------------------ | ------------- | --------------- | ---------------- |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
395
 
396
  ## Usage and Limitations
397
 
 
494
  have shown to provide superior performance to other, comparably-sized open model
495
  alternatives.
496
 
 
497
  [rai-toolkit]: https://ai.google.dev/responsible
498
  [kaggle-gemma]: https://www.kaggle.com/models/google/gemma-2
499
  [terms]: https://ai.google.dev/gemma/terms
500
+ [vertex-mg-gemma]: https://console.cloud.google.com/vertex-ai/publishers/google/model-garden/335
501
  [sensitive-info]: https://cloud.google.com/dlp/docs/high-sensitivity-infotypes-reference
502
  [safety-policies]: https://storage.googleapis.com/gweb-uniblog-publish-prod/documents/2023_Google_AI_Principles_Progress_Update.pdf#page=11
503
  [prohibited-use]: https://ai.google.dev/gemma/prohibited_use_policy
 
531
  [winobias]: https://arxiv.org/abs/1804.06876
532
  [math]: https://arxiv.org/abs/2103.03874
533
  [agieval]: https://arxiv.org/abs/2304.06364
 
534
  [big-bench]: https://arxiv.org/abs/2206.04615
535
+ [toxigen]: https://arxiv.org/abs/2203.09509