gemma-4-e4b-it

#25
Files changed (3) hide show
  1. README.md +63 -89
  2. chat_template.jinja +46 -88
  3. tokenizer_config.json +0 -46
README.md CHANGED
@@ -3,8 +3,6 @@ library_name: transformers
3
  license: apache-2.0
4
  license_link: https://ai.google.dev/gemma/docs/gemma_4_license
5
  pipeline_tag: any-to-any
6
- base_model:
7
- - google/gemma-4-E4B
8
  ---
9
 
10
  <div align="center">
@@ -16,21 +14,20 @@ base_model:
16
  <a href="https://huggingface.co/collections/google/gemma-4" target="_blank">Hugging Face</a> |
17
  <a href="https://github.com/google-gemma" target="_blank">GitHub</a> |
18
  <a href="https://blog.google/innovation-and-ai/technology/developers-tools/gemma-4/" target="_blank">Launch Blog</a> |
19
- <a href="https://ai.google.dev/gemma/docs/core" target="_blank">Documentation</a> |
20
- <a href="https://arxiv.org/abs/2607.02770" target="_blank">Technical Report</a>
21
  <br>
22
  <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>
23
  </p>
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 +41,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 +80,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
@@ -134,13 +127,13 @@ You can use all Gemma 4 models with the latest version of Transformers. To get s
134
  Once you have everything installed, you can proceed to load the model with the code below:
135
 
136
  ```python
137
- from transformers import AutoProcessor, AutoModelForMultimodalLM
138
 
139
  MODEL_ID = "google/gemma-4-E4B-it"
140
 
141
  # Load model
142
  processor = AutoProcessor.from_pretrained(MODEL_ID)
143
- model = AutoModelForMultimodalLM.from_pretrained(
144
  MODEL_ID,
145
  dtype="auto",
146
  device_map="auto"
@@ -157,14 +150,13 @@ messages = [
157
  ]
158
 
159
  # Process input
160
- inputs = processor.apply_chat_template(
161
- messages,
162
- tokenize=True,
163
- return_dict=True,
164
- return_tensors="pt",
165
- add_generation_prompt=True,
166
  enable_thinking=False
167
- ).to(model.device)
 
168
  input_len = inputs["input_ids"].shape[-1]
169
 
170
  # Generate output
@@ -172,17 +164,18 @@ outputs = model.generate(**inputs, max_new_tokens=1024)
172
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
173
 
174
  # Parse output
175
- processor.parse_response(response, prefix=inputs["input_ids"])
176
  ```
177
 
178
  To enable reasoning, set `enable_thinking=True` and the `parse_response` function will take care of parsing the thinking output.
179
 
180
- Below, you will also find snippets for processing audio (E2B, E4B, 12B only), images, and video alongside text:
181
 
182
  <details>
183
  <summary>Code for processing Audio</summary>
184
 
185
- Make sure to install the following packages:
 
186
 
187
  `pip install -U transformers torch torchvision librosa accelerate`
188
 
@@ -206,13 +199,13 @@ Once the model is loaded, you can start generating output by directly referencin
206
 
207
 
208
  ```python
209
- # Prompt - add audio after text
210
  messages = [
211
  {
212
  "role": "user",
213
  "content": [
 
214
  {"type": "text", "text": "Transcribe the following speech segment in its original language. Follow these specific instructions for formatting the answer:\n* Only output the transcription, with no newlines.\n* When transcribing numbers, write the digits, i.e. write 1.7 and not one point seven, and write 3 instead of three."},
215
- {"type": "audio", "audio": "https://raw.githubusercontent.com/google-gemma/cookbook/refs/heads/main/apps/sample-data/journal1.wav"},
216
  ]
217
  }
218
  ]
@@ -232,7 +225,7 @@ outputs = model.generate(**inputs, max_new_tokens=512)
232
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
233
 
234
  # Parse output
235
- processor.parse_response(response, prefix=inputs["input_ids"])
236
  ```
237
 
238
  </details>
@@ -240,7 +233,7 @@ processor.parse_response(response, prefix=inputs["input_ids"])
240
  <details>
241
  <summary>Code for processing Images</summary>
242
 
243
- Make sure to install the following packages:
244
 
245
 
246
  `pip install -U transformers torch torchvision accelerate`
