RichardErkhov commited on
Commit
e1a1456
·
verified ·
1 Parent(s): 377d065

uploaded readme

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