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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: gemma
|
3 |
+
library_name: transformers
|
4 |
+
pipeline_tag: text-generation
|
5 |
+
tags:
|
6 |
+
- conversational
|
7 |
+
base_model: google/gemma-2-9b-it
|
8 |
+
---
|
9 |
+
|
10 |
+
# QuantFactory/gemma-2-9b-it-GGUF
|
11 |
+
This is quantized version of [google/gemma-2-9b-it](https://huggingface.co/google/gemma-2-9b-it) created using llama.cpp
|
12 |
+
|
13 |
+
# Gemma 2 model card
|
14 |
+
|
15 |
+
**Model Page**: [Gemma](https://ai.google.dev/gemma/docs)
|
16 |
+
|
17 |
+
**Resources and Technical Documentation**:
|
18 |
+
|
19 |
+
* [Responsible Generative AI Toolkit][rai-toolkit]
|
20 |
+
* [Gemma on Kaggle][kaggle-gemma]
|
21 |
+
* [Gemma on Vertex Model Garden][vertex-mg-gemma]
|
22 |
+
|
23 |
+
**Terms of Use**: [Terms](https://www.kaggle.com/models/google/gemma/license/consent/verify/huggingface?returnModelRepoId=google/gemma-2-9b-it)
|
24 |
+
|
25 |
+
**Authors**: Google
|
26 |
+
|
27 |
+
## Model Information
|
28 |
+
|
29 |
+
Summary description and brief definition of inputs and outputs.
|
30 |
+
|
31 |
+
### Description
|
32 |
+
|
33 |
+
Gemma is a family of lightweight, state-of-the-art open models from Google,
|
34 |
+
built from the same research and technology used to create the Gemini models.
|
35 |
+
They are text-to-text, decoder-only large language models, available in English,
|
36 |
+
with open weights for both pre-trained variants and instruction-tuned variants.
|
37 |
+
Gemma models are well-suited for a variety of text generation tasks, including
|
38 |
+
question answering, summarization, and reasoning. Their relatively small size
|
39 |
+
makes it possible to deploy them in environments with limited resources such as
|
40 |
+
a laptop, desktop or your own cloud infrastructure, democratizing access to
|
41 |
+
state of the art AI models and helping foster innovation for everyone.
|
42 |
+
|
43 |
+
### Usage
|
44 |
+
|
45 |
+
Below we share some code snippets on how to get quickly started with running the model. First make sure to `pip install -U transformers`, then copy the snippet from the section that is relevant for your usecase.
|
46 |
+
|
47 |
+
|
48 |
+
#### Running the model on a single / multi GPU
|
49 |
+
|
50 |
+
|
51 |
+
```python
|
52 |
+
# pip install accelerate
|
53 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
54 |
+
import torch
|
55 |
+
|
56 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-9b-it")
|
57 |
+
model = AutoModelForCausalLM.from_pretrained(
|
58 |
+
"google/gemma-2-9b-it",
|
59 |
+
device_map="auto",
|
60 |
+
torch_dtype=torch.bfloat16
|
61 |
+
)
|
62 |
+
|
63 |
+
input_text = "Write me a poem about Machine Learning."
|
64 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
65 |
+
|
66 |
+
outputs = model.generate(**input_ids)
|
67 |
+
print(tokenizer.decode(outputs[0]))
|
68 |
+
```
|
69 |
+
|
70 |
+
<a name="precisions"></a>
|
71 |
+
#### Running the model on a GPU using different precisions
|
72 |
+
|
73 |
+
The native weights of this model were exported in `bfloat16` precision. You can use `float16`, which may be faster on certain hardware, indicating the `torch_dtype` when loading the model. For convenience, the `float16` revision of the repo contains a copy of the weights already converted to that precision.
|
74 |
+
|
75 |
+
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.
|
76 |
+
|
77 |
+
* _Using `torch.float16`_
|
78 |
+
|
79 |
+
```python
|
80 |
+
# pip install accelerate
|
81 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
82 |
+
import torch
|
83 |
+
|
84 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-9b-it")
|
85 |
+
model = AutoModelForCausalLM.from_pretrained(
|
86 |
+
"google/gemma-2-9b-it",
|
87 |
+
device_map="auto",
|
88 |
+
torch_dtype=torch.float16,
|
89 |
+
revision="float16",
|
90 |
+
)
|
91 |
+
|
92 |
+
input_text = "Write me a poem about Machine Learning."
|
93 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
94 |
+
|
95 |
+
outputs = model.generate(**input_ids)
|
96 |
+
print(tokenizer.decode(outputs[0]))
|
97 |
+
```
|
98 |
+
|
99 |
+
* _Using `torch.bfloat16`_
|
100 |
+
|
101 |
+
```python
|
102 |
+
# pip install accelerate
|
103 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
104 |
+
|
105 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-9b-it")
|
106 |
+
model = AutoModelForCausalLM.from_pretrained(
|
107 |
+
"google/gemma-2-9b-it",
|
108 |
+
device_map="auto",
|
109 |
+
torch_dtype=torch.bfloat16)
|
110 |
+
|
111 |
+
input_text = "Write me a poem about Machine Learning."
|
112 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
113 |
+
|
114 |
+
outputs = model.generate(**input_ids)
|
115 |
+
print(tokenizer.decode(outputs[0]))
|
116 |
+
```
|
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-9b-it")
|
125 |
+
model = AutoModelForCausalLM.from_pretrained(
|
126 |
+
"google/gemma-2-9b-it",
|
127 |
+
device_map="auto")
|
128 |
+
|
129 |
+
input_text = "Write me a poem about Machine Learning."
|
130 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
131 |
+
|
132 |
+
outputs = model.generate(**input_ids)
|
133 |
+
print(tokenizer.decode(outputs[0]))
|
134 |
+
```
|
135 |
+
|
136 |
+
#### Quantized Versions through `bitsandbytes`
|
137 |
+
|
138 |
+
* _Using 8-bit precision (int8)_
|
139 |
+
|
140 |
+
```python
|
141 |
+
# pip install bitsandbytes accelerate
|
142 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
143 |
+
|
144 |
+
quantization_config = BitsAndBytesConfig(load_in_8bit=True)
|
145 |
+
|
146 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-9b-it")
|
147 |
+
model = AutoModelForCausalLM.from_pretrained(
|
148 |
+
"google/gemma-2-9b-it",
|
149 |
+
quantization_config=quantization_config)
|
150 |
+
|
151 |
+
input_text = "Write me a poem about Machine Learning."
|
152 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
153 |
+
|
154 |
+
outputs = model.generate(**input_ids)
|
155 |
+
print(tokenizer.decode(outputs[0]))
|
156 |
+
```
|
157 |
+
|
158 |
+
* _Using 4-bit precision_
|
159 |
+
|
160 |
+
```python
|
161 |
+
# pip install bitsandbytes accelerate
|
162 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
163 |
+
|
164 |
+
quantization_config = BitsAndBytesConfig(load_in_4bit=True)
|
165 |
+
|
166 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-9b-it")
|
167 |
+
model = AutoModelForCausalLM.from_pretrained(
|
168 |
+
"google/gemma-2-9b-it",
|
169 |
+
quantization_config=quantization_config)
|
170 |
+
|
171 |
+
input_text = "Write me a poem about Machine Learning."
|
172 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
173 |
+
|
174 |
+
outputs = model.generate(**input_ids)
|
175 |
+
print(tokenizer.decode(outputs[0]))
|
176 |
+
```
|
177 |
+
|
178 |
+
|
179 |
+
#### Other optimizations
|
180 |
+
|
181 |
+
* _Flash Attention 2_
|
182 |
+
|
183 |
+
First make sure to install `flash-attn` in your environment `pip install flash-attn`
|
184 |
+
|
185 |
+
```diff
|
186 |
+
model = AutoModelForCausalLM.from_pretrained(
|
187 |
+
model_id,
|
188 |
+
torch_dtype=torch.float16,
|
189 |
+
+ attn_implementation="flash_attention_2"
|
190 |
+
).to(0)
|
191 |
+
```
|
192 |
+
|
193 |
+
### Chat Template
|
194 |
+
|
195 |
+
The instruction-tuned models use a chat template that must be adhered to for conversational use.
|
196 |
+
The easiest way to apply it is using the tokenizer's built-in chat template, as shown in the following snippet.
|
197 |
+
|
198 |
+
Let's load the model and apply the chat template to a conversation. In this example, we'll start with a single user interaction:
|
199 |
+
|
200 |
+
```py
|
201 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
202 |
+
import transformers
|
203 |
+
import torch
|
204 |
+
|
205 |
+
model_id = "google/gemma-2-9b-it"
|
206 |
+
dtype = torch.bfloat16
|
207 |
+
|
208 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
209 |
+
model = AutoModelForCausalLM.from_pretrained(
|
210 |
+
model_id,
|
211 |
+
device_map="cuda",
|
212 |
+
torch_dtype=dtype,)
|
213 |
+
|
214 |
+
chat = [
|
215 |
+
{ "role": "user", "content": "Write a hello world program" },
|
216 |
+
]
|
217 |
+
prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
|
218 |
+
```
|
219 |
+
|
220 |
+
At this point, the prompt contains the following text:
|
221 |
+
|
222 |
+
```
|
223 |
+
<bos><start_of_turn>user
|
224 |
+
Write a hello world program<end_of_turn>
|
225 |
+
<start_of_turn>model
|
226 |
+
```
|
227 |
+
|
228 |
+
As you can see, each turn is preceded by a `<start_of_turn>` delimiter and then the role of the entity
|
229 |
+
(either `user`, for content supplied by the user, or `model` for LLM responses). Turns finish with
|
230 |
+
the `<end_of_turn>` token.
|
231 |
+
|
232 |
+
You can follow this format to build the prompt manually, if you need to do it without the tokenizer's
|
233 |
+
chat template.
|
234 |
+
|
235 |
+
After the prompt is ready, generation can be performed like this:
|
236 |
+
|
237 |
+
```py
|
238 |
+
inputs = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
|
239 |
+
outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=150)
|
240 |
+
print(tokenizer.decode(outputs[0]))
|
241 |
+
```
|
242 |
+
|
243 |
+
### Inputs and outputs
|
244 |
+
|
245 |
+
* **Input:** Text string, such as a question, a prompt, or a document to be
|
246 |
+
summarized.
|
247 |
+
* **Output:** Generated English-language text in response to the input, such
|
248 |
+
as an answer to a question, or a summary of a document.
|
249 |
+
|
250 |
+
### Model Citation
|
251 |
+
|
252 |
+
```none
|
253 |
+
@article{gemma_2024,
|
254 |
+
title={Gemma},
|
255 |
+
url={https://www.kaggle.com/m/3301},
|
256 |
+
DOI={10.34740/KAGGLE/M/3301},
|
257 |
+
publisher={Kaggle},
|
258 |
+
author={Gemma Team},
|
259 |
+
year={2024}
|
260 |
+
}
|
261 |
+
```
|
262 |
+
|
263 |
+
## Model Data
|
264 |
+
|
265 |
+
Data used for model training and how the data was processed.
|
266 |
+
|
267 |
+
### Training Dataset
|
268 |
+
|
269 |
+
These models were trained on a dataset of text data that includes a wide variety of sources. The 27B model was trained with 13 trillion tokens and the 9B model was trained with 8 trillion tokens.
|
270 |
+
Here are the key components:
|
271 |
+
|
272 |
+
* Web Documents: A diverse collection of web text ensures the model is exposed
|
273 |
+
to a broad range of linguistic styles, topics, and vocabulary. Primarily
|
274 |
+
English-language content.
|
275 |
+
* Code: Exposing the model to code helps it to learn the syntax and patterns of
|
276 |
+
programming languages, which improves its ability to generate code or
|
277 |
+
understand code-related questions.
|
278 |
+
* Mathematics: Training on mathematical text helps the model learn logical
|
279 |
+
reasoning, symbolic representation, and to address mathematical queries.
|
280 |
+
|
281 |
+
The combination of these diverse data sources is crucial for training a powerful
|
282 |
+
language model that can handle a wide variety of different tasks and text
|
283 |
+
formats.
|
284 |
+
|
285 |
+
### Data Preprocessing
|
286 |
+
|
287 |
+
Here are the key data cleaning and filtering methods applied to the training
|
288 |
+
data:
|
289 |
+
|
290 |
+
* CSAM Filtering: Rigorous CSAM (Child Sexual Abuse Material) filtering was
|
291 |
+
applied at multiple stages in the data preparation process to ensure the
|
292 |
+
exclusion of harmful and illegal content.
|
293 |
+
* Sensitive Data Filtering: As part of making Gemma pre-trained models safe and
|
294 |
+
reliable, automated techniques were used to filter out certain personal
|
295 |
+
information and other sensitive data from training sets.
|
296 |
+
* Additional methods: Filtering based on content quality and safety in line with
|
297 |
+
[our policies][safety-policies].
|
298 |
+
|
299 |
+
## Implementation Information
|
300 |
+
|
301 |
+
Details about the model internals.
|
302 |
+
|
303 |
+
### Hardware
|
304 |
+
|
305 |
+
Gemma was trained using the latest generation of
|
306 |
+
[Tensor Processing Unit (TPU)][tpu] hardware (TPUv5p).
|
307 |
+
|
308 |
+
Training large language models requires significant computational power. TPUs,
|
309 |
+
designed specifically for matrix operations common in machine learning, offer
|
310 |
+
several advantages in this domain:
|
311 |
+
|
312 |
+
* Performance: TPUs are specifically designed to handle the massive computations
|
313 |
+
involved in training LLMs. They can speed up training considerably compared to
|
314 |
+
CPUs.
|
315 |
+
* Memory: TPUs often come with large amounts of high-bandwidth memory, allowing
|
316 |
+
for the handling of large models and batch sizes during training. This can
|
317 |
+
lead to better model quality.
|
318 |
+
* Scalability: TPU Pods (large clusters of TPUs) provide a scalable solution for
|
319 |
+
handling the growing complexity of large foundation models. You can distribute
|
320 |
+
training across multiple TPU devices for faster and more efficient processing.
|
321 |
+
* Cost-effectiveness: In many scenarios, TPUs can provide a more cost-effective
|
322 |
+
solution for training large models compared to CPU-based infrastructure,
|
323 |
+
especially when considering the time and resources saved due to faster
|
324 |
+
training.
|
325 |
+
* These advantages are aligned with
|
326 |
+
[Google's commitments to operate sustainably][sustainability].
|
327 |
+
|
328 |
+
### Software
|
329 |
+
|
330 |
+
Training was done using [JAX][jax] and [ML Pathways][ml-pathways].
|
331 |
+
|
332 |
+
JAX allows researchers to take advantage of the latest generation of hardware,
|
333 |
+
including TPUs, for faster and more efficient training of large models.
|
334 |
+
|
335 |
+
ML Pathways is Google's latest effort to build artificially intelligent systems
|
336 |
+
capable of generalizing across multiple tasks. This is specially suitable for
|
337 |
+
[foundation models][foundation-models], including large language models like
|
338 |
+
these ones.
|
339 |
+
|
340 |
+
Together, JAX and ML Pathways are used as described in the
|
341 |
+
[paper about the Gemini family of models][gemini-2-paper]; "the 'single
|
342 |
+
controller' programming model of Jax and Pathways allows a single Python
|
343 |
+
process to orchestrate the entire training run, dramatically simplifying the
|
344 |
+
development workflow."
|
345 |
+
|
346 |
+
## Evaluation
|
347 |
+
|
348 |
+
Model evaluation metrics and results.
|
349 |
+
|
350 |
+
### Benchmark Results
|
351 |
+
|
352 |
+
These models were evaluated against a large collection of different datasets and
|
353 |
+
metrics to cover different aspects of text generation:
|
354 |
+
|
355 |
+
| Benchmark | Metric | Gemma PT 9B | Gemma PT 27B |
|
356 |
+
| ------------------------------ | ------------- | ----------- | ------------ |
|
357 |
+
| [MMLU][mmlu] | 5-shot, top-1 | 71.3 | 75.2 |
|
358 |
+
| [HellaSwag][hellaswag] | 10-shot | 81.9 | 86.4 |
|
359 |
+
| [PIQA][piqa] | 0-shot | 81.7 | 83.2 |
|
360 |
+
| [SocialIQA][socialiqa] | 0-shot | 53.4 | 53.7 |
|
361 |
+
| [BoolQ][boolq] | 0-shot | 84.2 | 84.8 |
|
362 |
+
| [WinoGrande][winogrande] | partial score | 80.6 | 83.7 |
|
363 |
+
| [ARC-e][arc] | 0-shot | 88.0 | 88.6 |
|
364 |
+
| [ARC-c][arc] | 25-shot | 68.4 | 71.4 |
|
365 |
+
| [TriviaQA][triviaqa] | 5-shot | 76.6 | 83.7 |
|
366 |
+
| [Natural Questions][naturalq] | 5-shot | 29.2 | 34.5 |
|
367 |
+
| [HumanEval][humaneval] | pass@1 | 40.2 | 51.8 |
|
368 |
+
| [MBPP][mbpp] | 3-shot | 52.4 | 62.6 |
|
369 |
+
| [GSM8K][gsm8k] | 5-shot, maj@1 | 68.6 | 74.0 |
|
370 |
+
| [MATH][math] | 4-shot | 36.6 | 42.3 |
|
371 |
+
| [AGIEval][agieval] | 3-5-shot | 52.8 | 55.1 |
|
372 |
+
| [BIG-Bench][big-bench] | 3-shot, CoT | 68.2 | 74.9 |
|
373 |
+
| ------------------------------ | ------------- | ----------- | ------------ |
|
374 |
+
|
375 |
+
## Ethics and Safety
|
376 |
+
|
377 |
+
Ethics and safety evaluation approach and results.
|
378 |
+
|
379 |
+
### Evaluation Approach
|
380 |
+
|
381 |
+
Our evaluation methods include structured evaluations and internal red-teaming
|
382 |
+
testing of relevant content policies. Red-teaming was conducted by a number of
|
383 |
+
different teams, each with different goals and human evaluation metrics. These
|
384 |
+
models were evaluated against a number of different categories relevant to
|
385 |
+
ethics and safety, including:
|
386 |
+
|
387 |
+
* Text-to-Text Content Safety: Human evaluation on prompts covering safety
|
388 |
+
policies including child sexual abuse and exploitation, harassment, violence
|
389 |
+
and gore, and hate speech.
|
390 |
+
* Text-to-Text Representational Harms: Benchmark against relevant academic
|
391 |
+
datasets such as [WinoBias][winobias] and [BBQ Dataset][bbq].
|
392 |
+
* Memorization: Automated evaluation of memorization of training data, including
|
393 |
+
the risk of personally identifiable information exposure.
|
394 |
+
* Large-scale harm: Tests for "dangerous capabilities," such as chemical,
|
395 |
+
biological, radiological, and nuclear (CBRN) risks.
|
396 |
+
|
397 |
+
### Evaluation Results
|
398 |
+
|
399 |
+
The results of ethics and safety evaluations are within acceptable thresholds
|
400 |
+
for meeting [internal policies][safety-policies] for categories such as child
|
401 |
+
safety, content safety, representational harms, memorization, large-scale harms.
|
402 |
+
On top of robust internal evaluations, the results of well-known safety
|
403 |
+
benchmarks like BBQ, BOLD, Winogender, Winobias, RealToxicity, and TruthfulQA
|
404 |
+
are shown here.
|
405 |
+
|
406 |
+
#### Gemma 2.0
|
407 |
+
|
408 |
+
| Benchmark | Metric | Gemma 2 IT 9B | Gemma 2 IT 27B |
|
409 |
+
| ------------------------ | ------------- | --------------- | ---------------- |
|
410 |
+
| [RealToxicity][realtox] | average | 8.25 | 8.84 |
|
411 |
+
| [CrowS-Pairs][crows] | top-1 | 37.47 | 36.67 |
|
412 |
+
| [BBQ Ambig][bbq] | 1-shot, top-1 | 88.58 | 85.99 |
|
413 |
+
| [BBQ Disambig][bbq] | top-1 | 82.67 | 86.94 |
|
414 |
+
| [Winogender][winogender] | top-1 | 79.17 | 77.22 |
|
415 |
+
| [TruthfulQA][truthfulqa] | | 50.27 | 51.60 |
|
416 |
+
| [Winobias 1_2][winobias] | | 78.09 | 81.94 |
|
417 |
+
| [Winobias 2_2][winobias] | | 95.32 | 97.22 |
|
418 |
+
| [Toxigen][toxigen] | | 39.30 | 38.42 |
|
419 |
+
| ------------------------ | ------------- | --------------- | ---------------- |
|
420 |
+
|
421 |
+
## Usage and Limitations
|
422 |
+
|
423 |
+
These models have certain limitations that users should be aware of.
|
424 |
+
|
425 |
+
### Intended Usage
|
426 |
+
|
427 |
+
Open Large Language Models (LLMs) have a wide range of applications across
|
428 |
+
various industries and domains. The following list of potential uses is not
|
429 |
+
comprehensive. The purpose of this list is to provide contextual information
|
430 |
+
about the possible use-cases that the model creators considered as part of model
|
431 |
+
training and development.
|
432 |
+
|
433 |
+
* Content Creation and Communication
|
434 |
+
* Text Generation: These models can be used to generate creative text formats
|
435 |
+
such as poems, scripts, code, marketing copy, and email drafts.
|
436 |
+
* Chatbots and Conversational AI: Power conversational interfaces for customer
|
437 |
+
service, virtual assistants, or interactive applications.
|
438 |
+
* Text Summarization: Generate concise summaries of a text corpus, research
|
439 |
+
papers, or reports.
|
440 |
+
* Research and Education
|
441 |
+
* Natural Language Processing (NLP) Research: These models can serve as a
|
442 |
+
foundation for researchers to experiment with NLP techniques, develop
|
443 |
+
algorithms, and contribute to the advancement of the field.
|
444 |
+
* Language Learning Tools: Support interactive language learning experiences,
|
445 |
+
aiding in grammar correction or providing writing practice.
|
446 |
+
* Knowledge Exploration: Assist researchers in exploring large bodies of text
|
447 |
+
by generating summaries or answering questions about specific topics.
|
448 |
+
|
449 |
+
### Limitations
|
450 |
+
|
451 |
+
* Training Data
|
452 |
+
* The quality and diversity of the training data significantly influence the
|
453 |
+
model's capabilities. Biases or gaps in the training data can lead to
|
454 |
+
limitations in the model's responses.
|
455 |
+
* The scope of the training dataset determines the subject areas the model can
|
456 |
+
handle effectively.
|
457 |
+
* Context and Task Complexity
|
458 |
+
* LLMs are better at tasks that can be framed with clear prompts and
|
459 |
+
instructions. Open-ended or highly complex tasks might be challenging.
|
460 |
+
* A model's performance can be influenced by the amount of context provided
|
461 |
+
(longer context generally leads to better outputs, up to a certain point).
|
462 |
+
* Language Ambiguity and Nuance
|
463 |
+
* Natural language is inherently complex. LLMs might struggle to grasp subtle
|
464 |
+
nuances, sarcasm, or figurative language.
|
465 |
+
* Factual Accuracy
|
466 |
+
* LLMs generate responses based on information they learned from their
|
467 |
+
training datasets, but they are not knowledge bases. They may generate
|
468 |
+
incorrect or outdated factual statements.
|
469 |
+
* Common Sense
|
470 |
+
* LLMs rely on statistical patterns in language. They might lack the ability
|
471 |
+
to apply common sense reasoning in certain situations.
|
472 |
+
|
473 |
+
### Ethical Considerations and Risks
|
474 |
+
|
475 |
+
The development of large language models (LLMs) raises several ethical concerns.
|
476 |
+
In creating an open model, we have carefully considered the following:
|
477 |
+
|
478 |
+
* Bias and Fairness
|
479 |
+
* LLMs trained on large-scale, real-world text data can reflect socio-cultural
|
480 |
+
biases embedded in the training material. These models underwent careful
|
481 |
+
scrutiny, input data pre-processing described and posterior evaluations
|
482 |
+
reported in this card.
|
483 |
+
* Misinformation and Misuse
|
484 |
+
* LLMs can be misused to generate text that is false, misleading, or harmful.
|
485 |
+
* Guidelines are provided for responsible use with the model, see the
|
486 |
+
[Responsible Generative AI Toolkit][rai-toolkit].
|
487 |
+
* Transparency and Accountability:
|
488 |
+
* This model card summarizes details on the models' architecture,
|
489 |
+
capabilities, limitations, and evaluation processes.
|
490 |
+
* A responsibly developed open model offers the opportunity to share
|
491 |
+
innovation by making LLM technology accessible to developers and researchers
|
492 |
+
across the AI ecosystem.
|
493 |
+
|
494 |
+
Risks identified and mitigations:
|
495 |
+
|
496 |
+
* Perpetuation of biases: It's encouraged to perform continuous monitoring
|
497 |
+
(using evaluation metrics, human review) and the exploration of de-biasing
|
498 |
+
techniques during model training, fine-tuning, and other use cases.
|
499 |
+
* Generation of harmful content: Mechanisms and guidelines for content safety
|
500 |
+
are essential. Developers are encouraged to exercise caution and implement
|
501 |
+
appropriate content safety safeguards based on their specific product policies
|
502 |
+
and application use cases.
|
503 |
+
* Misuse for malicious purposes: Technical limitations and developer and
|
504 |
+
end-user education can help mitigate against malicious applications of LLMs.
|
505 |
+
Educational resources and reporting mechanisms for users to flag misuse are
|
506 |
+
provided. Prohibited uses of Gemma models are outlined in the
|
507 |
+
[Gemma Prohibited Use Policy][prohibited-use].
|
508 |
+
* Privacy violations: Models were trained on data filtered for removal of PII
|
509 |
+
(Personally Identifiable Information). Developers are encouraged to adhere to
|
510 |
+
privacy regulations with privacy-preserving techniques.
|
511 |
+
|
512 |
+
### Benefits
|
513 |
+
|
514 |
+
At the time of release, this family of models provides high-performance open
|
515 |
+
large language model implementations designed from the ground up for Responsible
|
516 |
+
AI development compared to similarly sized models.
|
517 |
+
|
518 |
+
Using the benchmark evaluation metrics described in this document, these models
|
519 |
+
have shown to provide superior performance to other, comparably-sized open model
|
520 |
+
alternatives.
|
521 |
+
|
522 |
+
[rai-toolkit]: https://ai.google.dev/responsible
|
523 |
+
[kaggle-gemma]: https://www.kaggle.com/models/google/gemma-2
|
524 |
+
[terms]: https://ai.google.dev/gemma/terms
|
525 |
+
[vertex-mg-gemma]: https://console.cloud.google.com/vertex-ai/publishers/google/model-garden/335
|
526 |
+
[sensitive-info]: https://cloud.google.com/dlp/docs/high-sensitivity-infotypes-reference
|
527 |
+
[safety-policies]: https://storage.googleapis.com/gweb-uniblog-publish-prod/documents/2023_Google_AI_Principles_Progress_Update.pdf#page=11
|
528 |
+
[prohibited-use]: https://ai.google.dev/gemma/prohibited_use_policy
|
529 |
+
[tpu]: https://cloud.google.com/tpu/docs/intro-to-tpu
|
530 |
+
[sustainability]: https://sustainability.google/operating-sustainably/
|
531 |
+
[jax]: https://github.com/google/jax
|
532 |
+
[ml-pathways]: https://blog.google/technology/ai/introducing-pathways-next-generation-ai-architecture/
|
533 |
+
[sustainability]: https://sustainability.google/operating-sustainably/
|
534 |
+
[foundation-models]: https://ai.google/discover/foundation-models/
|
535 |
+
[gemini-2-paper]: https://goo.gle/gemma2report
|
536 |
+
[mmlu]: https://arxiv.org/abs/2009.03300
|
537 |
+
[hellaswag]: https://arxiv.org/abs/1905.07830
|
538 |
+
[piqa]: https://arxiv.org/abs/1911.11641
|
539 |
+
[socialiqa]: https://arxiv.org/abs/1904.09728
|
540 |
+
[boolq]: https://arxiv.org/abs/1905.10044
|
541 |
+
[winogrande]: https://arxiv.org/abs/1907.10641
|
542 |
+
[commonsenseqa]: https://arxiv.org/abs/1811.00937
|
543 |
+
[openbookqa]: https://arxiv.org/abs/1809.02789
|
544 |
+
[arc]: https://arxiv.org/abs/1911.01547
|
545 |
+
[triviaqa]: https://arxiv.org/abs/1705.03551
|
546 |
+
[naturalq]: https://github.com/google-research-datasets/natural-questions
|
547 |
+
[humaneval]: https://arxiv.org/abs/2107.03374
|
548 |
+
[mbpp]: https://arxiv.org/abs/2108.07732
|
549 |
+
[gsm8k]: https://arxiv.org/abs/2110.14168
|
550 |
+
[realtox]: https://arxiv.org/abs/2009.11462
|
551 |
+
[bold]: https://arxiv.org/abs/2101.11718
|
552 |
+
[crows]: https://aclanthology.org/2020.emnlp-main.154/
|
553 |
+
[bbq]: https://arxiv.org/abs/2110.08193v2
|
554 |
+
[winogender]: https://arxiv.org/abs/1804.09301
|
555 |
+
[truthfulqa]: https://arxiv.org/abs/2109.07958
|
556 |
+
[winobias]: https://arxiv.org/abs/1804.06876
|
557 |
+
[math]: https://arxiv.org/abs/2103.03874
|
558 |
+
[agieval]: https://arxiv.org/abs/2304.06364
|
559 |
+
[big-bench]: https://arxiv.org/abs/2206.04615
|
560 |
+
[toxigen]: https://arxiv.org/abs/2203.09509
|