@@ -269,7 +262,7 @@ Once the model is loaded, you can start generating output by directly referencin
269
  messages = [
270
  {
271
  "role": "user", "content": [
272
- {"type": "image", "url": "https://raw.githubusercontent.com/google-gemma/cookbook/refs/heads/main/apps/sample-data/GoldenGate.png"},
273
  {"type": "text", "text": "What is shown in this image?"}
274
  ]
275
  }
@@ -290,7 +283,7 @@ outputs = model.generate(**inputs, max_new_tokens=512)
290
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
291
 
292
  # Parse output
293
- processor.parse_response(response, prefix=inputs["input_ids"])
294
  ```
295
 
296
  </details>
@@ -299,7 +292,7 @@ processor.parse_response(response, prefix=inputs["input_ids"])
299
  <details>
300
  <summary>Code for processing Videos</summary>
301
 
302
- Make sure to install the following packages:
303
 
304
  `pip install -U transformers torch torchvision librosa accelerate`
305
 
@@ -349,7 +342,7 @@ outputs = model.generate(**inputs, max_new_tokens=512)
349
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
350
 
351
  # Parse output
352
- processor.parse_response(response, prefix=inputs["input_ids"])
353
  ```
354
 
355
  </details>
@@ -383,14 +376,11 @@ Compared to Gemma 3, the models use standard `system`, `assistant`, and `user` r
383
 
384
  ### 3. Multi-Turn Conversations
385
 
386
- * **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.
387
 
388
  ### 4. Modality order
389
 
390
- For optimal performance with multimodal inputs, place:
391
-
392
- * Image content **before** the text in your prompt.
393
- * Audio content **after** the text in your prompt.
394
 
395
  ### 5. Variable Image Resolution
396
 
@@ -423,7 +413,7 @@ When formatting the answer, first output the transcription in {SOURCE_LANGUAGE},
423
 
424
  ### 7. Audio and Video Length
425
 
426
- 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.
427
 
428
  ## **Model Data**
429
 
@@ -479,7 +469,7 @@ Multimodal models (capable of processing vision, language, and/or audio) have a
479
  * **Chatbots and Conversational AI**: Power conversational interfaces for customer service, virtual assistants, or interactive applications.
480
  * **Text Summarization**: Generate concise summaries of a text corpus, research papers, or reports.
481
  * **Image Data Extraction**: These models can be used to extract, interpret, and summarize visual data for text communications.
482
- * **Audio Processing and Interaction**: The E2B, E4B, and 12B models can analyze and interpret audio inputs, enabling voice-driven interactions and transcriptions.
483
  * **Research and Education**
484
  * **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.
485
  * **Language Learning Tools**: Support interactive language learning experiences, aiding in grammar correction or providing writing practice.
@@ -523,19 +513,3 @@ The development of vision-language models (VLMs) raises several ethical concerns
523
  ### **Benefits**
524
 
525
  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.
526
-
527
- ## **Citation**
528
-
529
- If you find our work helpful, please consider citing it:
530
-
531
- ```bibtex
532
- @misc{gemmateam2026gemma4,
533
- title={Gemma 4 Technical Report},
534
- author={Gemma Team},
535
- year={2026},
536
- eprint={2607.02770},
537
- archivePrefix={arXiv},
538
- primaryClass={cs.CL},
539
- url={https://arxiv.org/abs/2607.02770},
540
- }
541
- ```
 
3
  license: apache-2.0
4
  license_link: https://ai.google.dev/gemma/docs/gemma_4_license
5
  pipeline_tag: any-to-any
 
 
6
  ---
7
 
8
  <div 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://blog.google/innovation-and-ai/technology/developers-tools/gemma-4/" target="_blank">Launch Blog</a> |
17
+ <a href="https://ai.google.dev/gemma/docs/core" target="_blank">Documentation</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>
21
 
22
+ 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.
23
 
24
+ 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.
25
 
26
  Gemma 4 introduces key **capability and architectural advancements**:
27
 
28
  * **Reasoning** – All models in the family are designed as highly capable reasoners, with configurable thinking modes.
29
 
30
+ * **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).
31
 
32
  * **Diverse & Efficient Architectures** – Offers Dense and Mixture-of-Experts (MoE) variants of different sizes for scalable deployment.
33
 
 
41
 
42
  ## **Models Overview**
43
 
44
+ 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.
45
 
46
  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).
47
 
48
  ### Dense Models
49
 
50
+ | Property | E2B | E4B | 31B Dense |
51
+ | :---- | :---- | :---- | :---- |
52
+ | **Total Parameters** | 2.3B effective (5.1B with embeddings) | 4.5B effective (8B with embeddings) | 30.7B |
53
+ | **Layers** | 35 | 42 | 60 |
54
+ | **Sliding Window** | 512 tokens | 512 tokens | 1024 tokens |
55
+ | **Context Length** | 128K tokens | 128K tokens | 256K tokens |
56
+ | **Vocabulary Size** | 262K | 262K | 262K |
57
+ | **Supported Modalities** | Text, Image, Audio | Text, Image, Audio | Text, Image |
58
+ | **Vision Encoder Parameters** | *~150M* | *~150M* | *~550M* |
59
+ | **Audio Encoder Parameters** | *~300M* | *~300M* | No Audio |
60
 
61
  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.
62
 
 
 
63
  ### Mixture-of-Experts (MoE) Model
