FastFlowLM commited on
Commit
e190937
·
verified ·
1 Parent(s): 1dfe60b

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +348 -0
README.md ADDED
@@ -0,0 +1,348 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: gemma
3
+ library_name: transformers
4
+ pipeline_tag: image-text-to-text
5
+ extra_gated_heading: Access Gemma on Hugging Face
6
+ extra_gated_prompt: To access Gemma on Hugging Face, you’re required to review and
7
+ agree to Google’s usage license. To do this, please ensure you’re logged in to Hugging
8
+ Face and click below. Requests are processed immediately.
9
+ extra_gated_button_content: Acknowledge license
10
+ ---
11
+
12
+ # TranslateGemma model card
13
+
14
+ **Resources and Technical Documentation**:
15
+
16
+ + [Technical Report](https://arxiv.org/pdf/2601.09012)
17
+ + [Responsible Generative AI Toolkit](https://ai.google.dev/responsible)
18
+ + [TranslateGemma on Kaggle](https://www.kaggle.com/models/google/translategemma/)
19
+ + [TranslateGemma on Vertex Model Garden](https://console.cloud.google.com/vertex-ai/publishers/google/model-garden/translategemma)
20
+
21
+ **Terms of Use**: [Terms](https://ai.google.dev/gemma/terms)
22
+ **Authors**: Google Translate
23
+
24
+ ## Model Information
25
+
26
+ Summary description and brief definition of inputs and outputs.
27
+
28
+ ### Description
29
+
30
+ TranslateGemma is a family of lightweight, state-of-the-art open translation models from Google, based on the Gemma 3 family of models.
31
+ TranslateGemma models are designed to handle translation tasks across 55 languages. Their relatively small size makes it possible to deploy them in environments with limited resources such as laptops, desktops or your own cloud infrastructure, democratizing access to state of the art translation models and helping foster innovation for everyone.
32
+
33
+ ### Inputs and outputs
34
+
35
+ + **Input:**
36
+
37
+ + Text string, representing the text to be translated
38
+ + Images, normalized to 896 x 896 resolution and encoded to 256 tokens each
39
+ + Total input context of 2K tokens
40
+
41
+ + **Output:**
42
+
43
+ + Text translated into the target language
44
+
45
+ ### Usage
46
+
47
+ TranslateGemma is designed to work with a specific chat template that supports direct translation of a text input, or text-extraction-and-translation from an image input. This chat template has been implemented with Hugging Face transformers' [chat templating](https://huggingface.co/docs/transformers/en/chat_templating) system and is compatible with the [apply_chat_template() function](https://huggingface.co/docs/transformers/en/chat_templating#using-applychattemplate) provided by the [Gemma tokenizer](https://huggingface.co/docs/transformers/en/model_doc/gemma#transformers.GemmaTokenizer) and [Gemma 3 processor](https://huggingface.co/docs/transformers/en/model_doc/gemma3#transformers.Gemma3Processor). Notable differences from other models' chat templates include:
48
+
49
+ + TranslateGemma supports only User and Assistant roles.
50
+ + TranslateGemma's User role is highly opinionated:
51
+
52
+ + The content property must be provided as a list with exactly one entry.
53
+ + The content list entry must provide:
54
+
55
+ + A "type" property where the value must be either "text" or "image".
56
+ + A "source_lang_code" property as a string
57
+ + A "target_lang_code" property as a string
58
+
59
+ + The content list entry should provide one of these:
60
+
61
+ + A "url" property, if the entry's type is "image", from which the image will be loaded
62
+ + A "text" property, if the entry's type is "text", containing only the text to translate
63
+
64
+ + The "source_lang_code" and "target_lang_code" property values can take one of one of two forms:
65
+
66
+ + An [ISO 639-1 Alpha-2 language code](https://en.wikipedia.org/wiki/ISO_639-1), e.g., `en`; or
67
+ + A "regionalized" variant as an ISO 639-1 Alpha-2 language code and an [ISO 3166-1 Alpha-2 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) pair separated by a dash or an underscore, e.g., en_US` or `en-GB, similar to the [Unicode Common Locale Data Repository format](https://cldr.unicode.org/).
68
+
69
+ + If the "source_lang_code" and "target_lang_code" property value is not supported by the model, an error will be raised when the template is applied.
70
+
71
+ Additionally, TranslateGemma may respond well to other prompting techniques to support use cases that go beyond the provided chat template, such as Automatic Translation Post-Editing. As these are not officially supported, they should be crafted manually using the special control tokens and structures specified in the [Gemma 3 Technical Report](https://arxiv.org/abs/2503.19786), and sent directly to the tokenizer or processor instead of using the apply_chat_template() function. The TranslateGemma team is interested in hearing about your experiences with alternate prompts, please reach out with any questions and feedback.
72
+
73
+ #### With Pipelines
74
+
75
+ ```python
76
+ from transformers import pipeline
77
+ import torch
78
+
79
+ pipe = pipeline(
80
+ "image-text-to-text",
81
+ model="google/translategemma-4b-it",
82
+ device="cuda",
83
+ dtype=torch.bfloat16
84
+ )
85
+
86
+ # ---- Text Translation ----
87
+ messages = [
88
+ {
89
+ "role": "user",
90
+ "content": [
91
+ {
92
+ "type": "text",
93
+ "source_lang_code": "cs",
94
+ "target_lang_code": "de-DE",
95
+ "text": "V nejhorším případě i k prasknutí čočky.",
96
+ }
97
+ ],
98
+ }
99
+ ]
100
+
101
+ output = pipe(text=messages, max_new_tokens=200)
102
+ print(output[0]["generated_text"][-1]["content"])
103
+
104
+ # ---- Text Extraction and Translation ----
105
+ messages = [
106
+ {
107
+ "role": "user",
108
+ "content": [
109
+ {
110
+ "type": "image",
111
+ "source_lang_code": "cs",
112
+ "target_lang_code": "de-DE",
113
+ "url": "https://c7.alamy.com/comp/2YAX36N/traffic-signs-in-czech-republic-pedestrian-zone-2YAX36N.jpg",
114
+ },
115
+ ],
116
+ }
117
+ ]
118
+
119
+ output = pipe(text=messages, max_new_tokens=200)
120
+ print(output[0]["generated_text"][-1]["content"])
121
+
122
+ ```
123
+
124
+ #### With direct initialization
125
+
126
+ ```python
127
+ import torch
128
+ from transformers import AutoModelForImageTextToText, AutoProcessor
129
+
130
+ model_id = "google/translategemma-4b-it"
131
+ processor = AutoProcessor.from_pretrained(model_id)
132
+ model = AutoModelForImageTextToText.from_pretrained(model_id, device_map="auto")
133
+
134
+
135
+ # ---- Text Translation ----
136
+ messages = [
137
+ {
138
+ "role": "user",
139
+ "content": [
140
+ {
141
+ "type": "text",
142
+ "source_lang_code": "cs",
143
+ "target_lang_code": "de-DE",
144
+ "text": "V nejhorším případě i k prasknutí čočky.",
145
+ }
146
+ ],
147
+ }
148
+ ]
149
+
150
+ inputs = processor.apply_chat_template(
151
+ messages, tokenize=True, add_generation_prompt=True, return_dict=True, return_tensors="pt"
152
+ ).to(model.device, dtype=torch.bfloat16)
153
+ input_len = len(inputs['input_ids'][0])
154
+
155
+ with torch.inference_mode():
156
+ generation = model.generate(**inputs, do_sample=False)
157
+
158
+ generation = generation[0][input_len:]
159
+ decoded = processor.decode(generation, skip_special_tokens=True)
160
+ print(decoded)
161
+
162
+ # ---- Text Extraction and Translation ----
163
+ messages = [
164
+ {
165
+ "role": "user",
166
+ "content": [
167
+ {
168
+ "type": "image",
169
+ "source_lang_code": "cs",
170
+ "target_lang_code": "de-DE",
171
+ "url": "https://c7.alamy.com/comp/2YAX36N/traffic-signs-in-czech-republic-pedestrian-zone-2YAX36N.jpg",
172
+ },
173
+ ],
174
+ }
175
+ ]
176
+
177
+ inputs = processor.apply_chat_template(
178
+ messages, tokenize=True, add_generation_prompt=True, return_dict=True, return_tensors="pt"
179
+ ).to(model.device, dtype=torch.bfloat16)
180
+
181
+ with torch.inference_mode():
182
+ generation = model.generate(**inputs, do_sample=False)
183
+
184
+ generation = generation[0][input_len:]
185
+ decoded = processor.decode(generation, skip_special_tokens=True)
186
+ print(decoded)
187
+
188
+ ```
189
+
190
+ ### Citation
191
+
192
+ ```
193
+ @article{gemmatranslate2026,
194
+ title={{TranslateGemma Technical Report}},
195
+ url={https://arxiv.org/pdf/2601.09012},
196
+ publisher={Google DeepMind},
197
+ author={{Google Translate Research Team} and
198
+ Finkelstein, Mara and
199
+ Caswell, Isaac and
200
+ Domhan, Tobias and
201
+ Peter, Jan-Thorsten and
202
+ Juraska, Juraj and
203
+ Riley, Parker and
204
+ Deutsch, Daniel and
205
+ Dilanni, Cole and
206
+ Cherry, Colin and
207
+ Briakou, Eleftheria and
208
+ Nielsen, Elizabeth and
209
+ Luo, Jiaming and
210
+ Agrawal, Sweta and
211
+ Xu, Wenda and
212
+ Kats, Erin and
213
+ Jaskiewicz, Stephane and
214
+ Freitag, Markus and
215
+ Vilar, David
216
+ },
217
+ year={2026}
218
+ }
219
+ ```
220
+
221
+
222
+ ## Model Data
223
+
224
+ Data used for model training and how the data was processed.
225
+
226
+ ### Training Dataset
227
+
228
+ The models were fine-tuned from the original Gemma 3 checkpoints using parallel data from a wide variety of sources. The TranslateGemma models used 4.3 billion tokens during SFT and 10.2 million tokens during the reinforcement learning phase. The key components were:
229
+
230
+ + Monolingual web documents paired with high-quality translations into a variety of languages, generated by Gemini.
231
+ + Publicly available parallel documents.
232
+
233
+ ## Implementation Information
234
+
235
+ Details about the model internals.
236
+
237
+ ### Hardware
238
+
239
+ TranslateGemma was trained using [Tensor Processing Unit (TPU)](https://cloud.google.com/tpu/docs/intro-to-tpu) hardware (TPUv4p, TPUv5p and TPUv5e). TPUs, designed specifically for matrix operations common in machine learning, offer several advantages in this domain:
240
+
241
+ + Performance: TPUs are specifically designed to handle the massive computations involved in training VLMs. They can speed up training considerably compared to CPUs.
242
+ + Memory: TPUs often come with large amounts of high-bandwidth memory, allowing for the handling of large models and batch sizes during training. This can lead to better model quality.
243
+ + Scalability: TPU Pods (large clusters of TPUs) provide a scalable solution for handling the growing complexity of large foundation models. You can distribute training across multiple TPU devices for faster and more efficient processing.
244
+ + Cost-effectiveness: In many scenarios, TPUs can provide a more cost-effective solution for training large models compared to CPU-based infrastructure, especially when considering the time and resources saved due to faster training.
245
+ + These advantages are aligned with [Google's commitments to operate sustainably](https://sustainability.google/operating-sustainably/).
246
+
247
+ ### Software
248
+
249
+ Training was done using [JAX](https://github.com/jax-ml/jax) and [ML Pathways](https://blog.google/technology/ai/introducing-pathways-next-generation-ai-architecture/). JAX allows researchers to take advantage of the latest generation of hardware, including TPUs, for faster and more efficient training of large models. ML Pathways is Google's latest effort to build artificially intelligent systems capable of generalizing across multiple tasks. This is specially suitable for foundation models, including large language models like these ones.
250
+ Together, JAX and ML Pathways are used as described in the [paper about the Gemini family of models](https://goo.gle/gemma2report); _"the 'single controller' programming model of Jax and Pathways allows a single Python process to orchestrate the entire training run, dramatically simplifying the development workflow."_
251
+
252
+ ## Evaluation
253
+
254
+ Model evaluation metrics and results.
255
+
256
+ ### Benchmark Results
257
+
258
+ These models were evaluated against a large collection of different datasets and metrics to cover different aspects of text generation.
259
+
260
+ | | **4B** | **12B** | **27B** |
261
+ | ---------------------------------------------- | ------ | ------- | ------- |
262
+ | **WMT24++ (55 langs)** | | | |
263
+ | MetricX ↓ | 5.32 | 3.60 | 3.09 |
264
+ | Comet ↑ | 81.6 | 83.5 | 84.4 |
265
+ | **WMT25 (10 langs)** | | | |
266
+ | ** **MQM ↓ | N/A | 7.94 | 5.86 |
267
+ | **Vistra* (4 langs)** | | | |
268
+ | ** **MetricX ↓ | 2.57 | 2.08 | 1.57 |
269
+
270
+ * The Vistra corpus was filtered for images that contain a single text.
271
+
272
+ ## Ethics and Safety
273
+
274
+ Ethics and safety evaluation approach and results.
275
+
276
+ ### Evaluation Approach
277
+
278
+ Our evaluation methods include structured evaluations and internal red-teaming testing of relevant content policies. Red-teaming was conducted by a number of different teams, each with different goals and human evaluation metrics. These models were evaluated against a number of different categories relevant to ethics and safety, including:
279
+
280
+ + **Child Safety**: Evaluation of text-to-text and image to text prompts covering child safety policies, including child sexual abuse and exploitation.
281
+ + **Content Safety:** Evaluation of text-to-text and image to text prompts covering safety policies including, harassment, violence and gore, and hate speech.
282
+ + **Representational Harms**: Evaluation of text-to-text and image to text prompts covering safety policies including bias, stereotyping, and harmful associations or inaccuracies.
283
+
284
+ ### Evaluation Results
285
+
286
+ For all areas of safety testing, we saw major improvements in the categories of child safety, content safety, and representational harms relative to previous Gemma models. All testing was conducted without safety filters to evaluate the model capabilities and behaviors. For both text-to-text and image-to-text, and across all model sizes, the model produced minimal policy violations, and showed significant improvements over previous Gemma models' performance with respect to ungrounded inferences.
287
+
288
+ ## Usage and Limitations
289
+
290
+ These models have certain limitations that users should be aware of.
291
+
292
+ ### Intended Usage
293
+
294
+ The models have been trained with the explicit goal of producing text translation from textual or image output. No claims about other capabilities are made about these models.
295
+
296
+ ### Limitations
297
+
298
+ + Training Data
299
+
300
+ + The quality and diversity of the training data significantly influence the model's capabilities. Biases or gaps in the training data can lead to limitations in the model's responses.
301
+ + The scope of the training dataset determines the subject areas the model can handle effectively.
302
+
303
+ + Context and Task Complexity
304
+
305
+ + Models are better at tasks that can be framed with clear prompts and instructions. Open-ended or highly complex tasks might be challenging.
306
+ + A model's performance can be influenced by the amount of context provided (longer context generally leads to better outputs, up to a certain point).
307
+
308
+ + Language Ambiguity and Nuance
309
+
310
+ + Natural language is inherently complex. Models might struggle to grasp subtle nuances, sarcasm, or figurative language.
311
+
312
+ + Factual Accuracy
313
+
314
+ + Models generate responses based on information they learned from their training datasets, but they are not knowledge bases. They may generate incorrect or outdated factual statements.
315
+
316
+ + Common Sense
317
+
318
+ + Models rely on statistical patterns in language. They might lack the ability to apply common sense reasoning in certain situations.
319
+
320
+ ### Ethical Considerations and Risks
321
+
322
+ The development of vision-language models (VLMs) raises several ethical concerns. In creating an open model, we have carefully considered the following:
323
+
324
+ + Bias and Fairness
325
+
326
+ + VLMs trained on large-scale, real-world text and image data can reflect socio-cultural biases embedded in the training material. These models underwent careful scrutiny, input data pre-processing described and posterior evaluations reported in this card.
327
+
328
+ + Misinformation and Misuse
329
+
330
+ + VLMs can be misused to generate text that is false, misleading, or harmful.
331
+ + Guidelines are provided for responsible use with the model, see the [Responsible Generative AI Toolkit](https://ai.google.dev/responsible).
332
+
333
+ + Transparency and Accountability:
334
+
335
+ + This model card summarizes details on the models' architecture, capabilities, limitations, and evaluation processes.
336
+ + A responsibly developed open model offers the opportunity to share innovation by making VLM technology accessible to developers and researchers across the AI ecosystem.
337
+
338
+ Risks identified and mitigations:
339
+
340
+ + **Perpetuation of biases**: It's encouraged to perform continuous monitoring (using evaluation metrics, human review) and the exploration of de-biasing techniques during model training, fine-tuning, and other use cases.
341
+ + **Generation of harmful content**: Mechanisms and guidelines for content safety are essential. Developers are encouraged to exercise caution and implement appropriate content safety safeguards based on their specific product policies and application use cases.
342
+ + **Misuse for malicious purposes**: Technical limitations and developer and end-user education can help mitigate against malicious applications of VLMs. Educational resources and reporting mechanisms for users to flag misuse are provided. Prohibited uses of Gemma models are outlined in the [Gemma Prohibited Use Policy](https://ai.google.dev/gemma/prohibited_use_policy).
343
+ + **Privacy violations**: Models were trained on data filtered for removal of certain personal information and other sensitive data. Developers are encouraged to adhere to privacy regulations with privacy-preserving techniques.
344
+
345
+ ### Benefits
346
+
347
+ At the time of release, this family of models provides high-performance translation model implementations fine-tuned from Gemma 3 models.
348
+ Using the benchmark evaluation metrics described in this document, these models have shown to provide superior performance to other, comparably-sized open model alternatives.