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