64
 
65
  | Property | 26B A4B MoE |
 
80
 
81
  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.
82
 
83
+ | | Gemma 4 31B | Gemma 4 26B A4B | Gemma 4 E4B | Gemma 4 E2B | Gemma 3 27B (no think) |
84
+ | :---- | :---- | :---- | :---- | :---- | :---- |
85
+ | MMLU Pro | 85.2% | 82.6% | 69.4% | 60.0% | 67.6% |
86
+ | AIME 2026 no tools | 89.2% | 88.3% | 42.5% | 37.5% | 20.8% |
87
+ | LiveCodeBench v6 | 80.0% | 77.1% | 52.0% | 44.0% | 29.1% |
88
+ | Codeforces ELO | 2150 | 1718 | 940 | 633 | 110 |
89
+ | GPQA Diamond | 84.3% | 82.3% | 58.6% | 43.4% | 42.4% |
90
+ | Tau2 (average over 3) | 76.9% | 68.2% | 42.2% | 24.5% | 16.2% |
91
+ | HLE no tools | 19.5% | 8.7% | - | - | - |
92
+ | HLE with search | 26.5% | 17.2% | - | - | - |
93
+ | BigBench Extra Hard | 74.4% | 64.8% | 33.1% | 21.9% | 19.3% |
94
+ | MMMLU | 88.4% | 86.3% | 76.6% | 67.4% | 70.7% |
95
+ | **Vision** | | | | | |
96
+ | MMMU Pro | 76.9% | 73.8% | 52.6% | 44.2% | 49.7% |
97
+ | OmniDocBench 1.5 (average edit distance, lower is better) | 0.131 | 0.149 | 0.181 | 0.290 | 0.365 |
98
+ | MATH-Vision | 85.6% | 82.4% | 59.5% | 52.4% | 46.0% |
99
+ | MedXPertQA MM | 61.3% | 58.1% | 28.7% | 23.5% | - |
100
+ | **Audio** | | | | | |
101
+ | CoVoST | - | - | 35.54 | 33.47 | - |
102
+ | FLEURS (lower is better) | - | - | 0.08 | 0.09 | - |
103
+ | **Long Context** | | | | | |
104
+ | MRCR v2 8 needle 128k (average) | 66.4% | 44.1% | 25.4% | 19.1% | 13.5% |
 
 
105
 
106
  ## **Core Capabilities**
107
 
108
  Gemma 4 models handle a broad range of tasks across text, vision, and audio. Key capabilities include:
109
 
110
  * **Thinking** – Built-in reasoning mode that lets the model think step-by-step before answering.
111
+ * **Long Context** – Context windows of up to 128K tokens (E2B/E4B) and 256K tokens (26B A4B/31B).
112
  * **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.
113
  * **Video Understanding** – Analyze video by processing sequences of frames.
114
  * **Interleaved Multimodal Input** – Freely mix text and images in any order within a single prompt.
115
  * **Function Calling** – Native support for structured tool use, enabling agentic workflows.
116
  * **Coding** – Code generation, completion, and correction.
117
  * **Multilingual** – Out-of-the-box support for 35+ languages, pre-trained on 140+ languages.
118
+ * **Audio** (E2B and E4B only) – Automatic speech recognition (ASR) and speech-to-translated-text translation across multiple languages.
119
 
120
 
121
  ## Getting Started
 
127
  Once you have everything installed, you can proceed to load the model with the code below:
128
 
129
  ```python
130
+ from transformers import AutoProcessor, AutoModelForCausalLM
131
 
132
  MODEL_ID = "google/gemma-4-E4B-it"
133
 
134
  # Load model
135
  processor = AutoProcessor.from_pretrained(MODEL_ID)
136
+ model = AutoModelForCausalLM.from_pretrained(
137
  MODEL_ID,
138
  dtype="auto",
139
  device_map="auto"
 
150
  ]
151
 
152
  # Process input
153
+ text = processor.apply_chat_template(
154
+ messages,
155
+ tokenize=False,
156
+ add_generation_prompt=True,
 
 
157
  enable_thinking=False
158
+ )
159
+ inputs = processor(text=text, return_tensors="pt").to(model.device)
160
  input_len = inputs["input_ids"].shape[-1]
161
 
162
  # Generate output
 
164
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
165
 
166
  # Parse output
167
+ processor.parse_response(response)
168
  ```
169
 
170
  To enable reasoning, set `enable_thinking=True` and the `parse_response` function will take care of parsing the thinking output.
171
 
172
+ Below, you will also find snippets for processing audio (E2B and E4B only), images, and video alongside text:
173
 
174
  <details>
175
  <summary>Code for processing Audio</summary>
176
 
177
+ Instead of using `AutoModelForCausalLM`, you can use `AutoModelForMultimodalLM` to process audio. To use it, make sure to install the following packages:
178
+
179
 
