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