Files changed (1) hide show
  1. README.md +53 -77
README.md CHANGED
@@ -13,8 +13,7 @@ pipeline_tag: any-to-any
13
  <p align="center">
14
  <a href="https://huggingface.co/collections/google/gemma-4" target="_blank">Hugging Face</a> |
15
  <a href="https://github.com/google-gemma" target="_blank">GitHub</a> |
16
- <a href="https://ai.google.dev/gemma/docs/mtp/mtp" target="_blank">MTP Documentation</a> |
17
- <a href="https://arxiv.org/abs/2607.02770" target="_blank">Technical Report</a>
18
  <br>
19
  <b>License</b>: <a href="https://ai.google.dev/gemma/docs/gemma_4_license" target="_blank">Apache 2.0</a> | <b>Authors</b>: <a href="https://deepmind.google/models/gemma/" target="_blank">Google DeepMind</a>
20
  </p>
@@ -22,15 +21,15 @@ pipeline_tag: any-to-any
22
  > [!Note]
23
  > This model card is for the Multi-Token Prediction (MTP) drafters for the Gemma 4 models. MTP is implemented by extending the base model with a smaller, faster draft model. When used in a Speculative Decoding pipeline, the draft model predicts several tokens ahead, which the target model then verifies in parallel. This results in significant decoding speedups (up to 3x) while guaranteeing the exact same quality as standard generation, making these checkpoints perfect for low-latency and on-device applications.
24
 
25
- Gemma is a family of open models built by Google DeepMind. Gemma 4 models are multimodal, handling text and image input (with audio supported on E2B, E4B, and 12B) and generating text output. This release includes open-weights models in both pre-trained and instruction-tuned variants. Gemma 4 features a context window of up to 256K tokens and maintains multilingual support in over 140 languages.
26
 
27
- Featuring both Dense and Mixture-of-Experts (MoE) architectures, Gemma 4 is well-suited for tasks like text generation, coding, and reasoning. The models are available in five distinct sizes: **E2B**, **E4B**, **12B**, **26B A4B**, and **31B**. Their diverse sizes make them deployable in environments ranging from high-end phones to laptops and servers, democratizing access to state-of-the-art AI.
28
 
29
  Gemma 4 introduces key **capability and architectural advancements**:
30
 
31
  * **Reasoning** – All models in the family are designed as highly capable reasoners, with configurable thinking modes.
32
 
33
- * **Extended Multimodalities** – Processes Text, Image with variable aspect ratio and resolution support (all models), Video, and Audio (featured natively on the E2B, E4B, and 12B models).
34
 
35
  * **Diverse & Efficient Architectures** – Offers Dense and Mixture-of-Experts (MoE) variants of different sizes for scalable deployment.
36
 
@@ -44,27 +43,25 @@ Gemma 4 introduces key **capability and architectural advancements**:
44
 
45
  ## **Models Overview**
46
 
47
- Gemma 4 models are designed to deliver frontier-level performance at each size, targeting deployment scenarios from mobile and edge devices (E2B, E4B) to consumer GPUs and workstations (12B, 26B A4B, 31B). They are well-suited for reasoning, agentic workflows, coding, and multimodal understanding.
48
 
49
  The models employ a hybrid attention mechanism that interleaves local sliding window attention with full global attention, ensuring the final layer is always global. This hybrid design delivers the processing speed and low memory footprint of a lightweight model without sacrificing the deep awareness required for complex, long-context tasks. To optimize memory for long contexts, global layers feature unified Keys and Values, and apply Proportional RoPE (p-RoPE).
50
 
51
  ### Dense Models
52
 
53
- | Property | E2B | E4B | 12B Unified | 31B Dense |
54
- | :---- | :---- | :---- | :---- | :---- |
55
- | **Total Parameters** | 2.3B effective <br> (5.1B with embeddings) | 4.5B effective <br> (8B with embeddings) | 11.95B | 30.7B |
56
- | **Layers** | 35 | 42 | 48 | 60 |
57
- | **Sliding Window** | 512 tokens | 512 tokens | 1024 tokens | 1024 tokens |
58
- | **Context Length** | 128K tokens | 128K tokens | 256K tokens | 256K tokens |
59
- | **Vocabulary Size** | 262K | 262K | 262K | 262K |
60
- | **Supported Modalities** | Text, Image, Audio | Text, Image, Audio | Text, Image, Audio | Text, Image |
61
- | **Vision Encoder Parameters** | *~150M* | *~150M* | - | *~550M* |
62
- | **Audio Encoder Parameters** | *~300M* | *~300M* | - | No Audio |
63
 
