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