180
  `pip install -U transformers torch torchvision librosa accelerate`
181
 
 
199
 
200
 
201
  ```python
202
+ # Prompt - add audio before text
203
  messages = [
204
  {
205
  "role": "user",
206
  "content": [
207
+ {"type": "audio", "audio": "https://raw.githubusercontent.com/google-gemma/cookbook/refs/heads/main/Demos/sample-data/journal1.wav"},
208
  {"type": "text", "text": "Transcribe the following speech segment in its original language. Follow these specific instructions for formatting the answer:\n* Only output the transcription, with no newlines.\n* When transcribing numbers, write the digits, i.e. write 1.7 and not one point seven, and write 3 instead of three."},
 
209
  ]
210
  }
211
  ]
 
225
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
226
 
227
  # Parse output
228
+ processor.parse_response(response)
229
  ```
230
 
231
  </details>
 
233
  <details>
234
  <summary>Code for processing Images</summary>
235
 
236
+ Instead of using `AutoModelForCausalLM`, you can use `AutoModelForMultimodalLM` to process images. To use it, make sure to install the following packages:
237
 
238
 
239
  `pip install -U transformers torch torchvision accelerate`
 
262
  messages = [
263
  {
264
  "role": "user", "content": [
265
+ {"type": "image", "url": "https://raw.githubusercontent.com/google-gemma/cookbook/refs/heads/main/Demos/sample-data/GoldenGate.png"},
266
  {"type": "text", "text": "What is shown in this image?"}
267
  ]
268
  }
 
283
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
284
 
285
  # Parse output
286
+ processor.parse_response(response)
287
  ```
288
 
289
  </details>
 
292
  <details>
293
  <summary>Code for processing Videos</summary>
294
 
295
+ Instead of using `AutoModelForCausalLM`, you can use `AutoModelForMultimodalLM` to process videos. To use it, make sure to install the following packages:
296
 
297
  `pip install -U transformers torch torchvision librosa accelerate`
298
 
 
342
  response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
343
 
344
  # Parse output
345
+ processor.parse_response(response)
346
  ```
347
 
348
  </details>
 
376
 
377
  ### 3. Multi-Turn Conversations
378
 
379
+ * **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.
380
 
381
  ### 4. Modality order
382
 
383
+ * For optimal performance with multimodal inputs, place image and/or audio content **before** the text in your prompt.
 
 
 
384
 
385
  ### 5. Variable Image Resolution
386
 
 
413
 
414
  ### 7. Audio and Video Length
415
 
416
+ 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.
417
 
418
  ## **Model Data**
419
 
 
469
  * **Chatbots and Conversational AI**: Power conversational interfaces for customer service, virtual assistants, or interactive applications.
470
  * **Text Summarization**: Generate concise summaries of a text corpus, research papers, or reports.
471
  * **Image Data Extraction**: These models can be used to extract, interpret, and summarize visual data for text communications.
472
+ * **Audio Processing and Interaction**: The smaller models (E2B and E4B) can analyze and interpret audio inputs, enabling voice-driven interactions and transcriptions.
473
  * **Research and Education**
474
  * **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.
475
  * **Language Learning Tools**: Support interactive language learning experiences, aiding in grammar correction or providing writing practice.
 
513
  ### **Benefits**
514
 
515
  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.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
chat_template.jinja CHANGED
@@ -1,15 +1,9 @@
1
- {#
2
- Template: Google Gemma 4 Canonical Chat Template
3
- Author: Google Gemma Engineering Team
4
- Published: 2026-07-09
5
- Context: Fixed tool-calling loops, turn closures, and thinking content-ordering.
6
- #}
7
- {%- macro format_parameters(properties, required, filter_keys=false) -%}
8
  {%- set standard_keys = ['description', 'type', 'properties', 'required', 'nullable'] -%}
9
  {%- set ns = namespace(found_first=false) -%}
10
  {%- for key, value in properties | dictsort -%}
11
  {%- set add_comma = false -%}
12
- {%- if not filter_keys or key not in standard_keys -%}
13
  {%- if ns.found_first %},{% endif -%}
14
  {%- set ns.found_first = true -%}
15
  {{ key }}:{
@@ -71,7 +65,7 @@
71
  {%- elif value is mapping -%}
72
  {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
73
  properties:{
74
- {{- format_parameters(value, value['required'] | default([]), filter_keys=true) -}}
75
  }
76
  {%- endif -%}
77
  {%- if value['required'] -%}
@@ -122,9 +116,7 @@
122
  }
123
  {%- endmacro -%}
124
  {%- macro format_argument(argument, escape_keys=True) -%}
125
- {%- if argument is none -%}
126
- {{- 'null' -}}
127
- {%- elif argument is string -%}
128
  {{- '<|"|>' + argument + '<|"|>' -}}
129
  {%- elif argument is boolean -%}
130
  {{- 'true' if argument else 'false' -}}
@@ -180,30 +172,24 @@
180
  {{- '<tool_response|>' -}}
181
  {%- endmacro -%}
182
 
183
- {#- ===== SETUP ===== -#}
184
- {%- set ns = namespace(prev_message_type=None, prev_non_tool_role=None) -%}
185
  {%- set loop_messages = messages -%}
186
- {%- set enable_thinking = enable_thinking | default(false) -%}
187
- {%- set preserve_thinking = preserve_thinking | default(false) -%}
188
  {{- bos_token -}}
189
  {#- Handle System/Tool Definitions Block -#}
190
- {%- if enable_thinking or tools or (messages and messages[0]['role'] in ['system', 'developer']) -%}
191
  {{- '<|turn>system\n' -}}
 
192
  {#- Inject Thinking token at the very top of the FIRST system turn -#}
193
- {%- if enable_thinking -%}
194
  {{- '<|think|>\n' -}}
195
  {%- set ns.prev_message_type = 'think' -%}
196
  {%- endif -%}
197
- {%- if messages and messages[0]['role'] in ['system', 'developer'] -%}
198
- {%- if messages[0]['content'] is string -%}
199
- {{- messages[0]['content'] | trim -}}
200
- {%- elif messages[0]['content'] is sequence -%}
201
- {%- for item in messages[0]['content'] -%}
202
- {{- item['text'] | trim + ' '-}}
203
- {%- endfor -%}
204
- {%- endif -%}
205
  {%- set loop_messages = messages[1:] -%}
206
  {%- endif -%}
 
207
  {%- if tools -%}
208
  {%- for tool in tools %}
209
  {{- '<|tool>' -}}
@@ -212,6 +198,7 @@
212
  {%- endfor %}
213
  {%- set ns.prev_message_type = 'tool' -%}
214
  {%- endif -%}
 
215
  {{- '<turn|>\n' -}}
216
  {%- endif %}
217
 
@@ -228,21 +215,31 @@
228
  {%- if message['role'] != 'tool' -%}
229
  {%- set ns.prev_message_type = None -%}
230
  {%- set role = 'model' if message['role'] == 'assistant' else message['role'] -%}
231
- {#- Detect continuation using tracked state O(1) instead of O(n) backward scan -#}
232
- {%- set continue_same_model_turn = (role == 'model' and ns.prev_non_tool_role == 'assistant') -%}
 
 
 
 
 
 
 
 
 
 
 
233
  {%- if not continue_same_model_turn -%}
234
  {{- '<|turn>' + role + '\n' }}
235
  {%- endif -%}
236
 
237
  {#- Render reasoning/reasoning_content as thinking channel -#}
238
  {%- set thinking_text = message.get('reasoning') or message.get('reasoning_content') -%}
239
- {%- set thinking_gate = (loop.index0 > ns_turn.last_user_idx) or (preserve_thinking and message.get('tool_calls')) -%}
240
- {%- if thinking_text and thinking_gate -%}
241
  {{- '<|channel>thought\n' + thinking_text + '\n<channel|>' -}}
242
  {%- endif -%}
243
 
244
- {%- if message.get('tool_calls') -%}
245
- {%- for tool_call in message.get('tool_calls') -%}
246
  {%- set function = tool_call['function'] -%}
247
  {{- '<|tool_call>call:' + function['name'] + '{' -}}
248
  {%- if function['arguments'] is mapping -%}
@@ -252,13 +249,8 @@
252
  {%- set ns_args.found_first = true -%}
253
  {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
254
  {%- endfor -%}
255
- {%- elif function['arguments'] is none -%}
256
- {%- else -%}
257
- {{- raise_exception(
258
- "chat_template: tool_calls[].function.arguments must be a "
259
- "JSON object (mapping), not a string. Deserialize arguments "
260
- "before passing to the template."
261
- ) -}}
262
  {%- endif -%}
263
  {{- '}<tool_call|>' -}}
264
  {%- endfor -%}
@@ -268,8 +260,8 @@
268
  {%- set ns_tr_out = namespace(flag=false) -%}
269
  {%- if message.get('tool_responses') -%}
270
  {#- Legacy: tool_responses embedded on the assistant message (Google/Gemma native) -#}
271
- {%- for tool_response in message.get('tool_responses') -%}
272
- {{- format_tool_response_block(tool_response['name'] | default('unknown', true), tool_response['response']) -}}
273
  {%- set ns_tr_out.flag = true -%}
274
  {%- set ns.prev_message_type = 'tool_response' -%}
275
  {%- endfor -%}
@@ -283,8 +275,8 @@
283
  {%- else -%}
284
  {%- set follow = loop_messages[k] -%}
285
  {#- Resolve tool_call_id to function name -#}
286
- {%- set ns_tname = namespace(name=follow.get('name') or 'unknown') -%}
287
- {%- for tc in message.get('tool_calls') -%}
288
  {%- if tc.get('id') == follow.get('tool_call_id') -%}
289
  {%- set ns_tname.name = tc['function']['name'] -%}
290
  {%- endif -%}
@@ -301,15 +293,6 @@
301
  {%- endif -%}
302
  {%- endfor -%}
303
  {{- format_tool_response_block(ns_tname.name, ns_txt.s) -}}
304
- {%- for part in tool_body -%}
305
- {%- if part.get('type') in ['image', 'image_url'] -%}
306
- {{- '<|image|>' -}}
307
- {%- elif part.get('type') in ['audio', 'input_audio'] -%}
308
- {{- '<|audio|>' -}}
309
- {%- elif part.get('type') == 'video' -%}
310
- {{- '<|video|>' -}}
311
- {%- endif -%}
312
- {%- endfor -%}
313
  {%- else -%}
314
  {{- format_tool_response_block(ns_tname.name, tool_body) -}}
315
  {%- endif -%}
@@ -319,68 +302,43 @@
319
  {%- endfor -%}
320
  {%- endif -%}
321
 
322
- {%- set captured_content -%}
323
- {%- if message.get('content') is string -%}
324
  {%- if role == 'model' -%}
325
  {{- strip_thinking(message['content']) -}}
326
  {%- else -%}
327
  {{- message['content'] | trim -}}
328
  {%- endif -%}
329
- {%- elif message.get('content') is sequence -%}
330
  {%- for item in message['content'] -%}
331
- {%- if item.get('type') == 'text' -%}
332
  {%- if role == 'model' -%}
333
  {{- strip_thinking(item['text']) -}}
334
  {%- else -%}
335
  {{- item['text'] | trim -}}
336
  {%- endif -%}
337
- {%- elif item.get('type') in ['image', 'image_url'] -%}
338
  {{- '<|image|>' -}}
339
- {%- elif item.get('type') in ['audio', 'input_audio'] -%}
 
340
  {{- '<|audio|>' -}}
341
- {%- elif item.get('type') == 'video' -%}
 
342
  {{- '<|video|>' -}}
 
343
  {%- endif -%}
344
  {%- endfor -%}
345
  {%- endif -%}
346
- {%- endset -%}
347
-
348
- {{- captured_content -}}
349
- {%- set has_content = captured_content | trim | length > 0 -%}
350
-
351
- {#- Forward-scan: find next non-tool message role for continuation detection -#}
352
- {%- set next_nt = namespace(role=None, found=false) -%}
353
- {%- for j in range(loop.index0 + 1, loop_messages | length) -%}
354
- {%- if not next_nt.found -%}
355
- {%- if loop_messages[j]['role'] != 'tool' -%}
356
- {%- set next_nt.role = loop_messages[j]['role'] -%}
357
- {%- set next_nt.found = true -%}
358
- {%- endif -%}
359
- {%- endif -%}
360
- {%- endfor -%}
361
-
362
- {%- set continues_into_next = (
363
- role == 'model'
364
- and next_nt.role == 'assistant'
365
- and (not message.get('tool_calls') or ns_tr_out.flag)
366
- ) -%}
367
 
368
  {%- if ns.prev_message_type == 'tool_call' and not ns_tr_out.flag -%}
369
  {{- '<|tool_response>' -}}
370
- {%- elif continues_into_next -%}
371
- {%- elif not (ns_tr_out.flag and not has_content and not next_nt.found) -%}
372
  {{- '<turn|>\n' -}}
373
  {%- endif -%}
374
-
375
- {#- Track previous non-tool role for next iteration (avoids O(n) backward scan) -#}
376
- {%- set ns.prev_non_tool_role = message['role'] -%}
377
  {%- endif -%}
378
  {%- endfor -%}
379
 
380
  {%- if add_generation_prompt -%}
381
  {%- if ns.prev_message_type != 'tool_response' and ns.prev_message_type != 'tool_call' -%}
382
  {{- '<|turn>model\n' -}}
383
- {%- elif ns.prev_message_type == 'tool_response' and enable_thinking -%}
384
- {{- '<|channel>thought\n' -}}
385
  {%- endif -%}
386
- {%- endif -%}
 
1
+ {%- macro format_parameters(properties, required) -%}
 
 
 
 
 
 
2
  {%- set standard_keys = ['description', 'type', 'properties', 'required', 'nullable'] -%}
3
  {%- set ns = namespace(found_first=false) -%}
4
  {%- for key, value in properties | dictsort -%}
5
  {%- set add_comma = false -%}
6
+ {%- if key not in standard_keys -%}
7
  {%- if ns.found_first %},{% endif -%}
8
  {%- set ns.found_first = true -%}
9
  {{ key }}:{
 
65
  {%- elif value is mapping -%}
66
  {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
67
  properties:{
68
+ {{- format_parameters(value, value['required'] | default([])) -}}
69
  }
70
  {%- endif -%}
71
  {%- if value['required'] -%}
 
116
  }
117
  {%- endmacro -%}
118
  {%- macro format_argument(argument, escape_keys=True) -%}
119
+ {%- if argument is string -%}
 
 
120
  {{- '<|"|>' + argument + '<|"|>' -}}
121
  {%- elif argument is boolean -%}
122
  {{- 'true' if argument else 'false' -}}
 
172
  {{- '<tool_response|>' -}}
173
  {%- endmacro -%}
174
 
175
+ {%- set ns = namespace(prev_message_type=None) -%}
 
176
  {%- set loop_messages = messages -%}
 
 
177
  {{- bos_token -}}
178
  {#- Handle System/Tool Definitions Block -#}
179
+ {%- if (enable_thinking is defined and enable_thinking) or tools or messages[0]['role'] in ['system', 'developer'] -%}
180
  {{- '<|turn>system\n' -}}
181
+
182
  {#- Inject Thinking token at the very top of the FIRST system turn -#}
183
+ {%- if enable_thinking is defined and enable_thinking -%}
184
  {{- '<|think|>\n' -}}
185
  {%- set ns.prev_message_type = 'think' -%}
186
  {%- endif -%}
187
+
188
+ {%- if messages[0]['role'] in ['system', 'developer'] -%}
189
+ {{- messages[0]['content'] | trim -}}
 
 
 
 
 
190
  {%- set loop_messages = messages[1:] -%}
191
  {%- endif -%}
192
+
193
  {%- if tools -%}
194
  {%- for tool in tools %}
195
  {{- '<|tool>' -}}
 
198
  {%- endfor %}
199
  {%- set ns.prev_message_type = 'tool' -%}
200
  {%- endif -%}
201
+
202
  {{- '<turn|>\n' -}}
203
  {%- endif %}
204
 
 
215
  {%- if message['role'] != 'tool' -%}
216
  {%- set ns.prev_message_type = None -%}
217
  {%- set role = 'model' if message['role'] == 'assistant' else message['role'] -%}
218
+ {#- Detect continuation: suppress duplicate <|turn>model when previous non-tool message was also assistant -#}
219
+ {%- set prev_nt = namespace(role=None, found=false) -%}
220
+ {%- if loop.index0 > 0 -%}
221
+ {%- for j in range(loop.index0 - 1, -1, -1) -%}
222
+ {%- if not prev_nt.found -%}
223
+ {%- if loop_messages[j]['role'] != 'tool' -%}
224
+ {%- set prev_nt.role = loop_messages[j]['role'] -%}
225
+ {%- set prev_nt.found = true -%}
226
+ {%- endif -%}
227
+ {%- endif -%}
228
+ {%- endfor -%}
229
+ {%- endif -%}
230
+ {%- set continue_same_model_turn = (role == 'model' and prev_nt.role == 'assistant') -%}
231
  {%- if not continue_same_model_turn -%}
232
  {{- '<|turn>' + role + '\n' }}
233
  {%- endif -%}
234
 
235
  {#- Render reasoning/reasoning_content as thinking channel -#}
236
  {%- set thinking_text = message.get('reasoning') or message.get('reasoning_content') -%}
237
+ {%- if thinking_text and loop.index0 > ns_turn.last_user_idx and message.get('tool_calls') -%}
 
238
  {{- '<|channel>thought\n' + thinking_text + '\n<channel|>' -}}
239
  {%- endif -%}
240
 
241
+ {%- if message['tool_calls'] -%}
242
+ {%- for tool_call in message['tool_calls'] -%}
243
  {%- set function = tool_call['function'] -%}
244
  {{- '<|tool_call>call:' + function['name'] + '{' -}}
245
  {%- if function['arguments'] is mapping -%}
 
249
  {%- set ns_args.found_first = true -%}
250
  {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
251
  {%- endfor -%}
252
+ {%- elif function['arguments'] is string -%}
253
+ {{- function['arguments'] -}}
 
 
 
 
 
254
  {%- endif -%}
255
  {{- '}<tool_call|>' -}}
256
  {%- endfor -%}
 
260
  {%- set ns_tr_out = namespace(flag=false) -%}
261
  {%- if message.get('tool_responses') -%}
262
  {#- Legacy: tool_responses embedded on the assistant message (Google/Gemma native) -#}
263
+ {%- for tool_response in message['tool_responses'] -%}
264
+ {{- format_tool_response_block(tool_response['name'] | default('unknown'), tool_response['response']) -}}
265
  {%- set ns_tr_out.flag = true -%}
266
  {%- set ns.prev_message_type = 'tool_response' -%}
267
  {%- endfor -%}
 
275
  {%- else -%}
276
  {%- set follow = loop_messages[k] -%}
277
  {#- Resolve tool_call_id to function name -#}
278
+ {%- set ns_tname = namespace(name=follow.get('name') | default('unknown')) -%}
279
+ {%- for tc in message['tool_calls'] -%}
280
  {%- if tc.get('id') == follow.get('tool_call_id') -%}
281
  {%- set ns_tname.name = tc['function']['name'] -%}
282
  {%- endif -%}
 
293
  {%- endif -%}
294
  {%- endfor -%}
295
  {{- format_tool_response_block(ns_tname.name, ns_txt.s) -}}
 
 
 
 
 
 
 
 
 
296
  {%- else -%}
297
  {{- format_tool_response_block(ns_tname.name, tool_body) -}}
298
  {%- endif -%}
 
302
  {%- endfor -%}
303
  {%- endif -%}
304
 
305
+ {%- if message['content'] is string -%}
 
306
  {%- if role == 'model' -%}
307
  {{- strip_thinking(message['content']) -}}
308
  {%- else -%}
309
  {{- message['content'] | trim -}}
310
  {%- endif -%}
311
+ {%- elif message['content'] is sequence -%}
312
  {%- for item in message['content'] -%}
313
+ {%- if item['type'] == 'text' -%}
314
  {%- if role == 'model' -%}
315
  {{- strip_thinking(item['text']) -}}
316
  {%- else -%}
317
  {{- item['text'] | trim -}}
318
  {%- endif -%}
319
+ {%- elif item['type'] == 'image' -%}
320
  {{- '<|image|>' -}}
321
+ {%- set ns.prev_message_type = 'image' -%}
322
+ {%- elif item['type'] == 'audio' -%}
323
  {{- '<|audio|>' -}}
324
+ {%- set ns.prev_message_type = 'audio' -%}
325
+ {%- elif item['type'] == 'video' -%}
326
  {{- '<|video|>' -}}
327
+ {%- set ns.prev_message_type = 'video' -%}
328
  {%- endif -%}
329
  {%- endfor -%}
330
  {%- endif -%}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
 
332
  {%- if ns.prev_message_type == 'tool_call' and not ns_tr_out.flag -%}
333
  {{- '<|tool_response>' -}}
334
+ {%- elif not (ns_tr_out.flag and not message.get('content')) -%}
 
335
  {{- '<turn|>\n' -}}
336
  {%- endif -%}
 
 
 
337
  {%- endif -%}
338
  {%- endfor -%}
339
 
340
  {%- if add_generation_prompt -%}
341
  {%- if ns.prev_message_type != 'tool_response' and ns.prev_message_type != 'tool_call' -%}
342
  {{- '<|turn>model\n' -}}
 
 
343
  {%- endif -%}
344
+ {%- endif -%}
tokenizer_config.json CHANGED
@@ -63,52 +63,6 @@
63
  },
64
  "x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?P<content>(?:(?!\\<turn\\|\\>)(?!\\<\\|tool_response\\>).)+)?(?:\\<turn\\|\\>|\\<\\|tool_response\\>)?"
65
  },
66
- "response_template": {
67
- "defaults": {
68
- "role": "assistant"
69
- },
70
- "fields": {
71
- "content": {
72
- "close": [
73
- "<turn|>",
74
- "<|tool_response>",
75
- "<eos>"
76
- ],
77
- "content": "text"
78
- },
79
- "thinking": {
80
- "close": "<channel|>",
81
- "content": "text",
82
- "open": "<|channel>thought\n"
83
- },
84
- "tool_calls": {
85
- "close": "<tool_call|>",
86
- "content": "json",
87
- "content_args": {
88
- "string_delims": [
89
- [
90
- "<|\"|>",
91
- "<|\"|>"
92
- ]
93
- ],
94
- "unquoted_keys": true
95
- },
96
- "open_pattern": "<\\|tool_call>call:(?P<name>\\w+)",
97
- "repeats": true,
98
- "transform": {
99
- "function": {
100
- "arguments": "{content}",
101
- "name": "{name}"
102
- },
103
- "type": "function"
104
- }
105
- }
106
- },
107
- "start_anchor": [
108
- "<|turn>model\n",
109
- "<tool_response|>"
110
- ]
111
- },
112
  "soc_token": "<|channel>",
113
  "sot_token": "<|turn>",
114
  "stc_token": "<|tool_call>",
 
63
  },
64
  "x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?P<content>(?:(?!\\<turn\\|\\>)(?!\\<\\|tool_response\\>).)+)?(?:\\<turn\\|\\>|\\<\\|tool_response\\>)?"
65
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  "soc_token": "<|channel>",
67
  "sot_token": "<|turn>",
68
  "stc_token": "<|tool_call>",