64
  The "E" in E2B and E4B stands for "effective" parameters. The smaller models incorporate Per-Layer Embeddings (PLE) to maximize parameter efficiency in on-device deployments. Rather than adding more layers or parameters to the model, PLE gives each decoder layer its own small embedding for every token. These embedding tables are large but are only used for quick lookups, which is why the effective parameter count is much smaller than the total.
65
 
66
- The "Unified" in Gemma 4 12B Unified refers to its encoder-free architecture. Other Gemma 4 models use dedicated encoders to process multimodal data before passing it to the LLM. Gemma 4 12B eliminates these encoders entirely, projecting raw image patches and audio waveforms directly into the LLM's embedding space through lightweight linear layers. This unified approach means all modalities flow straight into a single decoder-only transformer, reducing multimodal latency and allowing the entire model to be fine-tuned in one pass.
67
-
68
  ### Mixture-of-Experts (MoE) Model
69
 
70
  | Property | 26B A4B MoE |
@@ -85,44 +82,42 @@ The "A" in 26B A4B stands for "active parameters" in contrast to the total numbe
85
 
86
  These models were evaluated against a large collection of different datasets and metrics to cover different aspects of text generation. Evaluation results marked in the table are for instruction-tuned models.
87
 
88
- | | Gemma 4 31B | Gemma 4 26B A4B | Gemma 4 12B Unified | Gemma 4 E4B | Gemma 4 E2B | Gemma 3 27B (no think) |
89
- | :---- | :---- | :---- | :---- | :---- | :---- | :---- |
90
- | MMLU Pro | 85.2% | 82.6% | 77.2% | 69.4% | 60.0% | 67.6% |
91
- | AIME 2026 no tools | 89.2% | 88.3% | 77.5% | 42.5% | 37.5% | 20.8% |
92
- | LiveCodeBench v6 | 80.0% | 77.1% | 72.0% | 52.0% | 44.0% | 29.1% |
93
- | Codeforces ELO | 2150 | 1718 | 1659 | 940 | 633 | 110 |
94
- | GPQA Diamond | 84.3% | 82.3% | 78.8% | 58.6% | 43.4% | 42.4% |
95
- | Tau2 (average over 3) | 76.9% | 68.2% | 69.0% | 42.2% | 24.5% | 16.2% |
96
- | HLE no tools | 19.5% | 8.7% | 5.2% | - | - | - |
97
- | HLE with search | 26.5% | 17.2% | - | - | - | - |
98
- | BigBench Extra Hard | 74.4% | 64.8% | 53.0% | 33.1% | 21.9% | 19.3% |
99
- | MMMLU | 88.4% | 86.3% | 83.4% | 76.6% | 67.4% | 70.7% |
100
- | **Vision** | | | | | | |
101
- | MMMU Pro | 76.9% | 73.8% | 69.1% | 52.6% | 44.2% | 49.7% |
102
- | OmniDocBench 1.5 (average edit distance, lower is better) | 0.131 | 0.149 | 0.164 | 0.181 | 0.290 | 0.365 |
103
- | MATH-Vision | 85.6% | 82.4% | 79.7% | 59.5% | 52.4% | 46.0% |
104
- | MedXPertQA MM | 61.3% | 58.1% | 48.7% | 28.7% | 23.5% | - |
105
- | **Audio** | | | | | | |
106
- | CoVoST | - | - | 38.5<sup>*</sup> | 35.54 | 33.47 | - |
107
- | FLEURS (lower is better) | - | - | 0.069<sup>*</sup> | 0.08 | 0.09 | - |
108
- | **Long Context** | | | | | | |
109
- | MRCR v2 8 needle 128k (average) | 66.4% | 44.1% | 43.4% | 25.4% | 19.1% | 13.5% |
110
-
111
- <sup>*</sup>Excluding Chinese language.
112
 
113
  ## **Core Capabilities**
114
 
