rockerBOO commited on
Commit
6aebe24
·
verified ·
1 Parent(s): ed25629

Update README.md

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