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