115
  Gemma 4 models handle a broad range of tasks across text, vision, and audio. Key capabilities include:
116
 
117
  * **Thinking** – Built-in reasoning mode that lets the model think step-by-step before answering.
118
- * **Long Context** – Context windows of up to 128K tokens (E2B/E4B) and 256K tokens (12B, 26B A4B/31B).
119
  * **Image Understanding** – Object detection, Document/PDF parsing, screen and UI understanding, chart comprehension, OCR (including multilingual), handwriting recognition, and pointing. Images can be processed at variable aspect ratios and resolutions.
120
  * **Video Understanding** – Analyze video by processing sequences of frames.
121
  * **Interleaved Multimodal Input** – Freely mix text and images in any order within a single prompt.
122
  * **Function Calling** – Native support for structured tool use, enabling agentic workflows.
123
  * **Coding** – Code generation, completion, and correction.
124
  * **Multilingual** – Out-of-the-box support for 35+ languages, pre-trained on 140+ languages.
125
- * **Audio** (E2B, E4B, and 12B only) – Automatic speech recognition (ASR) and speech-to-translated-text translation across multiple languages.
126
 
127
 
128
  ## Getting Started
@@ -166,14 +161,12 @@ messages = [
166
  ]
167
 
168
  # Process input
169
- inputs = processor.apply_chat_template(
170
- messages,
171
- tokenize=True,
172
- return_dict=True,
173
- return_tensors="pt",
174
- add_generation_prompt=True,
175
- enable_thinking=False
176
- ).to(model.device)
177
  input_len = inputs["input_ids"].shape[-1]
178
 
179
  # Generate output
@@ -190,12 +183,12 @@ processor.parse_response(response)
190
 
191
  To enable reasoning, set `enable_thinking=True` and the `parse_response` function will take care of parsing the thinking output.
192
 
193
- Below, you will also find snippets for processing audio (E2B, E4B, and 12B only), images, and video alongside text:
194
 
195
  <details>
196
  <summary>Code for processing Audio</summary>
197
 
198
- Make sure to install the following packages:
199
 
200
 
201
  `pip install -U transformers torch torchvision librosa accelerate`
@@ -267,7 +260,7 @@ processor.parse_response(response)
267
  <details>
268
  <summary>Code for processing Images</summary>
269
 
270
- Make sure to install the following packages:
271
 
272
 
273
  `pip install -U transformers torch torchvision accelerate`
@@ -336,7 +329,7 @@ processor.parse_response(response)
336
  <details>
337
  <summary>Code for processing Videos</summary>
338
 
339
- Make sure to install the following packages:
340
 
341
  `pip install -U transformers torch torchvision librosa accelerate`
342
 
@@ -403,7 +396,6 @@ processor.parse_response(response)
403
 
404
 
405
 
406
-
407
  ## **Best Practices**
408
 
409
  For the best performance, use these configurations and best practices:
@@ -431,7 +423,7 @@ Compared to Gemma 3, the models use standard `system`, `assistant`, and `user` r
431
 
432
  ### 3. Multi-Turn Conversations
433
 
434
- * **No Thinking Content in History**: In multi-turn conversations, the historical model output should only include the final response. Thoughts from previous model turns must *not be added* before the next user turn begins, with the exception of tool call turns where thinking content should be preserved.
435
 
436
  ### 4. Modality order
437
 
@@ -471,7 +463,7 @@ When formatting the answer, first output the transcription in {SOURCE_LANGUAGE},
471
 
472
  ### 7. Audio and Video Length
473
 
474
- All models support image inputs and can process videos as frames whereas the E2B, E4B, and 12B models also support audio inputs. Audio supports a maximum length of 30 seconds. Video supports a maximum of 60 seconds assuming the images are processed at one frame per second.
475
 
476
  ## **Model Data**
477
 
@@ -527,7 +519,7 @@ Multimodal models (capable of processing vision, language, and/or audio) have a
527
  * **Chatbots and Conversational AI**: Power conversational interfaces for customer service, virtual assistants, or interactive applications.
528
  * **Text Summarization**: Generate concise summaries of a text corpus, research papers, or reports.
529
  * **Image Data Extraction**: These models can be used to extract, interpret, and summarize visual data for text communications.
