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