RichardErkhov commited on
Commit
ba0a11a
1 Parent(s): 3d41f3f

uploaded readme

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