530
- * **Audio Processing and Interaction**: The E2B, E4B, and 12B models can analyze and interpret audio inputs, enabling voice-driven interactions and transcriptions.
531
  * **Research and Education**
532
  * **Natural Language Processing (NLP) and VLM Research**: These models can serve as a foundation for researchers to experiment with VLM and NLP techniques, develop algorithms, and contribute to the advancement of the field.
533
  * **Language Learning Tools**: Support interactive language learning experiences, aiding in grammar correction or providing writing practice.
@@ -570,20 +562,4 @@ The development of vision-language models (VLMs) raises several ethical concerns
570
 
571
  ### **Benefits**
572
 
573
- At the time of release, this family of models provides high-performance open vision-language model implementations designed from the ground up for responsible AI development compared to similarly sized models.
574
-
575
- ## **Citation**
576
-
577
- If you find our work helpful, please consider citing it:
578
-
579
- ```bibtex
580
- @misc{gemmateam2026gemma4,
581
- title={Gemma 4 Technical Report},
582
- author={Gemma Team},
583
- year={2026},
584
- eprint={2607.02770},
585
- archivePrefix={arXiv},
586
- primaryClass={cs.CL},
587
- url={https://arxiv.org/abs/2607.02770},
588
- }
589
- ```
 
13
  <p align="center">
14
  <a href="https://huggingface.co/collections/google/gemma-4" target="_blank">Hugging Face</a> |
15
  <a href="https://github.com/google-gemma" target="_blank">GitHub</a> |
16
+ <a href="https://ai.google.dev/gemma/docs/mtp/mtp" target="_blank">MTP Documentation</a>
 
17
  <br>
18
  <b>License</b>: <a href="https://ai.google.dev/gemma/docs/gemma_4_license" target="_blank">Apache 2.0</a> | <b>Authors</b>: <a href="https://deepmind.google/models/gemma/" target="_blank">Google DeepMind</a>
19
  </p>
 
21
  > [!Note]
22
  > This model card is for the Multi-Token Prediction (MTP) drafters for the Gemma 4 models. MTP is implemented by extending the base model with a smaller, faster draft model. When used in a Speculative Decoding pipeline, the draft model predicts several tokens ahead, which the target model then verifies in parallel. This results in significant decoding speedups (up to 3x) while guaranteeing the exact same quality as standard generation, making these checkpoints perfect for low-latency and on-device applications.
23
 
24
+ Gemma is a family of open models built by Google DeepMind. Gemma 4 models are multimodal, handling text and image input (with audio supported on small models) and generating text output. This release includes open-weights models in both pre-trained and instruction-tuned variants. Gemma 4 features a context window of up to 256K tokens and maintains multilingual support in over 140 languages.
25
 
26
+ Featuring both Dense and Mixture-of-Experts (MoE) architectures, Gemma 4 is well-suited for tasks like text generation, coding, and reasoning. The models are available in four distinct sizes: **E2B**, **E4B**, **26B A4B**, and **31B**. Their diverse sizes make them deployable in environments ranging from high-end phones to laptops and servers, democratizing access to state-of-the-art AI.
27
 
28
  Gemma 4 introduces key **capability and architectural advancements**:
29
 
30
  * **Reasoning** – All models in the family are designed as highly capable reasoners, with configurable thinking modes.
31
 
32
+ * **Extended Multimodalities** – Processes Text, Image with variable aspect ratio and resolution support (all models), Video, and Audio (featured natively on the E2B and E4B models).
33
 
34
  * **Diverse & Efficient Architectures** – Offers Dense and Mixture-of-Experts (MoE) variants of different sizes for scalable deployment.
35
 
 
43
 
44
  ## **Models Overview**
45
 
46
+ Gemma 4 models are designed to deliver frontier-level performance at each size, targeting deployment scenarios from mobile and edge devices (E2B, E4B) to consumer GPUs and workstations (26B A4B, 31B). They are well-suited for reasoning, agentic workflows, coding, and multimodal understanding.
47
 
48
  The models employ a hybrid attention mechanism that interleaves local sliding window attention with full global attention, ensuring the final layer is always global. This hybrid design delivers the processing speed and low memory footprint of a lightweight model without sacrificing the deep awareness required for complex, long-context tasks. To optimize memory for long contexts, global layers feature unified Keys and Values, and apply Proportional RoPE (p-RoPE).
