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