Image-Text-to-Text
MLX
Safetensors
English
gemma4
aerial-vlm
drone
vision-language-model
visual-grounding
apple-silicon
int4
edge-ai
structured-output
miril
conversational
4-bit precision
Instructions to use MirilAI/Miril-DroneVLM-2B-2-MLX-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use MirilAI/Miril-DroneVLM-2B-2-MLX-4bit with MLX:
# Make sure mlx-vlm is installed # pip install --upgrade mlx-vlm from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config # Load the model model, processor = load("MirilAI/Miril-DroneVLM-2B-2-MLX-4bit") config = load_config("MirilAI/Miril-DroneVLM-2B-2-MLX-4bit") # Prepare input image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] prompt = "Describe this image." # Apply chat template formatted_prompt = apply_chat_template( processor, config, prompt, num_images=1 ) # Generate output output = generate(model, processor, formatted_prompt, image) print(output) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use MirilAI/Miril-DroneVLM-2B-2-MLX-4bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "MirilAI/Miril-DroneVLM-2B-2-MLX-4bit"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "MirilAI/Miril-DroneVLM-2B-2-MLX-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent
How to use MirilAI/Miril-DroneVLM-2B-2-MLX-4bit with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "MirilAI/Miril-DroneVLM-2B-2-MLX-4bit"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default MirilAI/Miril-DroneVLM-2B-2-MLX-4bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use MirilAI/Miril-DroneVLM-2B-2-MLX-4bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "MirilAI/Miril-DroneVLM-2B-2-MLX-4bit"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "MirilAI/Miril-DroneVLM-2B-2-MLX-4bit" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Stage Miril-DroneVLM-2B-2 release
Browse files- .gitattributes +1 -0
- LICENSE +201 -0
- NOTICE +15 -0
- README.md +202 -0
- assets/cleaned_test_comparison.svg +168 -0
- assets/deployment_comparison.svg +168 -0
- assets/full_validation_comparison.svg +168 -0
- chat_template.jinja +386 -0
- config.json +220 -0
- generation_config.json +14 -0
- model.safetensors +3 -0
- model.safetensors.index.json +0 -0
- processor_config.json +64 -0
- shared_kv_export_report.json +458 -0
- tokenizer.json +3 -0
- tokenizer_config.json +142 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright [yyyy] [name of copyright owner]
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
NOTICE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Miril-DroneVLM-2B-2-MLX-4bit
|
| 2 |
+
Copyright 2026 Miril
|
| 3 |
+
|
| 4 |
+
Miril-DroneVLM-2B-2-MLX-4bit is a quantized aerial vision-language model derived from
|
| 5 |
+
google/gemma-4-E2B-it by Google DeepMind.
|
| 6 |
+
|
| 7 |
+
The base model google/gemma-4-E2B-it is published by Google DeepMind
|
| 8 |
+
under the Apache License, Version 2.0.
|
| 9 |
+
|
| 10 |
+
Miril modifications adapt the base model for aerial scene understanding,
|
| 11 |
+
drone visual question answering, and structured image-relative coordinate
|
| 12 |
+
outputs.
|
| 13 |
+
|
| 14 |
+
This distribution is not endorsed by or affiliated with Google,
|
| 15 |
+
Google DeepMind, or the Gemma authors.
|
README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: MirilAI/Miril-DroneVLM-2B-2
|
| 4 |
+
library_name: mlx
|
| 5 |
+
pipeline_tag: image-text-to-text
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
+
tags:
|
| 9 |
+
- aerial-vlm
|
| 10 |
+
- drone
|
| 11 |
+
- vision-language-model
|
| 12 |
+
- visual-grounding
|
| 13 |
+
- mlx
|
| 14 |
+
- apple-silicon
|
| 15 |
+
- int4
|
| 16 |
+
- edge-ai
|
| 17 |
+
- structured-output
|
| 18 |
+
- miril
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
# Miril-DroneVLM-2B-2-MLX-4bit
|
| 22 |
+
|
| 23 |
+
### The compact Apple Silicon edition of Miril-DroneVLM-2B-2
|
| 24 |
+
|
| 25 |
+
**Drones can talk.**
|
| 26 |
+
|
| 27 |
+
This repository contains the 4-bit MLX-VLM deployment variant of [Miril-DroneVLM-2B-2](https://huggingface.co/MirilAI/Miril-DroneVLM-2B-2), Miril.ai's open-weight aerial VLM. Give it an overhead image and an ordinary question such as “What am I looking at?”, “Any people?”, “Choose a place for this parcel,” or “Track the white car.” It returns typed JSON that identifies how the answer should be interpreted.
|
| 28 |
+
|
| 29 |
+
This is the same four-route model interface as the merged checkpoint, converted for compact Apple Silicon experiments. See the primary model card for the `caption`, `answer`, `location`, and `pointing` responses, fixed system contract, precise-point and coarse-direction rules, runnable validation code, WALDO lineage, limitations, and safety requirements.
|
| 30 |
+
|
| 31 |
+
Methods and citation: [Miril-DroneVLM-2B-2: Compiling Detector Annotations into a Typed Aerial VLM](https://huggingface.co/MirilAI/Miril-DroneVLM-2B-2/blob/main/technical_report.pdf).
|
| 32 |
+
|
| 33 |
+
## Deployment Profile
|
| 34 |
+
|
| 35 |
+
<!-- MIRIL_VARIANT_PROFILE_START -->
|
| 36 |
+
- Artifact size: **3.34 GiB**
|
| 37 |
+
- Recommended starting envelope: **6.0 GiB free unified memory**
|
| 38 |
+
- Estimate covers model weights plus practical single-image runtime headroom; larger images, batching, long generations, and server overhead need more.
|
| 39 |
+
<!-- MIRIL_VARIANT_PROFILE_END -->
|
| 40 |
+
|
| 41 |
+
Use this variant for compact local experiments on Apple Silicon. The deployment
|
| 42 |
+
profile reports measured artifact size, a recommended unified-memory envelope,
|
| 43 |
+
and full same-case quality deltas against the merged model.
|
| 44 |
+
|
| 45 |
+
## Known 4-bit Contract Degradation
|
| 46 |
+
|
| 47 |
+
This artifact is published because it is compact and still produces useful aerial descriptions, answers, spatial statuses, and coordinates. It is **not contract-equivalent** to the merged or MLX 8-bit checkpoint.
|
| 48 |
+
|
| 49 |
+
On the complete balanced independent route benchmark:
|
| 50 |
+
|
| 51 |
+
| Metric | Merged BF16 | CUDA bnb4 | MLX 8-bit | MLX 4-bit |
|
| 52 |
+
| --- | ---: | ---: | ---: | ---: |
|
| 53 |
+
| Valid JSON | 100.0% | 96.7% | 100.0% | 100.0% |
|
| 54 |
+
| Correct response type | 96.1% | 92.6% | 94.6% | 98.4% |
|
| 55 |
+
| Exact schema | 96.1% | 92.1% | 94.6% | **55.8%** |
|
| 56 |
+
| Exact route | 94.8% | 91.2% | 93.4% | **56.9%** |
|
| 57 |
+
|
| 58 |
+
The failure is narrow but important. In 96.6% of pointing cases, the MLX 4-bit model emitted the location key `intent` where the pointing schema requires `action`. It often preserved the requested value (`locate`, `point`, or `track`), the caption, status, and coordinates, but a strict parser must reject the object because the envelope is wrong. Only 0.1% of pointing responses emitted a strictly route-correct `action` field in this benchmark.
|
| 59 |
+
|
| 60 |
+
Do not silently treat `intent` as `action` in a flight or safety workflow. Use the bundled strict validator, reject malformed envelopes, and prefer the MLX 8-bit or merged model when deterministic route conformance matters.
|
| 61 |
+
|
| 62 |
+
Our current explanation is a measured hypothesis, not a proven causal result. The uniform affine 4-bit MLX conversion quantizes token embeddings as well as linear layers; the evaluated artifact contains quantized `embed_tokens` weights. [MLX documents that its default quantizer covers both `Linear` and `Embedding`](https://ml-explore.github.io/mlx/build/html/python/_autosummary/mlx.nn.quantize.html). The current MLX-VLM [`mixed_4_8` recipe](https://github.com/Blaizzy/mlx-vlm/blob/main/mlx_vlm/convert.py) keeps token embeddings, the language-model head, and selected projections at 8-bit. The fact that MLX 8-bit and CUDA 4-bit do not show the same collapse makes those sensitive layers the leading explanation, but it does not isolate one layer or rule out runtime-specific effects.
|
| 63 |
+
|
| 64 |
+
Generation three will test `mixed_4_8` against the same cases, add layer-sensitivity ablations, and require action-key, route, and schema recovery before a mixed-bit artifact is called contract-preserving.
|
| 65 |
+
|
| 66 |
+
## Run It
|
| 67 |
+
|
| 68 |
+
```bash
|
| 69 |
+
python -m pip install mlx-vlm huggingface_hub pillow
|
| 70 |
+
hf download MirilAI/Miril-DroneVLM-2B-2 mlx_inference.py inference.py router_contract.py --local-dir miril-drone-runtime
|
| 71 |
+
python miril-drone-runtime/mlx_inference.py \
|
| 72 |
+
--model-id MirilAI/Miril-DroneVLM-2B-2-MLX-4bit \
|
| 73 |
+
--image drone_frame.jpg \
|
| 74 |
+
--prompt "Where is the white car?"
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
The helper applies the same fixed system prompt and strict response validator as the CUDA path. Invalid or contradictory coordinates are never returned as dispatch-safe points.
|
| 78 |
+
|
| 79 |
+
## Export Integrity
|
| 80 |
+
|
| 81 |
+
Gemma 4 E2B uses shared key/value layers. The included
|
| 82 |
+
[shared-KV export audit](./shared_kv_export_report.json) verifies the expected
|
| 83 |
+
tensor-owner layout for this exact MLX artifact; the absence of separate
|
| 84 |
+
`k_proj`, `v_proj`, and `k_norm` tensors on sharing layers is intentional.
|
| 85 |
+
|
| 86 |
+
## Complete Benchmark
|
| 87 |
+
|
| 88 |
+
<!-- MIRIL_RELEASE_METRICS_START -->
|
| 89 |
+

|
| 90 |
+
|
| 91 |
+
| Metric | Merged BF16 | MLX 4-bit |
|
| 92 |
+
|---|---:|---:|
|
| 93 |
+
| Valid JSON | 100.0% | 100.0% |
|
| 94 |
+
| Schema valid | 96.1% | 55.8% |
|
| 95 |
+
| Route accuracy | 94.8% | 56.9% |
|
| 96 |
+
| Caption / answer F1 | 38.2% | 35.1% |
|
| 97 |
+
| Spatial status | 79.2% | 77.3% |
|
| 98 |
+
| Precise target retained | 50.2% | 46.9% |
|
| 99 |
+
| Point within 100 | 33.4% | 25.1% |
|
| 100 |
+
| Coarse direction exact | 35.0% | 27.6% |
|
| 101 |
+
| No-target discipline | 93.4% | 91.6% |
|
| 102 |
+
|
| 103 |
+
### Complete held-out validation
|
| 104 |
+
|
| 105 |
+

|
| 106 |
+
|
| 107 |
+
| Metric | Merged BF16 | MLX 4-bit |
|
| 108 |
+
|---|---:|---:|
|
| 109 |
+
| Valid JSON | 99.9% | 100.0% |
|
| 110 |
+
| Schema valid | 99.9% | 53.0% |
|
| 111 |
+
| Route accuracy | 99.9% | 53.2% |
|
| 112 |
+
| Caption / answer F1 | 38.6% | 35.6% |
|
| 113 |
+
| Spatial status | 86.1% | 82.8% |
|
| 114 |
+
| Precise target retained | 71.7% | 68.8% |
|
| 115 |
+
| Point within 100 | 38.3% | 27.8% |
|
| 116 |
+
| Coarse direction exact | 34.4% | 25.8% |
|
| 117 |
+
| No-target discipline | 96.3% | 95.5% |
|
| 118 |
+
|
| 119 |
+
### Cleaned held-out deployment audit
|
| 120 |
+
|
| 121 |
+

|
| 122 |
+
|
| 123 |
+
After training, a stricter held-out audit removed pointing rows whose targets fall below the model-visible size threshold, then ran every release artifact on the complete revised validation and test splits. Strict-cleaned rows use only accepted evidence. Coverage-matched rows add evidence-preserving questions on the same held-out images to restore the earlier route and pointing action/status mix; they do not recreate the earlier object-class histogram.
|
| 124 |
+
|
| 125 |
+
#### Final held-out test
|
| 126 |
+
|
| 127 |
+
##### Strict-cleaned evidence
|
| 128 |
+
|
| 129 |
+
| Metric | Merged BF16 - Strict cleaned test | MLX 4-bit - Strict cleaned test |
|
| 130 |
+
|---|---:|---:|
|
| 131 |
+
| Valid JSON | 99.8% | 100.0% |
|
| 132 |
+
| Schema valid | 99.8% | 62.8% |
|
| 133 |
+
| Route accuracy | 99.8% | 63.3% |
|
| 134 |
+
| Reference text F1 | 60.9% | 57.2% |
|
| 135 |
+
| Spatial status | 88.0% | 83.8% |
|
| 136 |
+
| Coordinate quality | 89.7% | 86.1% |
|
| 137 |
+
| Precise target retained | 65.2% | 61.3% |
|
| 138 |
+
| Point within 100 | 42.6% | 31.4% |
|
| 139 |
+
| No-target discipline | 96.5% | 93.4% |
|
| 140 |
+
|
| 141 |
+
##### Coverage-matched evidence
|
| 142 |
+
|
| 143 |
+
| Metric | Merged BF16 - Coverage-matched test | MLX 4-bit - Coverage-matched test |
|
| 144 |
+
|---|---:|---:|
|
| 145 |
+
| Valid JSON | 99.9% | 100.0% |
|
| 146 |
+
| Schema valid | 99.9% | 50.2% |
|
| 147 |
+
| Route accuracy | 99.9% | 50.5% |
|
| 148 |
+
| Reference text F1 | 64.3% | 60.6% |
|
| 149 |
+
| Spatial status | 84.2% | 79.0% |
|
| 150 |
+
| Coordinate quality | 84.9% | 80.9% |
|
| 151 |
+
| Precise target retained | 63.5% | 59.7% |
|
| 152 |
+
| Point within 100 | 42.8% | 31.4% |
|
| 153 |
+
| No-target discipline | 96.4% | 93.1% |
|
| 154 |
+
|
| 155 |
+
#### Validation
|
| 156 |
+
|
| 157 |
+
##### Strict-cleaned evidence
|
| 158 |
+
|
| 159 |
+
| Metric | Merged BF16 - Strict cleaned validation | MLX 4-bit - Strict cleaned validation |
|
| 160 |
+
|---|---:|---:|
|
| 161 |
+
| Valid JSON | 99.9% | 100.0% |
|
| 162 |
+
| Schema valid | 99.9% | 64.3% |
|
| 163 |
+
| Route accuracy | 99.9% | 64.6% |
|
| 164 |
+
| Reference text F1 | 59.9% | 56.7% |
|
| 165 |
+
| Spatial status | 89.6% | 86.3% |
|
| 166 |
+
| Coordinate quality | 89.8% | 87.4% |
|
| 167 |
+
| Precise target retained | 65.8% | 62.9% |
|
| 168 |
+
| Point within 100 | 39.3% | 28.6% |
|
| 169 |
+
| No-target discipline | 96.7% | 95.2% |
|
| 170 |
+
|
| 171 |
+
##### Coverage-matched evidence
|
| 172 |
+
|
| 173 |
+
| Metric | Merged BF16 - Coverage-matched validation | MLX 4-bit - Coverage-matched validation |
|
| 174 |
+
|---|---:|---:|
|
| 175 |
+
| Valid JSON | 99.9% | 100.0% |
|
| 176 |
+
| Schema valid | 99.9% | 53.0% |
|
| 177 |
+
| Route accuracy | 99.9% | 53.2% |
|
| 178 |
+
| Reference text F1 | 62.6% | 59.5% |
|
| 179 |
+
| Spatial status | 84.5% | 80.7% |
|
| 180 |
+
| Coordinate quality | 84.5% | 81.7% |
|
| 181 |
+
| Precise target retained | 60.5% | 58.8% |
|
| 182 |
+
| Point within 100 | 38.4% | 28.0% |
|
| 183 |
+
| No-target discipline | 96.1% | 94.1% |
|
| 184 |
+
|
| 185 |
+
Validation supports comparison and model selection; test is the final held-out report. These automated scores measure contract and reference agreement, not flight safety.
|
| 186 |
+
|
| 187 |
+
Spoken-query results on the primary model card apply to the merged BF16 checkpoint. This deployment variant has not inherited that claim without a separate matched audio evaluation.
|
| 188 |
+
|
| 189 |
+
The merged and deployment variants use identical cases within each evaluation. Automated scores are regression signals, not safety certification.
|
| 190 |
+
<!-- MIRIL_RELEASE_METRICS_END -->
|
| 191 |
+
|
| 192 |
+
The tables below compare MLX and CUDA artifacts on identical complete held-out
|
| 193 |
+
validation and test cases. Partial runs are excluded. Automated scores are
|
| 194 |
+
regression signals, not safety certification.
|
| 195 |
+
|
| 196 |
+
## Limits And Safety
|
| 197 |
+
|
| 198 |
+
This is a research perception model, not a flight controller or certified safety system. Follow the complete limitations and operational guidance on the [primary model card](https://huggingface.co/MirilAI/Miril-DroneVLM-2B-2).
|
| 199 |
+
|
| 200 |
+
## License
|
| 201 |
+
|
| 202 |
+
Apache License 2.0. See `LICENSE` and `NOTICE`.
|
assets/cleaned_test_comparison.svg
ADDED
|
|
assets/deployment_comparison.svg
ADDED
|
|
assets/full_validation_comparison.svg
ADDED
|
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,386 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 }}:{
|
| 16 |
+
{%- if value['description'] -%}
|
| 17 |
+
description:<|"|>{{ value['description'] }}<|"|>
|
| 18 |
+
{%- set add_comma = true -%}
|
| 19 |
+
{%- endif -%}
|
| 20 |
+
{%- if value['type'] | upper == 'STRING' -%}
|
| 21 |
+
{%- if value['enum'] -%}
|
| 22 |
+
{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
|
| 23 |
+
enum:{{ format_argument(value['enum']) }}
|
| 24 |
+
{%- endif -%}
|
| 25 |
+
{%- elif value['type'] | upper == 'ARRAY' -%}
|
| 26 |
+
{%- if value['items'] is mapping and value['items'] -%}
|
| 27 |
+
{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
|
| 28 |
+
items:{
|
| 29 |
+
{%- set ns_items = namespace(found_first=false) -%}
|
| 30 |
+
{%- for item_key, item_value in value['items'] | dictsort -%}
|
| 31 |
+
{%- if item_value is not none -%}
|
| 32 |
+
{%- if ns_items.found_first %},{% endif -%}
|
| 33 |
+
{%- set ns_items.found_first = true -%}
|
| 34 |
+
{%- if item_key == 'properties' -%}
|
| 35 |
+
properties:{
|
| 36 |
+
{%- if item_value is mapping -%}
|
| 37 |
+
{{- format_parameters(item_value, value['items']['required'] | default([])) -}}
|
| 38 |
+
{%- endif -%}
|
| 39 |
+
}
|
| 40 |
+
{%- elif item_key == 'required' -%}
|
| 41 |
+
required:[
|
| 42 |
+
{%- for req_item in item_value -%}
|
| 43 |
+
<|"|>{{- req_item -}}<|"|>
|
| 44 |
+
{%- if not loop.last %},{% endif -%}
|
| 45 |
+
{%- endfor -%}
|
| 46 |
+
]
|
| 47 |
+
{%- elif item_key == 'type' -%}
|
| 48 |
+
{%- if item_value is string -%}
|
| 49 |
+
type:{{ format_argument(item_value | upper) }}
|
| 50 |
+
{%- else -%}
|
| 51 |
+
type:{{ format_argument(item_value | map('upper') | list) }}
|
| 52 |
+
{%- endif -%}
|
| 53 |
+
{%- else -%}
|
| 54 |
+
{{ item_key }}:{{ format_argument(item_value) }}
|
| 55 |
+
{%- endif -%}
|
| 56 |
+
{%- endif -%}
|
| 57 |
+
{%- endfor -%}
|
| 58 |
+
}
|
| 59 |
+
{%- endif -%}
|
| 60 |
+
{%- endif -%}
|
| 61 |
+
{%- if value['nullable'] %}
|
| 62 |
+
{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
|
| 63 |
+
nullable:true
|
| 64 |
+
{%- endif -%}
|
| 65 |
+
{%- if value['type'] | upper == 'OBJECT' -%}
|
| 66 |
+
{%- if value['properties'] is defined and value['properties'] is mapping -%}
|
| 67 |
+
{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
|
| 68 |
+
properties:{
|
| 69 |
+
{{- format_parameters(value['properties'], value['required'] | default([])) -}}
|
| 70 |
+
}
|
| 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'] -%}
|
| 78 |
+
{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
|
| 79 |
+
required:[
|
| 80 |
+
{%- for item in value['required'] | default([]) -%}
|
| 81 |
+
<|"|>{{- item -}}<|"|>
|
| 82 |
+
{%- if not loop.last %},{% endif -%}
|
| 83 |
+
{%- endfor -%}
|
| 84 |
+
]
|
| 85 |
+
{%- endif -%}
|
| 86 |
+
{%- endif -%}
|
| 87 |
+
{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
|
| 88 |
+
type:<|"|>{{ value['type'] | upper }}<|"|>}
|
| 89 |
+
{%- endif -%}
|
| 90 |
+
{%- endfor -%}
|
| 91 |
+
{%- endmacro -%}
|
| 92 |
+
{%- macro format_function_declaration(tool_data) -%}
|
| 93 |
+
declaration:{{- tool_data['function']['name'] -}}{description:<|"|>{{- tool_data['function']['description'] -}}<|"|>
|
| 94 |
+
{%- set params = tool_data['function']['parameters'] -%}
|
| 95 |
+
{%- if params -%}
|
| 96 |
+
,parameters:{
|
| 97 |
+
{%- if params['properties'] -%}
|
| 98 |
+
properties:{ {{- format_parameters(params['properties'], params['required']) -}} },
|
| 99 |
+
{%- endif -%}
|
| 100 |
+
{%- if params['required'] -%}
|
| 101 |
+
required:[
|
| 102 |
+
{%- for item in params['required'] -%}
|
| 103 |
+
<|"|>{{- item -}}<|"|>
|
| 104 |
+
{{- ',' if not loop.last -}}
|
| 105 |
+
{%- endfor -%}
|
| 106 |
+
],
|
| 107 |
+
{%- endif -%}
|
| 108 |
+
{%- if params['type'] -%}
|
| 109 |
+
type:<|"|>{{- params['type'] | upper -}}<|"|>}
|
| 110 |
+
{%- endif -%}
|
| 111 |
+
{%- endif -%}
|
| 112 |
+
{%- if 'response' in tool_data['function'] -%}
|
| 113 |
+
{%- set response_declaration = tool_data['function']['response'] -%}
|
| 114 |
+
,response:{
|
| 115 |
+
{%- if response_declaration['description'] -%}
|
| 116 |
+
description:<|"|>{{- response_declaration['description'] -}}<|"|>,
|
| 117 |
+
{%- endif -%}
|
| 118 |
+
{%- if response_declaration['type'] | upper == 'OBJECT' -%}
|
| 119 |
+
type:<|"|>{{- response_declaration['type'] | upper -}}<|"|>}
|
| 120 |
+
{%- endif -%}
|
| 121 |
+
{%- endif -%}
|
| 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' -}}
|
| 131 |
+
{%- elif argument is mapping -%}
|
| 132 |
+
{{- '{' -}}
|
| 133 |
+
{%- set ns = namespace(found_first=false) -%}
|
| 134 |
+
{%- for key, value in argument | dictsort -%}
|
| 135 |
+
{%- if ns.found_first %},{% endif -%}
|
| 136 |
+
{%- set ns.found_first = true -%}
|
| 137 |
+
{%- if escape_keys -%}
|
| 138 |
+
{{- '<|"|>' + key + '<|"|>' -}}
|
| 139 |
+
{%- else -%}
|
| 140 |
+
{{- key -}}
|
| 141 |
+
{%- endif -%}
|
| 142 |
+
:{{- format_argument(value, escape_keys=escape_keys) -}}
|
| 143 |
+
{%- endfor -%}
|
| 144 |
+
{{- '}' -}}
|
| 145 |
+
{%- elif argument is sequence -%}
|
| 146 |
+
{{- '[' -}}
|
| 147 |
+
{%- for item in argument -%}
|
| 148 |
+
{{- format_argument(item, escape_keys=escape_keys) -}}
|
| 149 |
+
{%- if not loop.last %},{% endif -%}
|
| 150 |
+
{%- endfor -%}
|
| 151 |
+
{{- ']' -}}
|
| 152 |
+
{%- else -%}
|
| 153 |
+
{{- argument -}}
|
| 154 |
+
{%- endif -%}
|
| 155 |
+
{%- endmacro -%}
|
| 156 |
+
{%- macro strip_thinking(text) -%}
|
| 157 |
+
{%- set ns = namespace(result='') -%}
|
| 158 |
+
{%- for part in text.split('<channel|>') -%}
|
| 159 |
+
{%- if '<|channel>' in part -%}
|
| 160 |
+
{%- set ns.result = ns.result + part.split('<|channel>')[0] -%}
|
| 161 |
+
{%- else -%}
|
| 162 |
+
{%- set ns.result = ns.result + part -%}
|
| 163 |
+
{%- endif -%}
|
| 164 |
+
{%- endfor -%}
|
| 165 |
+
{{- ns.result | trim -}}
|
| 166 |
+
{%- endmacro -%}
|
| 167 |
+
|
| 168 |
+
{%- macro format_tool_response_block(tool_name, response) -%}
|
| 169 |
+
{{- '<|tool_response>' -}}
|
| 170 |
+
{%- if response is mapping -%}
|
| 171 |
+
{{- 'response:' + tool_name + '{' -}}
|
| 172 |
+
{%- for key, value in response | dictsort -%}
|
| 173 |
+
{{- key -}}:{{- format_argument(value, escape_keys=False) -}}
|
| 174 |
+
{%- if not loop.last %},{% endif -%}
|
| 175 |
+
{%- endfor -%}
|
| 176 |
+
{{- '}' -}}
|
| 177 |
+
{%- else -%}
|
| 178 |
+
{{- 'response:' + tool_name + '{value:' + format_argument(response, escape_keys=False) + '}' -}}
|
| 179 |
+
{%- endif -%}
|
| 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>' -}}
|
| 210 |
+
{{- format_function_declaration(tool) | trim -}}
|
| 211 |
+
{{- '<tool|>' -}}
|
| 212 |
+
{%- endfor %}
|
| 213 |
+
{%- set ns.prev_message_type = 'tool' -%}
|
| 214 |
+
{%- endif -%}
|
| 215 |
+
{{- '<turn|>\n' -}}
|
| 216 |
+
{%- endif %}
|
| 217 |
+
|
| 218 |
+
{#- Pre-scan: find last user message index for reasoning guard -#}
|
| 219 |
+
{%- set ns_turn = namespace(last_user_idx=-1) -%}
|
| 220 |
+
{%- for i in range(loop_messages | length) -%}
|
| 221 |
+
{%- if loop_messages[i]['role'] == 'user' -%}
|
| 222 |
+
{%- set ns_turn.last_user_idx = i -%}
|
| 223 |
+
{%- endif -%}
|
| 224 |
+
{%- endfor -%}
|
| 225 |
+
|
| 226 |
+
{#- Loop through messages -#}
|
| 227 |
+
{%- for message in loop_messages -%}
|
| 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 -%}
|
| 249 |
+
{%- set ns_args = namespace(found_first=false) -%}
|
| 250 |
+
{%- for key, value in function['arguments'] | dictsort -%}
|
| 251 |
+
{%- if ns_args.found_first %},{% endif -%}
|
| 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 -%}
|
| 265 |
+
{%- set ns.prev_message_type = 'tool_call' -%}
|
| 266 |
+
{%- endif -%}
|
| 267 |
+
|
| 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 -%}
|
| 276 |
+
{%- elif message.get('tool_calls') -%}
|
| 277 |
+
{#- OpenAI Chat Completions: forward-scan consecutive role:tool messages -#}
|
| 278 |
+
{%- set ns_tool_scan = namespace(stopped=false) -%}
|
| 279 |
+
{%- for k in range(loop.index0 + 1, loop_messages | length) -%}
|
| 280 |
+
{%- if ns_tool_scan.stopped -%}
|
| 281 |
+
{%- elif loop_messages[k]['role'] != 'tool' -%}
|
| 282 |
+
{%- set ns_tool_scan.stopped = true -%}
|
| 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 -%}
|
| 291 |
+
{%- endfor -%}
|
| 292 |
+
{#- Handle content as string or content-parts array -#}
|
| 293 |
+
{%- set tool_body = follow.get('content') -%}
|
| 294 |
+
{%- if tool_body is string -%}
|
| 295 |
+
{{- format_tool_response_block(ns_tname.name, tool_body) -}}
|
| 296 |
+
{%- elif tool_body is sequence and tool_body is not string -%}
|
| 297 |
+
{%- set ns_txt = namespace(s='') -%}
|
| 298 |
+
{%- for part in tool_body -%}
|
| 299 |
+
{%- if part.get('type') == 'text' -%}
|
| 300 |
+
{%- set ns_txt.s = ns_txt.s + (part.get('text') | default('')) -%}
|
| 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 -%}
|
| 316 |
+
{%- set ns_tr_out.flag = true -%}
|
| 317 |
+
{%- set ns.prev_message_type = 'tool_response' -%}
|
| 318 |
+
{%- endif -%}
|
| 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 -%}
|
config.json
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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[
|
| 3 |
+
"Gemma4ForConditionalGeneration"
|
| 4 |
+
],
|
| 5 |
+
"audio_config": {
|
| 6 |
+
"_name_or_path": "",
|
| 7 |
+
"architectures": null,
|
| 8 |
+
"attention_chunk_size": 12,
|
| 9 |
+
"attention_context_left": 13,
|
| 10 |
+
"attention_context_right": 0,
|
| 11 |
+
"attention_invalid_logits_value": -1000000000.0,
|
| 12 |
+
"attention_logit_cap": 50.0,
|
| 13 |
+
"chunk_size_feed_forward": 0,
|
| 14 |
+
"conv_kernel_size": 5,
|
| 15 |
+
"dtype": "bfloat16",
|
| 16 |
+
"gradient_clipping": 10000000000.0,
|
| 17 |
+
"hidden_act": "silu",
|
| 18 |
+
"hidden_size": 1024,
|
| 19 |
+
"id2label": {
|
| 20 |
+
"0": "LABEL_0",
|
| 21 |
+
"1": "LABEL_1"
|
| 22 |
+
},
|
| 23 |
+
"initializer_range": 0.02,
|
| 24 |
+
"is_encoder_decoder": false,
|
| 25 |
+
"label2id": {
|
| 26 |
+
"LABEL_0": 0,
|
| 27 |
+
"LABEL_1": 1
|
| 28 |
+
},
|
| 29 |
+
"model_type": "gemma4_audio",
|
| 30 |
+
"num_attention_heads": 8,
|
| 31 |
+
"num_hidden_layers": 12,
|
| 32 |
+
"output_attentions": false,
|
| 33 |
+
"output_hidden_states": false,
|
| 34 |
+
"output_proj_dims": 1536,
|
| 35 |
+
"problem_type": null,
|
| 36 |
+
"residual_weight": 0.5,
|
| 37 |
+
"return_dict": true,
|
| 38 |
+
"rms_norm_eps": 1e-06,
|
| 39 |
+
"subsampling_conv_channels": [
|
| 40 |
+
128,
|
| 41 |
+
32
|
| 42 |
+
],
|
| 43 |
+
"use_clipped_linears": true
|
| 44 |
+
},
|
| 45 |
+
"audio_token_id": 258881,
|
| 46 |
+
"boa_token_id": 256000,
|
| 47 |
+
"boi_token_id": 255999,
|
| 48 |
+
"do_sample": true,
|
| 49 |
+
"dtype": "bfloat16",
|
| 50 |
+
"eoa_token_id": 258883,
|
| 51 |
+
"eoa_token_index": 258883,
|
| 52 |
+
"eoi_token_id": 258882,
|
| 53 |
+
"eos_token_id": [
|
| 54 |
+
1,
|
| 55 |
+
106,
|
| 56 |
+
50
|
| 57 |
+
],
|
| 58 |
+
"generation_config": {
|
| 59 |
+
"bos_token_id": 2,
|
| 60 |
+
"do_sample": true,
|
| 61 |
+
"eos_token_id": [
|
| 62 |
+
1,
|
| 63 |
+
106,
|
| 64 |
+
50
|
| 65 |
+
],
|
| 66 |
+
"pad_token_id": 0,
|
| 67 |
+
"temperature": 1.0,
|
| 68 |
+
"top_k": 64,
|
| 69 |
+
"top_p": 0.95,
|
| 70 |
+
"transformers_version": "5.12.1"
|
| 71 |
+
},
|
| 72 |
+
"image_token_id": 258880,
|
| 73 |
+
"initializer_range": 0.02,
|
| 74 |
+
"model_type": "gemma4",
|
| 75 |
+
"quantization": {
|
| 76 |
+
"group_size": 64,
|
| 77 |
+
"bits": 4,
|
| 78 |
+
"mode": "affine"
|
| 79 |
+
},
|
| 80 |
+
"quantization_config": {
|
| 81 |
+
"group_size": 64,
|
| 82 |
+
"bits": 4,
|
| 83 |
+
"mode": "affine"
|
| 84 |
+
},
|
| 85 |
+
"temperature": 1.0,
|
| 86 |
+
"text_config": {
|
| 87 |
+
"attention_bias": false,
|
| 88 |
+
"attention_dropout": 0.0,
|
| 89 |
+
"attention_k_eq_v": false,
|
| 90 |
+
"bos_token_id": 2,
|
| 91 |
+
"dtype": "bfloat16",
|
| 92 |
+
"enable_moe_block": false,
|
| 93 |
+
"eos_token_id": 1,
|
| 94 |
+
"expert_intermediate_size": null,
|
| 95 |
+
"final_logit_softcapping": 30.0,
|
| 96 |
+
"global_head_dim": 512,
|
| 97 |
+
"head_dim": 256,
|
| 98 |
+
"hidden_activation": "gelu_pytorch_tanh",
|
| 99 |
+
"hidden_size": 1536,
|
| 100 |
+
"hidden_size_per_layer_input": 256,
|
| 101 |
+
"initializer_range": 0.02,
|
| 102 |
+
"intermediate_size": 6144,
|
| 103 |
+
"layer_types": [
|
| 104 |
+
"sliding_attention",
|
| 105 |
+
"sliding_attention",
|
| 106 |
+
"sliding_attention",
|
| 107 |
+
"sliding_attention",
|
| 108 |
+
"full_attention",
|
| 109 |
+
"sliding_attention",
|
| 110 |
+
"sliding_attention",
|
| 111 |
+
"sliding_attention",
|
| 112 |
+
"sliding_attention",
|
| 113 |
+
"full_attention",
|
| 114 |
+
"sliding_attention",
|
| 115 |
+
"sliding_attention",
|
| 116 |
+
"sliding_attention",
|
| 117 |
+
"sliding_attention",
|
| 118 |
+
"full_attention",
|
| 119 |
+
"sliding_attention",
|
| 120 |
+
"sliding_attention",
|
| 121 |
+
"sliding_attention",
|
| 122 |
+
"sliding_attention",
|
| 123 |
+
"full_attention",
|
| 124 |
+
"sliding_attention",
|
| 125 |
+
"sliding_attention",
|
| 126 |
+
"sliding_attention",
|
| 127 |
+
"sliding_attention",
|
| 128 |
+
"full_attention",
|
| 129 |
+
"sliding_attention",
|
| 130 |
+
"sliding_attention",
|
| 131 |
+
"sliding_attention",
|
| 132 |
+
"sliding_attention",
|
| 133 |
+
"full_attention",
|
| 134 |
+
"sliding_attention",
|
| 135 |
+
"sliding_attention",
|
| 136 |
+
"sliding_attention",
|
| 137 |
+
"sliding_attention",
|
| 138 |
+
"full_attention"
|
| 139 |
+
],
|
| 140 |
+
"max_position_embeddings": 131072,
|
| 141 |
+
"model_type": "gemma4_text",
|
| 142 |
+
"moe_intermediate_size": null,
|
| 143 |
+
"num_attention_heads": 8,
|
| 144 |
+
"num_experts": null,
|
| 145 |
+
"num_global_key_value_heads": null,
|
| 146 |
+
"num_hidden_layers": 35,
|
| 147 |
+
"num_key_value_heads": 1,
|
| 148 |
+
"num_kv_shared_layers": 20,
|
| 149 |
+
"pad_token_id": 0,
|
| 150 |
+
"rms_norm_eps": 1e-06,
|
| 151 |
+
"rope_parameters": {
|
| 152 |
+
"full_attention": {
|
| 153 |
+
"partial_rotary_factor": 0.25,
|
| 154 |
+
"rope_theta": 1000000.0,
|
| 155 |
+
"rope_type": "proportional"
|
| 156 |
+
},
|
| 157 |
+
"sliding_attention": {
|
| 158 |
+
"rope_theta": 10000.0,
|
| 159 |
+
"rope_type": "default"
|
| 160 |
+
}
|
| 161 |
+
},
|
| 162 |
+
"sliding_window": 512,
|
| 163 |
+
"tie_word_embeddings": true,
|
| 164 |
+
"top_k_experts": null,
|
| 165 |
+
"use_bidirectional_attention": null,
|
| 166 |
+
"use_cache": true,
|
| 167 |
+
"use_double_wide_mlp": true,
|
| 168 |
+
"vocab_size": 262144,
|
| 169 |
+
"vocab_size_per_layer_input": 262144
|
| 170 |
+
},
|
| 171 |
+
"tie_word_embeddings": true,
|
| 172 |
+
"top_k": 64,
|
| 173 |
+
"top_p": 0.95,
|
| 174 |
+
"transformers_version": "5.12.1",
|
| 175 |
+
"video_token_id": 258884,
|
| 176 |
+
"vision_config": {
|
| 177 |
+
"_name_or_path": "",
|
| 178 |
+
"architectures": null,
|
| 179 |
+
"attention_bias": false,
|
| 180 |
+
"attention_dropout": 0.0,
|
| 181 |
+
"chunk_size_feed_forward": 0,
|
| 182 |
+
"default_output_length": 280,
|
| 183 |
+
"dtype": "bfloat16",
|
| 184 |
+
"global_head_dim": 64,
|
| 185 |
+
"head_dim": 64,
|
| 186 |
+
"hidden_activation": "gelu_pytorch_tanh",
|
| 187 |
+
"hidden_size": 768,
|
| 188 |
+
"id2label": {
|
| 189 |
+
"0": "LABEL_0",
|
| 190 |
+
"1": "LABEL_1"
|
| 191 |
+
},
|
| 192 |
+
"initializer_range": 0.02,
|
| 193 |
+
"intermediate_size": 3072,
|
| 194 |
+
"is_encoder_decoder": false,
|
| 195 |
+
"label2id": {
|
| 196 |
+
"LABEL_0": 0,
|
| 197 |
+
"LABEL_1": 1
|
| 198 |
+
},
|
| 199 |
+
"max_position_embeddings": 131072,
|
| 200 |
+
"model_type": "gemma4_vision",
|
| 201 |
+
"num_attention_heads": 12,
|
| 202 |
+
"num_hidden_layers": 16,
|
| 203 |
+
"num_key_value_heads": 12,
|
| 204 |
+
"output_attentions": false,
|
| 205 |
+
"output_hidden_states": false,
|
| 206 |
+
"patch_size": 16,
|
| 207 |
+
"pooling_kernel_size": 3,
|
| 208 |
+
"position_embedding_size": 10240,
|
| 209 |
+
"problem_type": null,
|
| 210 |
+
"return_dict": true,
|
| 211 |
+
"rms_norm_eps": 1e-06,
|
| 212 |
+
"rope_parameters": {
|
| 213 |
+
"rope_theta": 100.0,
|
| 214 |
+
"rope_type": "default"
|
| 215 |
+
},
|
| 216 |
+
"standardize": false,
|
| 217 |
+
"use_clipped_linears": true
|
| 218 |
+
},
|
| 219 |
+
"vision_soft_tokens_per_image": 280
|
| 220 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token_id": 2,
|
| 3 |
+
"do_sample": true,
|
| 4 |
+
"eos_token_id": [
|
| 5 |
+
1,
|
| 6 |
+
106,
|
| 7 |
+
50
|
| 8 |
+
],
|
| 9 |
+
"pad_token_id": 0,
|
| 10 |
+
"temperature": 1.0,
|
| 11 |
+
"top_k": 64,
|
| 12 |
+
"top_p": 0.95,
|
| 13 |
+
"transformers_version": "5.12.1"
|
| 14 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:82936e02461d8240713e66ba881dd00996d0237b61782da3c66a36fb58108f02
|
| 3 |
+
size 3550670554
|
model.safetensors.index.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
processor_config.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"audio_seq_length": 750,
|
| 3 |
+
"image_processor": {
|
| 4 |
+
"do_convert_rgb": true,
|
| 5 |
+
"do_normalize": false,
|
| 6 |
+
"do_rescale": true,
|
| 7 |
+
"do_resize": true,
|
| 8 |
+
"image_mean": [
|
| 9 |
+
0.0,
|
| 10 |
+
0.0,
|
| 11 |
+
0.0
|
| 12 |
+
],
|
| 13 |
+
"image_processor_type": "Gemma4ImageProcessor",
|
| 14 |
+
"image_seq_length": 280,
|
| 15 |
+
"image_std": [
|
| 16 |
+
1.0,
|
| 17 |
+
1.0,
|
| 18 |
+
1.0
|
| 19 |
+
],
|
| 20 |
+
"max_soft_tokens": 280,
|
| 21 |
+
"patch_size": 16,
|
| 22 |
+
"pooling_kernel_size": 3,
|
| 23 |
+
"resample": 3,
|
| 24 |
+
"rescale_factor": 0.00392156862745098,
|
| 25 |
+
"size": {
|
| 26 |
+
"height": 224,
|
| 27 |
+
"width": 224
|
| 28 |
+
}
|
| 29 |
+
},
|
| 30 |
+
"image_seq_length": 280,
|
| 31 |
+
"processor_class": "Gemma4Processor",
|
| 32 |
+
"video_processor": {
|
| 33 |
+
"default_fps": 2.0,
|
| 34 |
+
"do_normalize": true,
|
| 35 |
+
"do_rescale": true,
|
| 36 |
+
"do_resize": true,
|
| 37 |
+
"image_mean": [
|
| 38 |
+
0.0,
|
| 39 |
+
0.0,
|
| 40 |
+
0.0
|
| 41 |
+
],
|
| 42 |
+
"image_std": [
|
| 43 |
+
1.0,
|
| 44 |
+
1.0,
|
| 45 |
+
1.0
|
| 46 |
+
],
|
| 47 |
+
"max_soft_tokens": 70,
|
| 48 |
+
"num_frames": 32,
|
| 49 |
+
"patch_size": 16,
|
| 50 |
+
"pooling_kernel_size": 3,
|
| 51 |
+
"rescale_factor": 0.00392156862745098,
|
| 52 |
+
"video_processor_type": "Gemma4VideoProcessor"
|
| 53 |
+
},
|
| 54 |
+
"feature_extractor": {
|
| 55 |
+
"feature_extractor_type": "Gemma4AudioFeatureExtractor",
|
| 56 |
+
"sampling_rate": 16000,
|
| 57 |
+
"num_mel_filters": 128,
|
| 58 |
+
"fft_length": 512,
|
| 59 |
+
"hop_length": 160,
|
| 60 |
+
"chunk_duration": 8.0,
|
| 61 |
+
"overlap_duration": 1.0
|
| 62 |
+
},
|
| 63 |
+
"audio_ms_per_token": 40
|
| 64 |
+
}
|
shared_kv_export_report.json
ADDED
|
@@ -0,0 +1,458 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"applicable": true,
|
| 3 |
+
"artifact": "mlx_q4",
|
| 4 |
+
"checks": [
|
| 5 |
+
{
|
| 6 |
+
"expected_layer_ids": [
|
| 7 |
+
0,
|
| 8 |
+
1,
|
| 9 |
+
2,
|
| 10 |
+
3,
|
| 11 |
+
4,
|
| 12 |
+
5,
|
| 13 |
+
6,
|
| 14 |
+
7,
|
| 15 |
+
8,
|
| 16 |
+
9,
|
| 17 |
+
10,
|
| 18 |
+
11,
|
| 19 |
+
12,
|
| 20 |
+
13,
|
| 21 |
+
14,
|
| 22 |
+
15,
|
| 23 |
+
16,
|
| 24 |
+
17,
|
| 25 |
+
18,
|
| 26 |
+
19,
|
| 27 |
+
20,
|
| 28 |
+
21,
|
| 29 |
+
22,
|
| 30 |
+
23,
|
| 31 |
+
24,
|
| 32 |
+
25,
|
| 33 |
+
26,
|
| 34 |
+
27,
|
| 35 |
+
28,
|
| 36 |
+
29,
|
| 37 |
+
30,
|
| 38 |
+
31,
|
| 39 |
+
32,
|
| 40 |
+
33,
|
| 41 |
+
34
|
| 42 |
+
],
|
| 43 |
+
"missing_layer_ids": [],
|
| 44 |
+
"name": "language.q_proj",
|
| 45 |
+
"observed_layer_ids": [
|
| 46 |
+
0,
|
| 47 |
+
1,
|
| 48 |
+
2,
|
| 49 |
+
3,
|
| 50 |
+
4,
|
| 51 |
+
5,
|
| 52 |
+
6,
|
| 53 |
+
7,
|
| 54 |
+
8,
|
| 55 |
+
9,
|
| 56 |
+
10,
|
| 57 |
+
11,
|
| 58 |
+
12,
|
| 59 |
+
13,
|
| 60 |
+
14,
|
| 61 |
+
15,
|
| 62 |
+
16,
|
| 63 |
+
17,
|
| 64 |
+
18,
|
| 65 |
+
19,
|
| 66 |
+
20,
|
| 67 |
+
21,
|
| 68 |
+
22,
|
| 69 |
+
23,
|
| 70 |
+
24,
|
| 71 |
+
25,
|
| 72 |
+
26,
|
| 73 |
+
27,
|
| 74 |
+
28,
|
| 75 |
+
29,
|
| 76 |
+
30,
|
| 77 |
+
31,
|
| 78 |
+
32,
|
| 79 |
+
33,
|
| 80 |
+
34
|
| 81 |
+
],
|
| 82 |
+
"ok": true,
|
| 83 |
+
"unexpected_layer_ids": []
|
| 84 |
+
},
|
| 85 |
+
{
|
| 86 |
+
"expected_layer_ids": [
|
| 87 |
+
0,
|
| 88 |
+
1,
|
| 89 |
+
2,
|
| 90 |
+
3,
|
| 91 |
+
4,
|
| 92 |
+
5,
|
| 93 |
+
6,
|
| 94 |
+
7,
|
| 95 |
+
8,
|
| 96 |
+
9,
|
| 97 |
+
10,
|
| 98 |
+
11,
|
| 99 |
+
12,
|
| 100 |
+
13,
|
| 101 |
+
14,
|
| 102 |
+
15,
|
| 103 |
+
16,
|
| 104 |
+
17,
|
| 105 |
+
18,
|
| 106 |
+
19,
|
| 107 |
+
20,
|
| 108 |
+
21,
|
| 109 |
+
22,
|
| 110 |
+
23,
|
| 111 |
+
24,
|
| 112 |
+
25,
|
| 113 |
+
26,
|
| 114 |
+
27,
|
| 115 |
+
28,
|
| 116 |
+
29,
|
| 117 |
+
30,
|
| 118 |
+
31,
|
| 119 |
+
32,
|
| 120 |
+
33,
|
| 121 |
+
34
|
| 122 |
+
],
|
| 123 |
+
"missing_layer_ids": [],
|
| 124 |
+
"name": "language.o_proj",
|
| 125 |
+
"observed_layer_ids": [
|
| 126 |
+
0,
|
| 127 |
+
1,
|
| 128 |
+
2,
|
| 129 |
+
3,
|
| 130 |
+
4,
|
| 131 |
+
5,
|
| 132 |
+
6,
|
| 133 |
+
7,
|
| 134 |
+
8,
|
| 135 |
+
9,
|
| 136 |
+
10,
|
| 137 |
+
11,
|
| 138 |
+
12,
|
| 139 |
+
13,
|
| 140 |
+
14,
|
| 141 |
+
15,
|
| 142 |
+
16,
|
| 143 |
+
17,
|
| 144 |
+
18,
|
| 145 |
+
19,
|
| 146 |
+
20,
|
| 147 |
+
21,
|
| 148 |
+
22,
|
| 149 |
+
23,
|
| 150 |
+
24,
|
| 151 |
+
25,
|
| 152 |
+
26,
|
| 153 |
+
27,
|
| 154 |
+
28,
|
| 155 |
+
29,
|
| 156 |
+
30,
|
| 157 |
+
31,
|
| 158 |
+
32,
|
| 159 |
+
33,
|
| 160 |
+
34
|
| 161 |
+
],
|
| 162 |
+
"ok": true,
|
| 163 |
+
"unexpected_layer_ids": []
|
| 164 |
+
},
|
| 165 |
+
{
|
| 166 |
+
"expected_layer_ids": [
|
| 167 |
+
0,
|
| 168 |
+
1,
|
| 169 |
+
2,
|
| 170 |
+
3,
|
| 171 |
+
4,
|
| 172 |
+
5,
|
| 173 |
+
6,
|
| 174 |
+
7,
|
| 175 |
+
8,
|
| 176 |
+
9,
|
| 177 |
+
10,
|
| 178 |
+
11,
|
| 179 |
+
12,
|
| 180 |
+
13,
|
| 181 |
+
14,
|
| 182 |
+
15,
|
| 183 |
+
16,
|
| 184 |
+
17,
|
| 185 |
+
18,
|
| 186 |
+
19,
|
| 187 |
+
20,
|
| 188 |
+
21,
|
| 189 |
+
22,
|
| 190 |
+
23,
|
| 191 |
+
24,
|
| 192 |
+
25,
|
| 193 |
+
26,
|
| 194 |
+
27,
|
| 195 |
+
28,
|
| 196 |
+
29,
|
| 197 |
+
30,
|
| 198 |
+
31,
|
| 199 |
+
32,
|
| 200 |
+
33,
|
| 201 |
+
34
|
| 202 |
+
],
|
| 203 |
+
"missing_layer_ids": [],
|
| 204 |
+
"name": "language.q_norm",
|
| 205 |
+
"observed_layer_ids": [
|
| 206 |
+
0,
|
| 207 |
+
1,
|
| 208 |
+
2,
|
| 209 |
+
3,
|
| 210 |
+
4,
|
| 211 |
+
5,
|
| 212 |
+
6,
|
| 213 |
+
7,
|
| 214 |
+
8,
|
| 215 |
+
9,
|
| 216 |
+
10,
|
| 217 |
+
11,
|
| 218 |
+
12,
|
| 219 |
+
13,
|
| 220 |
+
14,
|
| 221 |
+
15,
|
| 222 |
+
16,
|
| 223 |
+
17,
|
| 224 |
+
18,
|
| 225 |
+
19,
|
| 226 |
+
20,
|
| 227 |
+
21,
|
| 228 |
+
22,
|
| 229 |
+
23,
|
| 230 |
+
24,
|
| 231 |
+
25,
|
| 232 |
+
26,
|
| 233 |
+
27,
|
| 234 |
+
28,
|
| 235 |
+
29,
|
| 236 |
+
30,
|
| 237 |
+
31,
|
| 238 |
+
32,
|
| 239 |
+
33,
|
| 240 |
+
34
|
| 241 |
+
],
|
| 242 |
+
"ok": true,
|
| 243 |
+
"unexpected_layer_ids": []
|
| 244 |
+
},
|
| 245 |
+
{
|
| 246 |
+
"expected_layer_ids": [
|
| 247 |
+
0,
|
| 248 |
+
1,
|
| 249 |
+
2,
|
| 250 |
+
3,
|
| 251 |
+
4,
|
| 252 |
+
5,
|
| 253 |
+
6,
|
| 254 |
+
7,
|
| 255 |
+
8,
|
| 256 |
+
9,
|
| 257 |
+
10,
|
| 258 |
+
11,
|
| 259 |
+
12,
|
| 260 |
+
13,
|
| 261 |
+
14
|
| 262 |
+
],
|
| 263 |
+
"missing_layer_ids": [],
|
| 264 |
+
"name": "language.k_proj",
|
| 265 |
+
"observed_layer_ids": [
|
| 266 |
+
0,
|
| 267 |
+
1,
|
| 268 |
+
2,
|
| 269 |
+
3,
|
| 270 |
+
4,
|
| 271 |
+
5,
|
| 272 |
+
6,
|
| 273 |
+
7,
|
| 274 |
+
8,
|
| 275 |
+
9,
|
| 276 |
+
10,
|
| 277 |
+
11,
|
| 278 |
+
12,
|
| 279 |
+
13,
|
| 280 |
+
14
|
| 281 |
+
],
|
| 282 |
+
"ok": true,
|
| 283 |
+
"unexpected_layer_ids": []
|
| 284 |
+
},
|
| 285 |
+
{
|
| 286 |
+
"expected_layer_ids": [
|
| 287 |
+
0,
|
| 288 |
+
1,
|
| 289 |
+
2,
|
| 290 |
+
3,
|
| 291 |
+
4,
|
| 292 |
+
5,
|
| 293 |
+
6,
|
| 294 |
+
7,
|
| 295 |
+
8,
|
| 296 |
+
9,
|
| 297 |
+
10,
|
| 298 |
+
11,
|
| 299 |
+
12,
|
| 300 |
+
13,
|
| 301 |
+
14
|
| 302 |
+
],
|
| 303 |
+
"missing_layer_ids": [],
|
| 304 |
+
"name": "language.v_proj",
|
| 305 |
+
"observed_layer_ids": [
|
| 306 |
+
0,
|
| 307 |
+
1,
|
| 308 |
+
2,
|
| 309 |
+
3,
|
| 310 |
+
4,
|
| 311 |
+
5,
|
| 312 |
+
6,
|
| 313 |
+
7,
|
| 314 |
+
8,
|
| 315 |
+
9,
|
| 316 |
+
10,
|
| 317 |
+
11,
|
| 318 |
+
12,
|
| 319 |
+
13,
|
| 320 |
+
14
|
| 321 |
+
],
|
| 322 |
+
"ok": true,
|
| 323 |
+
"unexpected_layer_ids": []
|
| 324 |
+
},
|
| 325 |
+
{
|
| 326 |
+
"expected_layer_ids": [
|
| 327 |
+
0,
|
| 328 |
+
1,
|
| 329 |
+
2,
|
| 330 |
+
3,
|
| 331 |
+
4,
|
| 332 |
+
5,
|
| 333 |
+
6,
|
| 334 |
+
7,
|
| 335 |
+
8,
|
| 336 |
+
9,
|
| 337 |
+
10,
|
| 338 |
+
11,
|
| 339 |
+
12,
|
| 340 |
+
13,
|
| 341 |
+
14
|
| 342 |
+
],
|
| 343 |
+
"missing_layer_ids": [],
|
| 344 |
+
"name": "language.k_norm",
|
| 345 |
+
"observed_layer_ids": [
|
| 346 |
+
0,
|
| 347 |
+
1,
|
| 348 |
+
2,
|
| 349 |
+
3,
|
| 350 |
+
4,
|
| 351 |
+
5,
|
| 352 |
+
6,
|
| 353 |
+
7,
|
| 354 |
+
8,
|
| 355 |
+
9,
|
| 356 |
+
10,
|
| 357 |
+
11,
|
| 358 |
+
12,
|
| 359 |
+
13,
|
| 360 |
+
14
|
| 361 |
+
],
|
| 362 |
+
"ok": true,
|
| 363 |
+
"unexpected_layer_ids": []
|
| 364 |
+
},
|
| 365 |
+
{
|
| 366 |
+
"expected_layer_ids": [
|
| 367 |
+
0,
|
| 368 |
+
1,
|
| 369 |
+
2,
|
| 370 |
+
3,
|
| 371 |
+
4,
|
| 372 |
+
5,
|
| 373 |
+
6,
|
| 374 |
+
7,
|
| 375 |
+
8,
|
| 376 |
+
9,
|
| 377 |
+
10,
|
| 378 |
+
11,
|
| 379 |
+
12,
|
| 380 |
+
13,
|
| 381 |
+
14,
|
| 382 |
+
15
|
| 383 |
+
],
|
| 384 |
+
"missing_layer_ids": [],
|
| 385 |
+
"name": "vision.k_norm",
|
| 386 |
+
"observed_layer_ids": [
|
| 387 |
+
0,
|
| 388 |
+
1,
|
| 389 |
+
2,
|
| 390 |
+
3,
|
| 391 |
+
4,
|
| 392 |
+
5,
|
| 393 |
+
6,
|
| 394 |
+
7,
|
| 395 |
+
8,
|
| 396 |
+
9,
|
| 397 |
+
10,
|
| 398 |
+
11,
|
| 399 |
+
12,
|
| 400 |
+
13,
|
| 401 |
+
14,
|
| 402 |
+
15
|
| 403 |
+
],
|
| 404 |
+
"ok": true,
|
| 405 |
+
"unexpected_layer_ids": []
|
| 406 |
+
}
|
| 407 |
+
],
|
| 408 |
+
"errors": [],
|
| 409 |
+
"expected_language_k_norm_count": 15,
|
| 410 |
+
"expected_vision_k_norm_count": 16,
|
| 411 |
+
"explanation": "Gemma 4 serializes K/V projections and k_norm only for the leading non-shared language layers. Later language layers reuse shared K/V states and must not be treated as missing tensors.",
|
| 412 |
+
"kv_owner_layer_ids": [
|
| 413 |
+
0,
|
| 414 |
+
1,
|
| 415 |
+
2,
|
| 416 |
+
3,
|
| 417 |
+
4,
|
| 418 |
+
5,
|
| 419 |
+
6,
|
| 420 |
+
7,
|
| 421 |
+
8,
|
| 422 |
+
9,
|
| 423 |
+
10,
|
| 424 |
+
11,
|
| 425 |
+
12,
|
| 426 |
+
13,
|
| 427 |
+
14
|
| 428 |
+
],
|
| 429 |
+
"kv_shared_layer_ids": [
|
| 430 |
+
15,
|
| 431 |
+
16,
|
| 432 |
+
17,
|
| 433 |
+
18,
|
| 434 |
+
19,
|
| 435 |
+
20,
|
| 436 |
+
21,
|
| 437 |
+
22,
|
| 438 |
+
23,
|
| 439 |
+
24,
|
| 440 |
+
25,
|
| 441 |
+
26,
|
| 442 |
+
27,
|
| 443 |
+
28,
|
| 444 |
+
29,
|
| 445 |
+
30,
|
| 446 |
+
31,
|
| 447 |
+
32,
|
| 448 |
+
33,
|
| 449 |
+
34
|
| 450 |
+
],
|
| 451 |
+
"model_type": "gemma4",
|
| 452 |
+
"num_hidden_layers": 35,
|
| 453 |
+
"num_kv_shared_layers": 20,
|
| 454 |
+
"ok": true,
|
| 455 |
+
"schema_version": 1,
|
| 456 |
+
"serialized_tensor_count": 2511,
|
| 457 |
+
"serialized_weight_source": "model.safetensors.index.json"
|
| 458 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cc8d3a0ce36466ccc1278bf987df5f71db1719b9ca6b4118264f45cb627bfe0f
|
| 3 |
+
size 32169626
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"audio_token": "<|audio|>",
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"boa_token": "<|audio>",
|
| 5 |
+
"boi_token": "<|image>",
|
| 6 |
+
"bos_token": "<bos>",
|
| 7 |
+
"eoa_token": "<audio|>",
|
| 8 |
+
"eoc_token": "<channel|>",
|
| 9 |
+
"eoi_token": "<image|>",
|
| 10 |
+
"eos_token": "<eos>",
|
| 11 |
+
"eot_token": "<turn|>",
|
| 12 |
+
"escape_token": "<|\"|>",
|
| 13 |
+
"etc_token": "<tool_call|>",
|
| 14 |
+
"etd_token": "<tool|>",
|
| 15 |
+
"etr_token": "<tool_response|>",
|
| 16 |
+
"extra_special_tokens": [
|
| 17 |
+
"<|video|>"
|
| 18 |
+
],
|
| 19 |
+
"image_token": "<|image|>",
|
| 20 |
+
"is_local": true,
|
| 21 |
+
"local_files_only": true,
|
| 22 |
+
"mask_token": "<mask>",
|
| 23 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 24 |
+
"model_specific_special_tokens": {
|
| 25 |
+
"audio_token": "<|audio|>",
|
| 26 |
+
"boa_token": "<|audio>",
|
| 27 |
+
"boi_token": "<|image>",
|
| 28 |
+
"eoa_token": "<audio|>",
|
| 29 |
+
"eoc_token": "<channel|>",
|
| 30 |
+
"eoi_token": "<image|>",
|
| 31 |
+
"eot_token": "<turn|>",
|
| 32 |
+
"escape_token": "<|\"|>",
|
| 33 |
+
"etc_token": "<tool_call|>",
|
| 34 |
+
"etd_token": "<tool|>",
|
| 35 |
+
"etr_token": "<tool_response|>",
|
| 36 |
+
"image_token": "<|image|>",
|
| 37 |
+
"soc_token": "<|channel>",
|
| 38 |
+
"sot_token": "<|turn>",
|
| 39 |
+
"stc_token": "<|tool_call>",
|
| 40 |
+
"std_token": "<|tool>",
|
| 41 |
+
"str_token": "<|tool_response>",
|
| 42 |
+
"think_token": "<|think|>"
|
| 43 |
+
},
|
| 44 |
+
"pad_token": "<pad>",
|
| 45 |
+
"padding_side": "left",
|
| 46 |
+
"processor_class": "Gemma4Processor",
|
| 47 |
+
"response_schema": {
|
| 48 |
+
"properties": {
|
| 49 |
+
"content": {
|
| 50 |
+
"type": "string"
|
| 51 |
+
},
|
| 52 |
+
"role": {
|
| 53 |
+
"const": "assistant"
|
| 54 |
+
},
|
| 55 |
+
"thinking": {
|
| 56 |
+
"type": "string"
|
| 57 |
+
},
|
| 58 |
+
"tool_calls": {
|
| 59 |
+
"items": {
|
| 60 |
+
"properties": {
|
| 61 |
+
"function": {
|
| 62 |
+
"properties": {
|
| 63 |
+
"arguments": {
|
| 64 |
+
"additionalProperties": {},
|
| 65 |
+
"type": "object",
|
| 66 |
+
"x-parser": "gemma4-tool-call"
|
| 67 |
+
},
|
| 68 |
+
"name": {
|
| 69 |
+
"type": "string"
|
| 70 |
+
}
|
| 71 |
+
},
|
| 72 |
+
"type": "object",
|
| 73 |
+
"x-regex": "call\\:(?P<name>\\w+)(?P<arguments>\\{.*\\})"
|
| 74 |
+
},
|
| 75 |
+
"type": {
|
| 76 |
+
"const": "function"
|
| 77 |
+
}
|
| 78 |
+
},
|
| 79 |
+
"type": "object"
|
| 80 |
+
},
|
| 81 |
+
"type": "array",
|
| 82 |
+
"x-regex-iterator": "<\\|tool_call>(.*?)<tool_call\\|>"
|
| 83 |
+
}
|
| 84 |
+
},
|
| 85 |
+
"type": "object",
|
| 86 |
+
"x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?P<content>(?:(?!\\<turn\\|\\>)(?!\\<\\|tool_response\\>).)+)?(?:\\<turn\\|\\>|\\<\\|tool_response\\>)?"
|
| 87 |
+
},
|
| 88 |
+
"response_template": {
|
| 89 |
+
"defaults": {
|
| 90 |
+
"role": "assistant"
|
| 91 |
+
},
|
| 92 |
+
"fields": {
|
| 93 |
+
"content": {
|
| 94 |
+
"close": [
|
| 95 |
+
"<turn|>",
|
| 96 |
+
"<|tool_response>",
|
| 97 |
+
"<eos>"
|
| 98 |
+
],
|
| 99 |
+
"content": "text"
|
| 100 |
+
},
|
| 101 |
+
"thinking": {
|
| 102 |
+
"close": "<channel|>",
|
| 103 |
+
"content": "text",
|
| 104 |
+
"open": "<|channel>thought\n"
|
| 105 |
+
},
|
| 106 |
+
"tool_calls": {
|
| 107 |
+
"close": "<tool_call|>",
|
| 108 |
+
"content": "json",
|
| 109 |
+
"content_args": {
|
| 110 |
+
"string_delims": [
|
| 111 |
+
[
|
| 112 |
+
"<|\"|>",
|
| 113 |
+
"<|\"|>"
|
| 114 |
+
]
|
| 115 |
+
],
|
| 116 |
+
"unquoted_keys": true
|
| 117 |
+
},
|
| 118 |
+
"open_pattern": "<\\|tool_call>call:(?P<name>\\w+)",
|
| 119 |
+
"repeats": true,
|
| 120 |
+
"transform": {
|
| 121 |
+
"function": {
|
| 122 |
+
"arguments": "{content}",
|
| 123 |
+
"name": "{name}"
|
| 124 |
+
},
|
| 125 |
+
"type": "function"
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
},
|
| 129 |
+
"start_anchor": [
|
| 130 |
+
"<|turn>model\n",
|
| 131 |
+
"<tool_response|>"
|
| 132 |
+
]
|
| 133 |
+
},
|
| 134 |
+
"soc_token": "<|channel>",
|
| 135 |
+
"sot_token": "<|turn>",
|
| 136 |
+
"stc_token": "<|tool_call>",
|
| 137 |
+
"std_token": "<|tool>",
|
| 138 |
+
"str_token": "<|tool_response>",
|
| 139 |
+
"think_token": "<|think|>",
|
| 140 |
+
"tokenizer_class": "GemmaTokenizer",
|
| 141 |
+
"unk_token": "<unk>"
|
| 142 |
+
}
|