49
 
50
  ### Dense Models
51
 
52
+ | Property | E2B | E4B | 31B Dense |
53
+ | :---- | :---- | :---- | :---- |
54
+ | **Total Parameters** | 2.3B effective (5.1B with embeddings) | 4.5B effective (8B with embeddings) | 30.7B |
55
+ | **Layers** | 35 | 42 | 60 |
56
+ | **Sliding Window** | 512 tokens | 512 tokens | 1024 tokens |
57
+ | **Context Length** | 128K tokens | 128K tokens | 256K tokens |
58
+ | **Vocabulary Size** | 262K | 262K | 262K |
59
+ | **Supported Modalities** | Text, Image, Audio | Text, Image, Audio | Text, Image |
60
+ | **Vision Encoder Parameters** | *~150M* | *~150M* | *~550M* |
61
+ | **Audio Encoder Parameters** | *~300M* | *~300M* | No Audio |
62
 
63
  The "E" in E2B and E4B stands for "effective" parameters. The smaller models incorporate Per-Layer Embeddings (PLE) to maximize parameter efficiency in on-device deployments. Rather than adding more layers or parameters to the model, PLE gives each decoder layer its own small embedding for every token. These embedding tables are large but are only used for quick lookups, which is why the effective parameter count is much smaller than the total.
64
 
 
 
65
  ### Mixture-of-Experts (MoE) Model
66
 
67
  | Property | 26B A4B MoE |
 
82
 
83
  These models were evaluated against a large collection of different datasets and metrics to cover different aspects of text generation. Evaluation results marked in the table are for instruction-tuned models.
84
 
85
+ | | Gemma 4 31B | Gemma 4 26B A4B | Gemma 4 E4B | Gemma 4 E2B | Gemma 3 27B (no think) |
86
+ | :---- | :---- | :---- | :---- | :---- | :---- |
87
+ | MMLU Pro | 85.2% | 82.6% | 69.4% | 60.0% | 67.6% |
88
+ | AIME 2026 no tools | 89.2% | 88.3% | 42.5% | 37.5% | 20.8% |
89
+ | LiveCodeBench v6 | 80.0% | 77.1% | 52.0% | 44.0% | 29.1% |
90
+ | Codeforces ELO | 2150 | 1718 | 940 | 633 | 110 |
91
+ | GPQA Diamond | 84.3% | 82.3% | 58.6% | 43.4% | 42.4% |
92
+ | Tau2 (average over 3) | 76.9% | 68.2% | 42.2% | 24.5% | 16.2% |
93
+ | HLE no tools | 19.5% | 8.7% | - | - | - |
94
+ | HLE with search | 26.5% | 17.2% | - | - | - |
95
+ | BigBench Extra Hard | 74.4% | 64.8% | 33.1% | 21.9% | 19.3% |
96
+ | MMMLU | 88.4% | 86.3% | 76.6% | 67.4% | 70.7% |
97
+ | **Vision** | | | | | |
98
+ | MMMU Pro | 76.9% | 73.8% | 52.6% | 44.2% | 49.7% |
99
+ | OmniDocBench 1.5 (average edit distance, lower is better) | 0.131 | 0.149 | 0.181 | 0.290 | 0.365 |
100
+ | MATH-Vision | 85.6% | 82.4% | 59.5% | 52.4% | 46.0% |
101
+ | MedXPertQA MM | 61.3% | 58.1% | 28.7% | 23.5% | - |
102
+ | **Audio** | | | | | |
103
+ | CoVoST | - | - | 35.54 | 33.47 | - |
104
+ | FLEURS (lower is better) | - | - | 0.08 | 0.09 | - |
105
+ | **Long Context** | | | | | |
106
+ | MRCR v2 8 needle 128k (average) | 66.4% | 44.1% | 25.4% | 19.1% | 13.5% |
 
 
107
 
108
  ## **Core Capabilities**
109
 
110
  Gemma 4 models handle a broad range of tasks across text, vision, and audio. Key capabilities include:
111
 
112
  * **Thinking** – Built-in reasoning mode that lets the model think step-by-step before answering.
