Image-Text-to-Text
MLX
Safetensors
gemma4_unified
apple-silicon
multimodal
text-classification
image-classification
typed-decision
conversational
4-bit precision
Instructions to use Ruiruiz30/Jev-Omni-MLX-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use Ruiruiz30/Jev-Omni-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("Ruiruiz30/Jev-Omni-MLX-4bit") config = load_config("Ruiruiz30/Jev-Omni-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 Ruiruiz30/Jev-Omni-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 "Ruiruiz30/Jev-Omni-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": "Ruiruiz30/Jev-Omni-MLX-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent
How to use Ruiruiz30/Jev-Omni-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 "Ruiruiz30/Jev-Omni-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 Ruiruiz30/Jev-Omni-MLX-4bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use Ruiruiz30/Jev-Omni-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 "Ruiruiz30/Jev-Omni-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 "Ruiruiz30/Jev-Omni-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"
Add Jev-Omni MLX 4-bit Mac mini release
Browse filesApple Silicon MLX conversion of akhilaaa3/Jev-Omni with local M4/16GB benchmarks and inference code.
- .gitattributes +1 -0
- LICENSE +202 -0
- NOTICE.md +7 -0
- README.md +87 -0
- chat_template.jinja +390 -0
- config.json +182 -0
- conversion.json +11 -0
- decision_head/weights.safetensors +3 -0
- generation_config.json +18 -0
- model.safetensors.index.json +0 -0
- omni_mlx/__init__.py +1 -0
- omni_mlx/__pycache__/__init__.cpython-310.pyc +0 -0
- omni_mlx/__pycache__/__init__.cpython-313.pyc +0 -0
- omni_mlx/__pycache__/classifier.cpython-310.pyc +0 -0
- omni_mlx/__pycache__/classifier.cpython-313.pyc +0 -0
- omni_mlx/__pycache__/convert.cpython-310.pyc +0 -0
- omni_mlx/__pycache__/convert.cpython-313.pyc +0 -0
- omni_mlx/classifier.py +120 -0
- omni_mlx/convert.py +133 -0
- processor_config.json +62 -0
- requirements.txt +4 -0
- tokenizer.json +3 -0
- tokenizer_config.json +142 -0
- verification_unified.json +67 -0
- weights-001.safetensors +3 -0
- weights-002.safetensors +3 -0
- weights-003.safetensors +3 -0
- weights-004.safetensors +3 -0
- weights-005.safetensors +3 -0
- weights-006.safetensors +3 -0
- weights-007.safetensors +3 -0
- weights-008.safetensors +3 -0
- weights-009.safetensors +3 -0
- weights-010.safetensors +3 -0
- weights-011.safetensors +3 -0
- weights-012.safetensors +3 -0
- weights-013.safetensors +3 -0
- weights-014.safetensors +3 -0
- weights-015.safetensors +3 -0
- weights-016.safetensors +3 -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=lfs merge=lfs -text
|
LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Apache License
|
| 3 |
+
Version 2.0, January 2004
|
| 4 |
+
http://www.apache.org/licenses/
|
| 5 |
+
|
| 6 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 7 |
+
|
| 8 |
+
1. Definitions.
|
| 9 |
+
|
| 10 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 11 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 12 |
+
|
| 13 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 14 |
+
the copyright owner that is granting the License.
|
| 15 |
+
|
| 16 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 17 |
+
other entities that control, are controlled by, or are under common
|
| 18 |
+
control with that entity. For the purposes of this definition,
|
| 19 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 20 |
+
direction or management of such entity, whether by contract or
|
| 21 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 22 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 23 |
+
|
| 24 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 25 |
+
exercising permissions granted by this License.
|
| 26 |
+
|
| 27 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 28 |
+
including but not limited to software source code, documentation
|
| 29 |
+
source, and configuration files.
|
| 30 |
+
|
| 31 |
+
"Object" form shall mean any form resulting from mechanical
|
| 32 |
+
transformation or translation of a Source form, including but
|
| 33 |
+
not limited to compiled object code, generated documentation,
|
| 34 |
+
and conversions to other media types.
|
| 35 |
+
|
| 36 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 37 |
+
Object form, made available under the License, as indicated by a
|
| 38 |
+
copyright notice that is included in or attached to the work
|
| 39 |
+
(an example is provided in the Appendix below).
|
| 40 |
+
|
| 41 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 42 |
+
form, that is based on (or derived from) the Work and for which the
|
| 43 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 44 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 45 |
+
of this License, Derivative Works shall not include works that remain
|
| 46 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 47 |
+
the Work and Derivative Works thereof.
|
| 48 |
+
|
| 49 |
+
"Contribution" shall mean any work of authorship, including
|
| 50 |
+
the original version of the Work and any modifications or additions
|
| 51 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 52 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 53 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 54 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 55 |
+
means any form of electronic, verbal, or written communication sent
|
| 56 |
+
to the Licensor or its representatives, including but not limited to
|
| 57 |
+
communication on electronic mailing lists, source code control systems,
|
| 58 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 59 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 60 |
+
excluding communication that is conspicuously marked or otherwise
|
| 61 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 62 |
+
|
| 63 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 64 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 65 |
+
subsequently incorporated within the Work.
|
| 66 |
+
|
| 67 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 68 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 69 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 70 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 71 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 72 |
+
Work and such Derivative Works in Source or Object form.
|
| 73 |
+
|
| 74 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 75 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 76 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 77 |
+
(except as stated in this section) patent license to make, have made,
|
| 78 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 79 |
+
where such license applies only to those patent claims licensable
|
| 80 |
+
by such Contributor that are necessarily infringed by their
|
| 81 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 82 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 83 |
+
institute patent litigation against any entity (including a
|
| 84 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 85 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 86 |
+
or contributory patent infringement, then any patent licenses
|
| 87 |
+
granted to You under this License for that Work shall terminate
|
| 88 |
+
as of the date such litigation is filed.
|
| 89 |
+
|
| 90 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 91 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 92 |
+
modifications, and in Source or Object form, provided that You
|
| 93 |
+
meet the following conditions:
|
| 94 |
+
|
| 95 |
+
(a) You must give any other recipients of the Work or
|
| 96 |
+
Derivative Works a copy of this License; and
|
| 97 |
+
|
| 98 |
+
(b) You must cause any modified files to carry prominent notices
|
| 99 |
+
stating that You changed the files; and
|
| 100 |
+
|
| 101 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 102 |
+
that You distribute, all copyright, patent, trademark, and
|
| 103 |
+
attribution notices from the Source form of the Work,
|
| 104 |
+
excluding those notices that do not pertain to any part of
|
| 105 |
+
the Derivative Works; and
|
| 106 |
+
|
| 107 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 108 |
+
distribution, then any Derivative Works that You distribute must
|
| 109 |
+
include a readable copy of the attribution notices contained
|
| 110 |
+
within such NOTICE file, excluding those notices that do not
|
| 111 |
+
pertain to any part of the Derivative Works, in at least one
|
| 112 |
+
of the following places: within a NOTICE text file distributed
|
| 113 |
+
as part of the Derivative Works; within the Source form or
|
| 114 |
+
documentation, if provided along with the Derivative Works; or,
|
| 115 |
+
within a display generated by the Derivative Works, if and
|
| 116 |
+
wherever such third-party notices normally appear. The contents
|
| 117 |
+
of the NOTICE file are for informational purposes only and
|
| 118 |
+
do not modify the License. You may add Your own attribution
|
| 119 |
+
notices within Derivative Works that You distribute, alongside
|
| 120 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 121 |
+
that such additional attribution notices cannot be construed
|
| 122 |
+
as modifying the License.
|
| 123 |
+
|
| 124 |
+
You may add Your own copyright statement to Your modifications and
|
| 125 |
+
may provide additional or different license terms and conditions
|
| 126 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 127 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 128 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 129 |
+
the conditions stated in this License.
|
| 130 |
+
|
| 131 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 132 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 133 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 134 |
+
this License, without any additional terms or conditions.
|
| 135 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 136 |
+
the terms of any separate license agreement you may have executed
|
| 137 |
+
with Licensor regarding such Contributions.
|
| 138 |
+
|
| 139 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 140 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 141 |
+
except as required for reasonable and customary use in describing the
|
| 142 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 143 |
+
|
| 144 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 145 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 146 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 147 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 148 |
+
implied, including, without limitation, any warranties or conditions
|
| 149 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 150 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 151 |
+
appropriateness of using or redistributing the Work and assume any
|
| 152 |
+
risks associated with Your exercise of permissions under this License.
|
| 153 |
+
|
| 154 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 155 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 156 |
+
unless required by applicable law (such as deliberate and grossly
|
| 157 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 158 |
+
liable to You for damages, including any direct, indirect, special,
|
| 159 |
+
incidental, or consequential damages of any character arising as a
|
| 160 |
+
result of this License or out of the use or inability to use the
|
| 161 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 162 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 163 |
+
other commercial damages or losses), even if such Contributor
|
| 164 |
+
has been advised of the possibility of such damages.
|
| 165 |
+
|
| 166 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 167 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 168 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 169 |
+
or other liability obligations and/or rights consistent with this
|
| 170 |
+
License. However, in accepting such obligations, You may act only
|
| 171 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 172 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 173 |
+
defend, and hold each Contributor harmless for any liability
|
| 174 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 175 |
+
of your accepting any such warranty or additional liability.
|
| 176 |
+
|
| 177 |
+
END OF TERMS AND CONDITIONS
|
| 178 |
+
|
| 179 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 180 |
+
|
| 181 |
+
To apply the Apache License to your work, attach the following
|
| 182 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 183 |
+
replaced with your own identifying information. (Don't include
|
| 184 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 185 |
+
comment syntax for the file format. We also recommend that a
|
| 186 |
+
file or class name and description of purpose be included on the
|
| 187 |
+
same "printed page" as the copyright notice for easier
|
| 188 |
+
identification within third-party archives.
|
| 189 |
+
|
| 190 |
+
Copyright [yyyy] [name of copyright owner]
|
| 191 |
+
|
| 192 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 193 |
+
you may not use this file except in compliance with the License.
|
| 194 |
+
You may obtain a copy of the License at
|
| 195 |
+
|
| 196 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 197 |
+
|
| 198 |
+
Unless required by applicable law or agreed to in writing, software
|
| 199 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 200 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 201 |
+
See the License for the specific language governing permissions and
|
| 202 |
+
limitations under the License.
|
NOTICE.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Attribution
|
| 2 |
+
|
| 3 |
+
This repository is an Apple Silicon MLX conversion of [`akhilaaa3/Jev-Omni`](https://huggingface.co/akhilaaa3/Jev-Omni), pinned to revision `c050d51354147985d13286cf4acf90f562f2c631`.
|
| 4 |
+
|
| 5 |
+
The converted weights use the upstream unified checkpoint and decision head. The upstream model card identifies the model as Apache-2.0 and states that it is an independent open model, not affiliated with TypeSafe AI.
|
| 6 |
+
|
| 7 |
+
The conversion and inference wrapper in `omni_mlx/` are provided under Apache-2.0. The base Gemma 4 model and any dataset terms remain subject to their respective upstream notices.
|
README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: akhilaaa3/Jev-Omni
|
| 4 |
+
library_name: mlx
|
| 5 |
+
pipeline_tag: image-text-to-text
|
| 6 |
+
tags:
|
| 7 |
+
- mlx
|
| 8 |
+
- apple-silicon
|
| 9 |
+
- multimodal
|
| 10 |
+
- text-classification
|
| 11 |
+
- image-classification
|
| 12 |
+
- typed-decision
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# Jev-Omni-MLX-4bit
|
| 16 |
+
|
| 17 |
+
An Apple Silicon MLX conversion of [`akhilaaa3/Jev-Omni`](https://huggingface.co/akhilaaa3/Jev-Omni) for local inference on a Mac mini with 16GB unified memory.
|
| 18 |
+
|
| 19 |
+
This repository keeps the upstream Jev-Omni unified multimodal checkpoint and its trained 256-way decision head, then converts the language-model weights to **4-bit affine quantization with group size 64**. The vision weights remain BF16 and the decision head remains FP32.
|
| 20 |
+
|
| 21 |
+
It is an independent conversion. It is not an official TypeSafe Jev release and does not claim to reproduce TypeSafe's proprietary system. It is also not a new fine-tune.
|
| 22 |
+
|
| 23 |
+
## Hardware and speed
|
| 24 |
+
|
| 25 |
+
Measured on:
|
| 26 |
+
|
| 27 |
+
- Mac mini, Apple M4, 10 CPU cores, 16GB unified memory
|
| 28 |
+
- macOS 26.5.1
|
| 29 |
+
- Python 3.13.12
|
| 30 |
+
- MLX 0.32.2
|
| 31 |
+
- MLX-VLM 0.7.1
|
| 32 |
+
- single request, batch size 1, no token generation
|
| 33 |
+
|
| 34 |
+
Ten warm requests were measured after one warm-up request. The image test used the recommended 20 visual-token budget and a 3-option question.
|
| 35 |
+
|
| 36 |
+
| Mode | Median | P95 | Peak Metal memory |
|
| 37 |
+
|---|---:|---:|---:|
|
| 38 |
+
| Text decision | ~963 ms | ~998 ms | ~7.0 GB |
|
| 39 |
+
| Image decision, 20 visual tokens | ~994 ms | ~1,021 ms | ~7.0 GB |
|
| 40 |
+
|
| 41 |
+
The first request includes MLX graph and memory warm-up. On the same machine, a 70-token image request is slower (roughly 1.8 seconds warm in an earlier run). Lowering visual tokens reduces latency but can lose small details; validate on your own game frames.
|
| 42 |
+
|
| 43 |
+
The published Jev-Omni H200 numbers are not transferable to this Mac mini. This model card reports local measurements only.
|
| 44 |
+
|
| 45 |
+
## Validation
|
| 46 |
+
|
| 47 |
+
- Upstream unified verification cases: 4/4 argmax decisions matched after 4-bit conversion.
|
| 48 |
+
- Six simple red/blue/green circle and square image checks: 6/6 color decisions matched.
|
| 49 |
+
- Maximum absolute probability difference on the four upstream text cases: 0.244 in this small check.
|
| 50 |
+
- JevBench and DecisionBench were **not** re-run for this conversion.
|
| 51 |
+
- Quantization changes the probability distribution; probabilities are not recalibrated here and must not be treated as calibrated confidence.
|
| 52 |
+
|
| 53 |
+
## Installation
|
| 54 |
+
|
| 55 |
+
This release is intended for Apple Silicon. Download the repository and install the small MLX runtime:
|
| 56 |
+
|
| 57 |
+
```bash
|
| 58 |
+
hf download Ruiruiz30/Jev-Omni-MLX-4bit \
|
| 59 |
+
--local-dir Jev-Omni-MLX-4bit
|
| 60 |
+
|
| 61 |
+
cd Jev-Omni-MLX-4bit
|
| 62 |
+
python3.13 -m venv .venv
|
| 63 |
+
source .venv/bin/activate
|
| 64 |
+
pip install -r requirements.txt
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
## Image decision
|
| 68 |
+
|
| 69 |
+
```bash
|
| 70 |
+
python -m omni_mlx.classifier \
|
| 71 |
+
--model . \
|
| 72 |
+
--image /path/to/frame.png \
|
| 73 |
+
--state "A kart is approaching a right turn." \
|
| 74 |
+
--question "Which steering action is best?" \
|
| 75 |
+
--options "Turn left" "Hold center" "Turn right" \
|
| 76 |
+
--image-tokens 20
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
The classifier returns candidate probabilities and the selected option. It does not generate a free-form explanation. Use `--image-tokens 70` when the scene contains small or dense visual details.
|
| 80 |
+
|
| 81 |
+
## Local conversion code
|
| 82 |
+
|
| 83 |
+
`omni_mlx/convert.py` contains the conversion path used for this release. The original unquantized checkpoint is not bundled here; it can be obtained from the upstream repository under its own license and terms.
|
| 84 |
+
|
| 85 |
+
## License and attribution
|
| 86 |
+
|
| 87 |
+
Apache-2.0. See [LICENSE](LICENSE) and [NOTICE.md](NOTICE.md). The upstream model card, Gemma 4 terms, and dataset rights remain authoritative for their respective components.
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 236 |
+
{%- endif -%}
|
| 237 |
+
|
| 238 |
+
{#- Render reasoning/reasoning_content as thinking channel -#}
|
| 239 |
+
{%- set thinking_text = message.get('reasoning') or message.get('reasoning_content') -%}
|
| 240 |
+
{%- set thinking_gate = (loop.index0 > ns_turn.last_user_idx) or (preserve_thinking and message.get('tool_calls')) -%}
|
| 241 |
+
{%- if thinking_text and thinking_gate -%}
|
| 242 |
+
{{- '<|channel>thought\n' + thinking_text + '\n<channel|>' -}}
|
| 243 |
+
{%- endif -%}
|
| 244 |
+
|
| 245 |
+
{%- if message.get('tool_calls') -%}
|
| 246 |
+
{%- for tool_call in message.get('tool_calls') -%}
|
| 247 |
+
{%- set function = tool_call['function'] -%}
|
| 248 |
+
{{- '<|tool_call>call:' + function['name'] + '{' -}}
|
| 249 |
+
{%- if function['arguments'] is mapping -%}
|
| 250 |
+
{%- set ns_args = namespace(found_first=false) -%}
|
| 251 |
+
{%- for key, value in function['arguments'] | dictsort -%}
|
| 252 |
+
{%- if ns_args.found_first %},{% endif -%}
|
| 253 |
+
{%- set ns_args.found_first = true -%}
|
| 254 |
+
{{- key -}}:{{- format_argument(value, escape_keys=False) -}}
|
| 255 |
+
{%- endfor -%}
|
| 256 |
+
{%- elif function['arguments'] is none -%}
|
| 257 |
+
{%- else -%}
|
| 258 |
+
{{- raise_exception(
|
| 259 |
+
"chat_template: tool_calls[].function.arguments must be a "
|
| 260 |
+
"JSON object (mapping), not a string. Deserialize arguments "
|
| 261 |
+
"before passing to the template."
|
| 262 |
+
) -}}
|
| 263 |
+
{%- endif -%}
|
| 264 |
+
{{- '}<tool_call|>' -}}
|
| 265 |
+
{%- endfor -%}
|
| 266 |
+
{%- set ns.prev_message_type = 'tool_call' -%}
|
| 267 |
+
{%- endif -%}
|
| 268 |
+
|
| 269 |
+
{%- set ns_tr_out = namespace(flag=false) -%}
|
| 270 |
+
{%- if message.get('tool_responses') -%}
|
| 271 |
+
{#- Legacy: tool_responses embedded on the assistant message (Google/Gemma native) -#}
|
| 272 |
+
{%- for tool_response in message.get('tool_responses') -%}
|
| 273 |
+
{{- format_tool_response_block(tool_response['name'] | default('unknown', true), tool_response['response']) -}}
|
| 274 |
+
{%- set ns_tr_out.flag = true -%}
|
| 275 |
+
{%- set ns.prev_message_type = 'tool_response' -%}
|
| 276 |
+
{%- endfor -%}
|
| 277 |
+
{%- elif message.get('tool_calls') -%}
|
| 278 |
+
{#- OpenAI Chat Completions: forward-scan consecutive role:tool messages -#}
|
| 279 |
+
{%- set ns_tool_scan = namespace(stopped=false) -%}
|
| 280 |
+
{%- for k in range(loop.index0 + 1, loop_messages | length) -%}
|
| 281 |
+
{%- if ns_tool_scan.stopped -%}
|
| 282 |
+
{%- elif loop_messages[k]['role'] != 'tool' -%}
|
| 283 |
+
{%- set ns_tool_scan.stopped = true -%}
|
| 284 |
+
{%- else -%}
|
| 285 |
+
{%- set follow = loop_messages[k] -%}
|
| 286 |
+
{#- Resolve tool_call_id to function name -#}
|
| 287 |
+
{%- set ns_tname = namespace(name=follow.get('name') or 'unknown') -%}
|
| 288 |
+
{%- for tc in message.get('tool_calls') -%}
|
| 289 |
+
{%- if tc.get('id') == follow.get('tool_call_id') -%}
|
| 290 |
+
{%- set ns_tname.name = tc['function']['name'] -%}
|
| 291 |
+
{%- endif -%}
|
| 292 |
+
{%- endfor -%}
|
| 293 |
+
{#- Handle content as string or content-parts array -#}
|
| 294 |
+
{%- set tool_body = follow.get('content') -%}
|
| 295 |
+
{%- if tool_body is string -%}
|
| 296 |
+
{{- format_tool_response_block(ns_tname.name, tool_body) -}}
|
| 297 |
+
{%- elif tool_body is sequence and tool_body is not string -%}
|
| 298 |
+
{%- set ns_txt = namespace(s='') -%}
|
| 299 |
+
{%- for part in tool_body -%}
|
| 300 |
+
{%- if part.get('type') == 'text' -%}
|
| 301 |
+
{%- set ns_txt.s = ns_txt.s + (part.get('text') | default('')) -%}
|
| 302 |
+
{%- endif -%}
|
| 303 |
+
{%- endfor -%}
|
| 304 |
+
{{- format_tool_response_block(ns_tname.name, ns_txt.s) -}}
|
| 305 |
+
{%- for part in tool_body -%}
|
| 306 |
+
{%- if part.get('type') in ['image', 'image_url'] -%}
|
| 307 |
+
{{- '<|image|>' -}}
|
| 308 |
+
{%- elif part.get('type') in ['audio', 'input_audio'] -%}
|
| 309 |
+
{{- '<|audio|>' -}}
|
| 310 |
+
{%- elif part.get('type') == 'video' -%}
|
| 311 |
+
{{- '<|video|>' -}}
|
| 312 |
+
{%- endif -%}
|
| 313 |
+
{%- endfor -%}
|
| 314 |
+
{%- else -%}
|
| 315 |
+
{{- format_tool_response_block(ns_tname.name, tool_body) -}}
|
| 316 |
+
{%- endif -%}
|
| 317 |
+
{%- set ns_tr_out.flag = true -%}
|
| 318 |
+
{%- set ns.prev_message_type = 'tool_response' -%}
|
| 319 |
+
{%- endif -%}
|
| 320 |
+
{%- endfor -%}
|
| 321 |
+
{%- endif -%}
|
| 322 |
+
|
| 323 |
+
{%- set captured_content -%}
|
| 324 |
+
{%- if message.get('content') is string -%}
|
| 325 |
+
{%- if role == 'model' -%}
|
| 326 |
+
{{- strip_thinking(message['content']) -}}
|
| 327 |
+
{%- else -%}
|
| 328 |
+
{{- message['content'] | trim -}}
|
| 329 |
+
{%- endif -%}
|
| 330 |
+
{%- elif message.get('content') is sequence -%}
|
| 331 |
+
{%- for item in message['content'] -%}
|
| 332 |
+
{%- if item.get('type') == 'text' -%}
|
| 333 |
+
{%- if role == 'model' -%}
|
| 334 |
+
{{- strip_thinking(item['text']) -}}
|
| 335 |
+
{%- else -%}
|
| 336 |
+
{{- item['text'] | trim -}}
|
| 337 |
+
{%- endif -%}
|
| 338 |
+
{%- elif item.get('type') in ['image', 'image_url'] -%}
|
| 339 |
+
{{- '<|image|>' -}}
|
| 340 |
+
{%- elif item.get('type') in ['audio', 'input_audio'] -%}
|
| 341 |
+
{{- '<|audio|>' -}}
|
| 342 |
+
{%- elif item.get('type') == 'video' -%}
|
| 343 |
+
{{- '<|video|>' -}}
|
| 344 |
+
{%- endif -%}
|
| 345 |
+
{%- endfor -%}
|
| 346 |
+
{%- endif -%}
|
| 347 |
+
{%- endset -%}
|
| 348 |
+
|
| 349 |
+
{{- captured_content -}}
|
| 350 |
+
{%- set has_content = captured_content | trim | length > 0 -%}
|
| 351 |
+
|
| 352 |
+
{#- Forward-scan: find next non-tool message role for continuation detection -#}
|
| 353 |
+
{%- set next_nt = namespace(role=None, found=false) -%}
|
| 354 |
+
{%- for j in range(loop.index0 + 1, loop_messages | length) -%}
|
| 355 |
+
{%- if not next_nt.found -%}
|
| 356 |
+
{%- if loop_messages[j]['role'] != 'tool' -%}
|
| 357 |
+
{%- set next_nt.role = loop_messages[j]['role'] -%}
|
| 358 |
+
{%- set next_nt.found = true -%}
|
| 359 |
+
{%- endif -%}
|
| 360 |
+
{%- endif -%}
|
| 361 |
+
{%- endfor -%}
|
| 362 |
+
|
| 363 |
+
{%- set continues_into_next = (
|
| 364 |
+
role == 'model'
|
| 365 |
+
and next_nt.role == 'assistant'
|
| 366 |
+
and (not message.get('tool_calls') or ns_tr_out.flag)
|
| 367 |
+
) -%}
|
| 368 |
+
|
| 369 |
+
{%- if ns.prev_message_type == 'tool_call' and not ns_tr_out.flag -%}
|
| 370 |
+
{{- '<|tool_response>' -}}
|
| 371 |
+
{%- elif continues_into_next -%}
|
| 372 |
+
{%- elif not (ns_tr_out.flag and not has_content and not next_nt.found) -%}
|
| 373 |
+
{{- '<turn|>\n' -}}
|
| 374 |
+
{%- endif -%}
|
| 375 |
+
|
| 376 |
+
{#- Track previous non-tool role for next iteration (avoids O(n) backward scan) -#}
|
| 377 |
+
{%- set ns.prev_non_tool_role = message['role'] -%}
|
| 378 |
+
{%- endif -%}
|
| 379 |
+
{%- endfor -%}
|
| 380 |
+
|
| 381 |
+
{%- if add_generation_prompt -%}
|
| 382 |
+
{%- if ns.prev_message_type != 'tool_response' and ns.prev_message_type != 'tool_call' -%}
|
| 383 |
+
{{- '<|turn>model\n' -}}
|
| 384 |
+
{%- if not enable_thinking -%}
|
| 385 |
+
{{- '<|channel>thought\n<channel|>' -}}
|
| 386 |
+
{%- endif -%}
|
| 387 |
+
{%- elif ns.prev_message_type == 'tool_response' and enable_thinking -%}
|
| 388 |
+
{{- '<|channel>thought\n' -}}
|
| 389 |
+
{%- endif -%}
|
| 390 |
+
{%- endif -%}
|
config.json
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Gemma4UnifiedForConditionalGeneration"
|
| 4 |
+
],
|
| 5 |
+
"audio_config": {
|
| 6 |
+
"_name_or_path": "",
|
| 7 |
+
"architectures": null,
|
| 8 |
+
"audio_embed_dim": 640,
|
| 9 |
+
"audio_samples_per_token": 640,
|
| 10 |
+
"chunk_size_feed_forward": 0,
|
| 11 |
+
"dtype": null,
|
| 12 |
+
"hidden_size": 640,
|
| 13 |
+
"id2label": {
|
| 14 |
+
"0": "LABEL_0",
|
| 15 |
+
"1": "LABEL_1"
|
| 16 |
+
},
|
| 17 |
+
"initializer_range": 0.02,
|
| 18 |
+
"is_encoder_decoder": false,
|
| 19 |
+
"label2id": {
|
| 20 |
+
"LABEL_0": 0,
|
| 21 |
+
"LABEL_1": 1
|
| 22 |
+
},
|
| 23 |
+
"model_type": "gemma4_unified_audio",
|
| 24 |
+
"output_attentions": false,
|
| 25 |
+
"output_hidden_states": false,
|
| 26 |
+
"output_proj_dims": 640,
|
| 27 |
+
"problem_type": null,
|
| 28 |
+
"return_dict": true,
|
| 29 |
+
"rms_norm_eps": 1e-06
|
| 30 |
+
},
|
| 31 |
+
"audio_token_id": 258881,
|
| 32 |
+
"boa_token_id": 256000,
|
| 33 |
+
"boi_token_id": 255999,
|
| 34 |
+
"dtype": "bfloat16",
|
| 35 |
+
"eoa_token_index": 258883,
|
| 36 |
+
"eoi_token_id": 258882,
|
| 37 |
+
"eos_token_id": [
|
| 38 |
+
1,
|
| 39 |
+
106
|
| 40 |
+
],
|
| 41 |
+
"image_token_id": 258880,
|
| 42 |
+
"initializer_range": 0.02,
|
| 43 |
+
"model_type": "gemma4_unified",
|
| 44 |
+
"text_config": {
|
| 45 |
+
"attention_bias": false,
|
| 46 |
+
"attention_dropout": 0.0,
|
| 47 |
+
"attention_k_eq_v": true,
|
| 48 |
+
"bos_token_id": 2,
|
| 49 |
+
"enable_moe_block": false,
|
| 50 |
+
"eos_token_id": 1,
|
| 51 |
+
"final_logit_softcapping": 30.0,
|
| 52 |
+
"global_head_dim": 512,
|
| 53 |
+
"head_dim": 256,
|
| 54 |
+
"hidden_activation": "gelu_pytorch_tanh",
|
| 55 |
+
"hidden_size": 3840,
|
| 56 |
+
"hidden_size_per_layer_input": 0,
|
| 57 |
+
"initializer_range": 0.02,
|
| 58 |
+
"intermediate_size": 15360,
|
| 59 |
+
"layer_types": [
|
| 60 |
+
"sliding_attention",
|
| 61 |
+
"sliding_attention",
|
| 62 |
+
"sliding_attention",
|
| 63 |
+
"sliding_attention",
|
| 64 |
+
"sliding_attention",
|
| 65 |
+
"full_attention",
|
| 66 |
+
"sliding_attention",
|
| 67 |
+
"sliding_attention",
|
| 68 |
+
"sliding_attention",
|
| 69 |
+
"sliding_attention",
|
| 70 |
+
"sliding_attention",
|
| 71 |
+
"full_attention",
|
| 72 |
+
"sliding_attention",
|
| 73 |
+
"sliding_attention",
|
| 74 |
+
"sliding_attention",
|
| 75 |
+
"sliding_attention",
|
| 76 |
+
"sliding_attention",
|
| 77 |
+
"full_attention",
|
| 78 |
+
"sliding_attention",
|
| 79 |
+
"sliding_attention",
|
| 80 |
+
"sliding_attention",
|
| 81 |
+
"sliding_attention",
|
| 82 |
+
"sliding_attention",
|
| 83 |
+
"full_attention",
|
| 84 |
+
"sliding_attention",
|
| 85 |
+
"sliding_attention",
|
| 86 |
+
"sliding_attention",
|
| 87 |
+
"sliding_attention",
|
| 88 |
+
"sliding_attention",
|
| 89 |
+
"full_attention",
|
| 90 |
+
"sliding_attention",
|
| 91 |
+
"sliding_attention",
|
| 92 |
+
"sliding_attention",
|
| 93 |
+
"sliding_attention",
|
| 94 |
+
"sliding_attention",
|
| 95 |
+
"full_attention",
|
| 96 |
+
"sliding_attention",
|
| 97 |
+
"sliding_attention",
|
| 98 |
+
"sliding_attention",
|
| 99 |
+
"sliding_attention",
|
| 100 |
+
"sliding_attention",
|
| 101 |
+
"full_attention",
|
| 102 |
+
"sliding_attention",
|
| 103 |
+
"sliding_attention",
|
| 104 |
+
"sliding_attention",
|
| 105 |
+
"sliding_attention",
|
| 106 |
+
"sliding_attention",
|
| 107 |
+
"full_attention"
|
| 108 |
+
],
|
| 109 |
+
"max_position_embeddings": 262144,
|
| 110 |
+
"model_type": "gemma4_unified_text",
|
| 111 |
+
"moe_intermediate_size": null,
|
| 112 |
+
"num_attention_heads": 16,
|
| 113 |
+
"num_experts": null,
|
| 114 |
+
"num_global_key_value_heads": 1,
|
| 115 |
+
"num_hidden_layers": 48,
|
| 116 |
+
"num_key_value_heads": 8,
|
| 117 |
+
"num_kv_shared_layers": 0,
|
| 118 |
+
"pad_token_id": 0,
|
| 119 |
+
"rms_norm_eps": 1e-06,
|
| 120 |
+
"rope_parameters": {
|
| 121 |
+
"full_attention": {
|
| 122 |
+
"partial_rotary_factor": 0.25,
|
| 123 |
+
"rope_theta": 1000000.0,
|
| 124 |
+
"rope_type": "proportional"
|
| 125 |
+
},
|
| 126 |
+
"sliding_attention": {
|
| 127 |
+
"rope_theta": 10000.0,
|
| 128 |
+
"rope_type": "default"
|
| 129 |
+
}
|
| 130 |
+
},
|
| 131 |
+
"sliding_window": 1024,
|
| 132 |
+
"tie_word_embeddings": true,
|
| 133 |
+
"top_k_experts": null,
|
| 134 |
+
"use_bidirectional_attention": "vision",
|
| 135 |
+
"use_cache": true,
|
| 136 |
+
"use_double_wide_mlp": false,
|
| 137 |
+
"vocab_size": 262144,
|
| 138 |
+
"vocab_size_per_layer_input": 262144
|
| 139 |
+
},
|
| 140 |
+
"tie_word_embeddings": true,
|
| 141 |
+
"transformers_version": "5.10.0.dev0",
|
| 142 |
+
"video_token_id": 258884,
|
| 143 |
+
"vision_config": {
|
| 144 |
+
"_name_or_path": "",
|
| 145 |
+
"architectures": null,
|
| 146 |
+
"chunk_size_feed_forward": 0,
|
| 147 |
+
"dtype": null,
|
| 148 |
+
"id2label": {
|
| 149 |
+
"0": "LABEL_0",
|
| 150 |
+
"1": "LABEL_1"
|
| 151 |
+
},
|
| 152 |
+
"initializer_range": 0.02,
|
| 153 |
+
"is_encoder_decoder": false,
|
| 154 |
+
"label2id": {
|
| 155 |
+
"LABEL_0": 0,
|
| 156 |
+
"LABEL_1": 1
|
| 157 |
+
},
|
| 158 |
+
"mm_embed_dim": 3840,
|
| 159 |
+
"mm_posemb_size": 1120,
|
| 160 |
+
"model_patch_size": 48,
|
| 161 |
+
"model_type": "gemma4_unified_vision",
|
| 162 |
+
"num_soft_tokens": 280,
|
| 163 |
+
"output_attentions": false,
|
| 164 |
+
"output_hidden_states": false,
|
| 165 |
+
"output_proj_dims": 3840,
|
| 166 |
+
"patch_size": 16,
|
| 167 |
+
"pooling_kernel_size": 3,
|
| 168 |
+
"problem_type": null,
|
| 169 |
+
"return_dict": true,
|
| 170 |
+
"rms_norm_eps": 1e-06
|
| 171 |
+
},
|
| 172 |
+
"quantization": {
|
| 173 |
+
"bits": 4,
|
| 174 |
+
"group_size": 64,
|
| 175 |
+
"mode": "affine"
|
| 176 |
+
},
|
| 177 |
+
"quantization_config": {
|
| 178 |
+
"bits": 4,
|
| 179 |
+
"group_size": 64,
|
| 180 |
+
"mode": "affine"
|
| 181 |
+
}
|
| 182 |
+
}
|
conversion.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"source": "akhilaaa3/Jev-Omni",
|
| 3 |
+
"revision": "c050d51354147985d13286cf4acf90f562f2c631",
|
| 4 |
+
"source_checkpoint": "unified/model.safetensors",
|
| 5 |
+
"bits": 4,
|
| 6 |
+
"group_size": 64,
|
| 7 |
+
"vision_precision": "bfloat16",
|
| 8 |
+
"head_precision": "float32",
|
| 9 |
+
"calibrated_after_conversion": false,
|
| 10 |
+
"weight_bytes": 6803751008
|
| 11 |
+
}
|
decision_head/weights.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:21ee232647cd6aaa61277ed11b25aee0726956ac950ae6bfbdc49cf277daf59b
|
| 3 |
+
size 3964224
|
generation_config.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
"suppress_tokens": [
|
| 11 |
+
258883,
|
| 12 |
+
258882
|
| 13 |
+
],
|
| 14 |
+
"temperature": 1.0,
|
| 15 |
+
"top_k": 64,
|
| 16 |
+
"top_p": 0.95,
|
| 17 |
+
"transformers_version": "5.10.0.dev0"
|
| 18 |
+
}
|
model.safetensors.index.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
omni_mlx/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Local experimental MLX port of the Jev-Omni decision classifier."""
|
omni_mlx/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (189 Bytes). View file
|
|
|
omni_mlx/__pycache__/__init__.cpython-313.pyc
ADDED
|
Binary file (221 Bytes). View file
|
|
|
omni_mlx/__pycache__/classifier.cpython-310.pyc
ADDED
|
Binary file (6.17 kB). View file
|
|
|
omni_mlx/__pycache__/classifier.cpython-313.pyc
ADDED
|
Binary file (10.6 kB). View file
|
|
|
omni_mlx/__pycache__/convert.cpython-310.pyc
ADDED
|
Binary file (5.35 kB). View file
|
|
|
omni_mlx/__pycache__/convert.cpython-313.pyc
ADDED
|
Binary file (10.1 kB). View file
|
|
|
omni_mlx/classifier.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Image/text classification with Jev's trained head; no vocabulary projection or generation."""
|
| 2 |
+
import argparse
|
| 3 |
+
import json
|
| 4 |
+
import statistics
|
| 5 |
+
import time
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
|
| 8 |
+
import mlx.core as mx
|
| 9 |
+
from mlx_vlm.models.gemma4_unified.processing_gemma4_unified import Gemma4UnifiedProcessor
|
| 10 |
+
from mlx_vlm.utils import load_model, prepare_inputs
|
| 11 |
+
from PIL import Image
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def prompt(state, question, options):
|
| 15 |
+
choices = "\n".join(f"{i+1}. {value}" for i, value in enumerate(options))
|
| 16 |
+
return (f"{state}\n\n---\n\nQUESTION: {question}\n\nOPTIONS:\n{choices}\n\n"
|
| 17 |
+
f"Reply with only the number of the correct option (1-{len(options)}).\n"
|
| 18 |
+
"Output a single number and nothing else.")
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def head_probabilities(hidden, head, count):
|
| 22 |
+
features = (hidden.astype(mx.float32) - head["mu"]) / head["sd"]
|
| 23 |
+
logits = features @ head["linear.weight"][:count].T + head["linear.bias"][:count]
|
| 24 |
+
return mx.softmax(logits, axis=-1)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class Classifier:
|
| 28 |
+
def __init__(self, path=".models/Jev-Omni-MLX-4bit"):
|
| 29 |
+
self.path = Path(path).resolve()
|
| 30 |
+
mx.set_cache_limit(256 * 1024**2)
|
| 31 |
+
self.model = load_model(self.path, strict=True)
|
| 32 |
+
self.processor = Gemma4UnifiedProcessor.from_pretrained(self.path, trust_remote_code=False)
|
| 33 |
+
self.head = mx.load(str(self.path / "decision_head/weights.safetensors"))
|
| 34 |
+
mx.eval(self.head)
|
| 35 |
+
self.provenance = json.loads((self.path / "conversion.json").read_text())
|
| 36 |
+
|
| 37 |
+
def predict(self, state, question, options, image=None, image_tokens=280):
|
| 38 |
+
if not 2 <= len(options) <= 20 or len(set(options)) != len(options):
|
| 39 |
+
raise ValueError("Supply 2–20 distinct options")
|
| 40 |
+
if image_tokens not in (10, 20, 35, 70, 140, 280):
|
| 41 |
+
raise ValueError("image_tokens must be 10, 20, 35, 70, 140, or 280")
|
| 42 |
+
started = time.perf_counter()
|
| 43 |
+
self.processor.image_processor.max_soft_tokens = image_tokens
|
| 44 |
+
self.processor.image_seq_length = image_tokens
|
| 45 |
+
content = ([{"type": "image"}] if image is not None else [])
|
| 46 |
+
content.append({"type": "text", "text": prompt(state, question, options)})
|
| 47 |
+
formatted = self.processor.apply_chat_template(
|
| 48 |
+
[{"role": "user", "content": content}],
|
| 49 |
+
add_generation_prompt=True, tokenize=False, enable_thinking=False,
|
| 50 |
+
)
|
| 51 |
+
if image is not None and not isinstance(image, Image.Image):
|
| 52 |
+
with Image.open(image) as opened:
|
| 53 |
+
image = opened.convert("RGB")
|
| 54 |
+
inputs = prepare_inputs(self.processor, images=[image] if image is not None else None,
|
| 55 |
+
prompts=formatted, add_special_tokens=False)
|
| 56 |
+
inputs = {k: v.astype(mx.bfloat16) if isinstance(v, mx.array) and mx.issubdtype(v.dtype, mx.floating) else v for k,v in inputs.items()}
|
| 57 |
+
ids = inputs["input_ids"]
|
| 58 |
+
if ids.shape[1] > 1024:
|
| 59 |
+
raise ValueError("Local prototype limited to 1024 input tokens to bound memory")
|
| 60 |
+
# Batch size 1, no padding. Let the decoder build its causal/sliding and vision masks.
|
| 61 |
+
extra = {k:v for k,v in inputs.items() if k not in {"input_ids", "attention_mask"}}
|
| 62 |
+
mx.eval(inputs)
|
| 63 |
+
preprocessing_ms = (time.perf_counter() - started) * 1000
|
| 64 |
+
vision_started = time.perf_counter()
|
| 65 |
+
embedded = self.model.get_input_embeddings(input_ids=ids, **extra)
|
| 66 |
+
mx.eval(embedded.inputs_embeds)
|
| 67 |
+
vision_ms = (time.perf_counter() - vision_started) * 1000
|
| 68 |
+
decoder_started = time.perf_counter()
|
| 69 |
+
hidden = self.model.language_model.model(
|
| 70 |
+
inputs_embeds=embedded.inputs_embeds,
|
| 71 |
+
per_layer_inputs=embedded.per_layer_inputs,
|
| 72 |
+
mm_token_type_ids=inputs.get("mm_token_type_ids"),
|
| 73 |
+
)
|
| 74 |
+
probabilities = head_probabilities(hidden[:, -1], self.head, len(options))[0]
|
| 75 |
+
mx.eval(probabilities)
|
| 76 |
+
decoder_ms = (time.perf_counter() - decoder_started) * 1000
|
| 77 |
+
values = probabilities.tolist()
|
| 78 |
+
if not all(0 <= value <= 1 for value in values):
|
| 79 |
+
raise RuntimeError("Non-finite classifier output")
|
| 80 |
+
elapsed_ms = (time.perf_counter() - started) * 1000
|
| 81 |
+
best = max(range(len(values)), key=values.__getitem__)
|
| 82 |
+
return {
|
| 83 |
+
"model": "akhilaaa3/Jev-Omni", "backend": "mlx", "quantization_bits": self.provenance["bits"],
|
| 84 |
+
"prediction": options[best], "prediction_index": best,
|
| 85 |
+
"probabilities": dict(zip(options, values)), "calibrated": False,
|
| 86 |
+
"metrics": {"elapsed_ms": elapsed_ms, "preprocessing_ms": preprocessing_ms,
|
| 87 |
+
"vision_ms": vision_ms, "decoder_ms": decoder_ms,
|
| 88 |
+
"input_tokens": ids.shape[1], "image_token_budget": image_tokens if image is not None else 0,
|
| 89 |
+
"peak_metal_memory_gb": mx.get_peak_memory()/1e9, "generated_tokens": 0},
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
def main():
|
| 94 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 95 |
+
parser.add_argument("--model", default=".models/Jev-Omni-MLX-4bit")
|
| 96 |
+
parser.add_argument("--image")
|
| 97 |
+
parser.add_argument("--state", default="")
|
| 98 |
+
parser.add_argument("--question", required=True)
|
| 99 |
+
parser.add_argument("--options", nargs="+", required=True)
|
| 100 |
+
parser.add_argument("--image-tokens", type=int, choices=[10, 20, 35, 70, 140, 280], default=70)
|
| 101 |
+
parser.add_argument("--repeat", type=int, default=1)
|
| 102 |
+
parser.add_argument("--output", type=Path)
|
| 103 |
+
args = parser.parse_args()
|
| 104 |
+
if args.repeat < 1:
|
| 105 |
+
parser.error("repeat must be positive")
|
| 106 |
+
start = time.perf_counter()
|
| 107 |
+
classifier = Classifier(args.model)
|
| 108 |
+
load_ms = (time.perf_counter() - start) * 1000
|
| 109 |
+
results = [classifier.predict(args.state, args.question, args.options, args.image, args.image_tokens) for _ in range(args.repeat)]
|
| 110 |
+
result = {"load_ms": load_ms, "requests": results}
|
| 111 |
+
if len(results) > 1:
|
| 112 |
+
result["warm_median_ms"] = statistics.median(r["metrics"]["elapsed_ms"] for r in results[1:])
|
| 113 |
+
rendered = json.dumps(result, ensure_ascii=False, indent=2)
|
| 114 |
+
if args.output:
|
| 115 |
+
args.output.write_text(rendered + "\n")
|
| 116 |
+
print(rendered)
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
if __name__ == "__main__":
|
| 120 |
+
main()
|
omni_mlx/convert.py
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Convert the pinned Jev-Omni unified checkpoint without loading 24 GB into RAM."""
|
| 2 |
+
import argparse
|
| 3 |
+
import gc
|
| 4 |
+
import hashlib
|
| 5 |
+
import json
|
| 6 |
+
import shutil
|
| 7 |
+
import struct
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
import mlx.core as mx
|
| 11 |
+
import numpy as np
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def remap(key):
|
| 15 |
+
key = key.removeprefix("model.")
|
| 16 |
+
if key.startswith("language_model."):
|
| 17 |
+
key = key.replace("language_model.", "language_model.model.", 1)
|
| 18 |
+
return key
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def convert(source: Path, output: Path, bits=4):
|
| 22 |
+
if output.exists():
|
| 23 |
+
raise FileExistsError(f"Refusing to overwrite {output}")
|
| 24 |
+
unified = source / "unified"
|
| 25 |
+
checkpoint = unified / "model.safetensors"
|
| 26 |
+
if not checkpoint.is_file():
|
| 27 |
+
raise FileNotFoundError(checkpoint)
|
| 28 |
+
output.mkdir(parents=True)
|
| 29 |
+
mx.set_cache_limit(128 * 1024**2)
|
| 30 |
+
weights, index, total_bytes = {}, {}, 0
|
| 31 |
+
shard_number = 0
|
| 32 |
+
|
| 33 |
+
def flush():
|
| 34 |
+
nonlocal weights, shard_number, total_bytes
|
| 35 |
+
if not weights:
|
| 36 |
+
return
|
| 37 |
+
shard_number += 1
|
| 38 |
+
name = f"weights-{shard_number:03d}.safetensors"
|
| 39 |
+
mx.save_safetensors(str(output / name), weights, metadata={"format": "mlx"})
|
| 40 |
+
total_bytes += sum(v.nbytes for v in weights.values())
|
| 41 |
+
index.update({key: name for key in weights})
|
| 42 |
+
weights = {}
|
| 43 |
+
gc.collect()
|
| 44 |
+
mx.clear_cache()
|
| 45 |
+
|
| 46 |
+
with checkpoint.open("rb") as stream:
|
| 47 |
+
header_size = struct.unpack("<Q", stream.read(8))[0]
|
| 48 |
+
header = json.loads(stream.read(header_size))
|
| 49 |
+
data_start = header_size + 8
|
| 50 |
+
for number, (key, info) in enumerate(header.items()):
|
| 51 |
+
if key == "__metadata__":
|
| 52 |
+
continue
|
| 53 |
+
if info["dtype"] != "BF16":
|
| 54 |
+
raise ValueError(f"Unexpected dtype for {key}: {info['dtype']}")
|
| 55 |
+
shape = info["shape"]
|
| 56 |
+
mapped = remap(key)
|
| 57 |
+
quantize = (
|
| 58 |
+
mapped.startswith("language_model.")
|
| 59 |
+
and mapped.endswith(".weight")
|
| 60 |
+
and len(shape) == 2
|
| 61 |
+
and shape[-1] % 64 == 0
|
| 62 |
+
)
|
| 63 |
+
stream.seek(data_start + info["data_offsets"][0])
|
| 64 |
+
if quantize:
|
| 65 |
+
packed, scales, biases = [], [], []
|
| 66 |
+
for row in range(0, shape[0], 1024):
|
| 67 |
+
rows = min(1024, shape[0] - row)
|
| 68 |
+
data = stream.read(rows * shape[1] * 2)
|
| 69 |
+
block = mx.array(np.frombuffer(data, dtype=np.uint16).copy()).view(mx.bfloat16)
|
| 70 |
+
block = block.reshape(rows, shape[1])
|
| 71 |
+
q, s, b = mx.quantize(block, group_size=64, bits=bits)
|
| 72 |
+
mx.eval(q, s, b)
|
| 73 |
+
packed.append(q)
|
| 74 |
+
scales.append(s)
|
| 75 |
+
biases.append(b)
|
| 76 |
+
prefix = mapped.removesuffix(".weight")
|
| 77 |
+
converted = {
|
| 78 |
+
prefix + ".weight": mx.concatenate(packed),
|
| 79 |
+
prefix + ".scales": mx.concatenate(scales),
|
| 80 |
+
prefix + ".biases": mx.concatenate(biases),
|
| 81 |
+
}
|
| 82 |
+
mx.eval(converted)
|
| 83 |
+
del packed, scales, biases, block, q, s, b, data
|
| 84 |
+
else:
|
| 85 |
+
length = info["data_offsets"][1] - info["data_offsets"][0]
|
| 86 |
+
data = stream.read(length)
|
| 87 |
+
converted = {mapped: mx.array(np.frombuffer(data, dtype=np.uint16).copy()).view(mx.bfloat16).reshape(shape)}
|
| 88 |
+
mx.eval(converted)
|
| 89 |
+
del data
|
| 90 |
+
weights.update(converted)
|
| 91 |
+
del converted
|
| 92 |
+
if sum(v.nbytes for v in weights.values()) >= 384 * 1024**2:
|
| 93 |
+
flush()
|
| 94 |
+
if number % 40 == 0:
|
| 95 |
+
print(f"Converted {number}/{len(header)-1} tensors; MLX peak {mx.get_peak_memory()/1e9:.2f} GB", flush=True)
|
| 96 |
+
flush()
|
| 97 |
+
config = json.loads((unified / "config.json").read_text())
|
| 98 |
+
config["quantization"] = {"bits": bits, "group_size": 64, "mode": "affine"}
|
| 99 |
+
config["quantization_config"] = config["quantization"]
|
| 100 |
+
(output / "config.json").write_text(json.dumps(config, indent=2) + "\n")
|
| 101 |
+
(output / "model.safetensors.index.json").write_text(json.dumps({"metadata": {"total_size": total_bytes}, "weight_map": index}, indent=2) + "\n")
|
| 102 |
+
for file in unified.iterdir():
|
| 103 |
+
if file.suffix in {".json", ".jinja"} and file.name != "config.json":
|
| 104 |
+
shutil.copy2(file, output / file.name)
|
| 105 |
+
|
| 106 |
+
# Only read tensors from the original small classification head; never execute pickle objects.
|
| 107 |
+
import torch
|
| 108 |
+
expected = json.loads((source / "sha256.json").read_text())["head.pt"]
|
| 109 |
+
if hashlib.sha256((source / "head.pt").read_bytes()).hexdigest() != expected:
|
| 110 |
+
raise ValueError("head.pt hash differs from the source manifest")
|
| 111 |
+
state = torch.load(source / "head.pt", map_location="cpu", weights_only=True)
|
| 112 |
+
if set(state) != {"mu", "sd", "linear.weight", "linear.bias"}:
|
| 113 |
+
raise ValueError(f"Unexpected classification head keys: {list(state)}")
|
| 114 |
+
target = output / "decision_head"
|
| 115 |
+
target.mkdir()
|
| 116 |
+
mx.save_safetensors(str(target / "weights.safetensors"), {k: mx.array(v.float().numpy()) for k,v in state.items()})
|
| 117 |
+
revision = Path("artifacts/jev-omni/source-revision.txt").read_text().strip()
|
| 118 |
+
(output / "conversion.json").write_text(json.dumps({
|
| 119 |
+
"source": "akhilaaa3/Jev-Omni", "revision": revision,
|
| 120 |
+
"source_checkpoint": "unified/model.safetensors", "bits": bits,
|
| 121 |
+
"group_size": 64, "vision_precision": "bfloat16", "head_precision": "float32",
|
| 122 |
+
"calibrated_after_conversion": False, "weight_bytes": total_bytes,
|
| 123 |
+
}, indent=2) + "\n")
|
| 124 |
+
print(f"Saved {total_bytes/1e9:.2f} GB of weights to {output}", flush=True)
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
if __name__ == "__main__":
|
| 128 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 129 |
+
parser.add_argument("--source", type=Path, default=Path(".models/Jev-Omni-source"))
|
| 130 |
+
parser.add_argument("--output", type=Path, default=Path(".models/Jev-Omni-MLX-4bit"))
|
| 131 |
+
parser.add_argument("--bits", type=int, choices=[4, 6, 8], default=4)
|
| 132 |
+
args = parser.parse_args()
|
| 133 |
+
convert(args.source, args.output, args.bits)
|
processor_config.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"audio_ms_per_token": 40,
|
| 3 |
+
"audio_seq_length": 750,
|
| 4 |
+
"feature_extractor": {
|
| 5 |
+
"audio_samples_per_token": 640,
|
| 6 |
+
"feature_extractor_type": "Gemma4UnifiedAudioFeatureExtractor",
|
| 7 |
+
"feature_size": 640,
|
| 8 |
+
"padding_side": "right",
|
| 9 |
+
"padding_value": 0.0,
|
| 10 |
+
"return_attention_mask": true,
|
| 11 |
+
"sampling_rate": 16000
|
| 12 |
+
},
|
| 13 |
+
"image_processor": {
|
| 14 |
+
"do_convert_rgb": true,
|
| 15 |
+
"do_normalize": false,
|
| 16 |
+
"do_rescale": true,
|
| 17 |
+
"do_resize": true,
|
| 18 |
+
"image_mean": [
|
| 19 |
+
0.0,
|
| 20 |
+
0.0,
|
| 21 |
+
0.0
|
| 22 |
+
],
|
| 23 |
+
"image_processor_type": "Gemma4UnifiedImageProcessor",
|
| 24 |
+
"image_std": [
|
| 25 |
+
1.0,
|
| 26 |
+
1.0,
|
| 27 |
+
1.0
|
| 28 |
+
],
|
| 29 |
+
"max_soft_tokens": 280,
|
| 30 |
+
"patch_size": 16,
|
| 31 |
+
"pooling_kernel_size": 3,
|
| 32 |
+
"resample": 3,
|
| 33 |
+
"rescale_factor": 0.00392156862745098
|
| 34 |
+
},
|
| 35 |
+
"image_seq_length": 280,
|
| 36 |
+
"processor_class": "Gemma4UnifiedProcessor",
|
| 37 |
+
"video_processor": {
|
| 38 |
+
"do_convert_rgb": true,
|
| 39 |
+
"do_normalize": true,
|
| 40 |
+
"do_rescale": true,
|
| 41 |
+
"do_resize": true,
|
| 42 |
+
"do_sample_frames": true,
|
| 43 |
+
"image_mean": [
|
| 44 |
+
0.0,
|
| 45 |
+
0.0,
|
| 46 |
+
0.0
|
| 47 |
+
],
|
| 48 |
+
"image_std": [
|
| 49 |
+
1.0,
|
| 50 |
+
1.0,
|
| 51 |
+
1.0
|
| 52 |
+
],
|
| 53 |
+
"max_soft_tokens": 70,
|
| 54 |
+
"num_frames": 32,
|
| 55 |
+
"patch_size": 16,
|
| 56 |
+
"pooling_kernel_size": 3,
|
| 57 |
+
"resample": 3,
|
| 58 |
+
"rescale_factor": 0.00392156862745098,
|
| 59 |
+
"return_metadata": false,
|
| 60 |
+
"video_processor_type": "Gemma4UnifiedVideoProcessor"
|
| 61 |
+
}
|
| 62 |
+
}
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
mlx==0.32.2
|
| 2 |
+
mlx-vlm==0.7.1
|
| 3 |
+
numpy>=2.0
|
| 4 |
+
Pillow>=10.0
|
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": false,
|
| 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": "Gemma4UnifiedProcessor",
|
| 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 |
+
}
|
verification_unified.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cases": [
|
| 3 |
+
{
|
| 4 |
+
"state": "The meeting starts at 10 AM. It is now 9 AM.",
|
| 5 |
+
"question": "Has the meeting started?",
|
| 6 |
+
"options": [
|
| 7 |
+
"Yes",
|
| 8 |
+
"No"
|
| 9 |
+
]
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
"state": "Customer: I was charged twice.\nAgent: I've refunded $29 to your card.\nCustomer: Got it. All sorted, thanks!",
|
| 13 |
+
"question": "Was the issue actually resolved?",
|
| 14 |
+
"options": [
|
| 15 |
+
"Yes",
|
| 16 |
+
"No"
|
| 17 |
+
]
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"state": "A fair six-sided die is rolled once.",
|
| 21 |
+
"question": "Which number comes up?",
|
| 22 |
+
"options": [
|
| 23 |
+
"1",
|
| 24 |
+
"2",
|
| 25 |
+
"3",
|
| 26 |
+
"4",
|
| 27 |
+
"5",
|
| 28 |
+
"6"
|
| 29 |
+
]
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"state": "An urn holds one blue, one yellow, one red and one green marble. One is drawn without looking.",
|
| 33 |
+
"question": "Which marble is drawn?",
|
| 34 |
+
"options": [
|
| 35 |
+
"Blue",
|
| 36 |
+
"Yellow",
|
| 37 |
+
"Red",
|
| 38 |
+
"Green"
|
| 39 |
+
]
|
| 40 |
+
}
|
| 41 |
+
],
|
| 42 |
+
"reference": [
|
| 43 |
+
{
|
| 44 |
+
"Yes": 0.00011235327838221565,
|
| 45 |
+
"No": 0.9998875856399536
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"Yes": 0.9399133324623108,
|
| 49 |
+
"No": 0.06008664518594742
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"1": 0.23407739400863647,
|
| 53 |
+
"2": 0.09292787313461304,
|
| 54 |
+
"3": 0.04372488334774971,
|
| 55 |
+
"4": 0.08901944011449814,
|
| 56 |
+
"5": 0.08105313032865524,
|
| 57 |
+
"6": 0.4591972529888153
|
| 58 |
+
},
|
| 59 |
+
{
|
| 60 |
+
"Blue": 0.41296717524528503,
|
| 61 |
+
"Yellow": 0.12619410455226898,
|
| 62 |
+
"Red": 0.0792793333530426,
|
| 63 |
+
"Green": 0.38155943155288696
|
| 64 |
+
}
|
| 65 |
+
],
|
| 66 |
+
"worst_abs_diff": 0.01936584711074829
|
| 67 |
+
}
|
weights-001.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fdb0abb73a0957abbf7498f16dac0eb4f9af50a40ca89b997ef8fa03a44b21ec
|
| 3 |
+
size 600638052
|
weights-002.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8ce22e87811ec5522a9de8e686d5f3d70f9867a6917bf67d8dbb4adeab293374
|
| 3 |
+
size 411516454
|
weights-003.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:89ea0ae6aec9e59f9b9b3f59b469024afd84a6264c47f6e017a08b05c9db1338
|
| 3 |
+
size 421462508
|
weights-004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a176555c9df5d762a4013586c0b5e05a6fe953faa3543a238ca3402f6ba6b4e8
|
| 3 |
+
size 411508567
|
weights-005.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cd17b1be4ab7559bde0cc43d0a719c14da4585a2cf20925303f5092233914619
|
| 3 |
+
size 410428736
|
weights-006.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f0ea901604540e01e5b217f6b0d1973f2f8755652e2622c80cd2989b3ddc96a9
|
| 3 |
+
size 415940536
|
weights-007.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:11c415ff671f0a0fd609f70aaa78140b7a08e45e6e853f82d73279a24a690bef
|
| 3 |
+
size 421462504
|
weights-008.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7891f453644091d28330466309ee95c26d59dacc3a9201e77f0b2925b78474f9
|
| 3 |
+
size 411508583
|
weights-009.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9b04affc543c23a78ab8d4a30ffe3c33aa5cc40ecbb0a43816ace2ce1e2c87b3
|
| 3 |
+
size 410428759
|
weights-010.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d8dcbae180260c5a1bbdb1dcb9f5e20b95a5fac044b1bf46c6c3224e90590ccd
|
| 3 |
+
size 415940519
|
weights-011.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9d7c18bd26c8781c66fde122dfd6969bd2d0a54b35f215c8518860b05756e092
|
| 3 |
+
size 421462482
|
weights-012.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d0c452c1abccbf8c6802b7b1f6495450d30ef6a902fa433ab066ee9fd6fd4032
|
| 3 |
+
size 411508537
|
weights-013.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:114c9752669f7f672966054e1623a9da99e4aac9f8f20055f1dd3ce466b10310
|
| 3 |
+
size 410428751
|
weights-014.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:85134bc69f35b0d89af9a4caafb2d40ce414aa72dce67cb883b20db4f69fa9c5
|
| 3 |
+
size 415940575
|
weights-015.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ed1833b879184d16efd62836578019ce68c02c9cffa23207e1813b062117f633
|
| 3 |
+
size 431416352
|
weights-016.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:46438c76c4ed86356cfb4be6b04eaeed4747194c3d1c500c8afd74a9613ef3e9
|
| 3 |
+
size 382328776
|