113
+ * **Long Context** – Context windows of up to 128K tokens (E2B/E4B) and 256K tokens (26B A4B/31B).
114
  * **Image Understanding** – Object detection, Document/PDF parsing, screen and UI understanding, chart comprehension, OCR (including multilingual), handwriting recognition, and pointing. Images can be processed at variable aspect ratios and resolutions.
115
  * **Video Understanding** – Analyze video by processing sequences of frames.
116
  * **Interleaved Multimodal Input** – Freely mix text and images in any order within a single prompt.
117
  * **Function Calling** – Native support for structured tool use, enabling agentic workflows.
118
  * **Coding** – Code generation, completion, and correction.
119
  * **Multilingual** – Out-of-the-box support for 35+ languages, pre-trained on 140+ languages.
120
+ * **Audio** (E2B and E4B only) – Automatic speech recognition (ASR) and speech-to-translated-text translation across multiple languages.
121
 
122
 
123
  ## Getting Started
 
161
  ]
162
 
163
  # Process input
164
+ text = processor.apply_chat_template(
165
+ messages,
166
+ tokenize=False,
167
+ add_generation_prompt=True,
168
+ )
169
+ inputs = processor(text=text, return_tensors="pt").to(target_model.device)
 
 
170
  input_len = inputs["input_ids"].shape[-1]
171
 
172
  # Generate output
 
183
 
184
  To enable reasoning, set `enable_thinking=True` and the `parse_response` function will take care of parsing the thinking output.
185
 
186
+ Below, you will also find snippets for processing audio (E2B and E4B only), images, and video alongside text:
187
 
188
  <details>
189
  <summary>Code for processing Audio</summary>
190
 
191
+ Instead of using `AutoModelForCausalLM`, you can use `AutoModelForMultimodalLM` to process audio. To use it, make sure to install the following packages:
192
 
193
 
194
  `pip install -U transformers torch torchvision librosa accelerate`
 
260
  <details>
261
  <summary>Code for processing Images</summary>
262
 
263
+ Instead of using `AutoModelForCausalLM`, you can use `AutoModelForMultimodalLM` to process images. To use it, make sure to install the following packages:
264
 
265
 
266
  `pip install -U transformers torch torchvision accelerate`
 
329
  <details>
330
  <summary>Code for processing Videos</summary>
331
 
332
+ Instead of using `AutoModelForCausalLM`, you can use `AutoModelForMultimodalLM` to process videos. To use it, make sure to install the following packages:
333
 
334
  `pip install -U transformers torch torchvision librosa accelerate`
335
 
 
396
 
397
 
398
 
 
399
  ## **Best Practices**
400
 
401
  For the best performance, use these configurations and best practices:
 
423
 
424
  ### 3. Multi-Turn Conversations
425
 
426
+ * **No Thinking Content in History**: In multi-turn conversations, the historical model output should only include the final response. Thoughts from previous model turns must *not be added* before the next user turn begins.
427
 
428
  ### 4. Modality order
429
 
 
463
 
464
  ### 7. Audio and Video Length
465
 
466
+ All models support image inputs and can process videos as frames whereas the E2B and E4B models also support audio inputs. Audio supports a maximum length of 30 seconds. Video supports a maximum of 60 seconds assuming the images are processed at one frame per second.
467
 
468
  ## **Model Data**
469
 
 
519
  * **Chatbots and Conversational AI**: Power conversational interfaces for customer service, virtual assistants, or interactive applications.
520
  * **Text Summarization**: Generate concise summaries of a text corpus, research papers, or reports.
521
  * **Image Data Extraction**: These models can be used to extract, interpret, and summarize visual data for text communications.
522
+ * **Audio Processing and Interaction**: The smaller models (E2B and E4B) can analyze and interpret audio inputs, enabling voice-driven interactions and transcriptions.
523
  * **Research and Education**
524
  * **Natural Language Processing (NLP) and VLM Research**: These models can serve as a foundation for researchers to experiment with VLM and NLP techniques, develop algorithms, and contribute to the advancement of the field.
525
  * **Language Learning Tools**: Support interactive language learning experiences, aiding in grammar correction or providing writing practice.
 
562
 
563
  ### **Benefits**
564
 
565
+ At the time of release, this family of models provides high-performance open vision-language model implementations designed from the ground up for responsible AI development compared to similarly sized models.