Image-Text-to-Text
MLX
Safetensors
English
molmo3
mlx-vlm
apple-silicon
quantized
molmo
multimodal
grounding
spatial
conversational
custom_code
4-bit precision
Run this model with HF Jobs
Run VisualInference/Molmo3-8B-MLX-4bit on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/VisualInference/Molmo3-8B-MLX-4bit. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/VisualInference/Molmo3-8B-MLX-4bit on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/VisualInference/Molmo3-8B-MLX-4bit. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Instructions to use VisualInference/Molmo3-8B-MLX-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use VisualInference/Molmo3-8B-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("VisualInference/Molmo3-8B-MLX-4bit") config = load_config("VisualInference/Molmo3-8B-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
- Atomic Chat
Upload MLX build
Browse filesFiles changed (15)
- .gitattributes+1
- LICENSEAdded+202
- README.mdAdded+88
- chat_template.jinjaAdded+64
- config.jsonAdded+123
- configuration_molmo3.pyAdded+328
- generation_config.jsonAdded+7
- model-00001-of-00002.safetensorsAdded+3
- model-00002-of-00002.safetensorsAdded+3
- model.safetensors.index.jsonAdded+1030
- modeling_molmo3.pyAdded+862
- processing_molmo3.pyAdded+1233
- processor_config.jsonAdded+69
- tokenizer.jsonAdded+3
- tokenizer_config.jsonAdded+463
32 unmodified lines3334353632 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -texttokenizer.json filter=lfs diff=lfs merge=lfs -text123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2026 Alibaba Cloud
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788---license: apache-2.0license_link: https://www.apache.org/licenses/LICENSE-2.0base_model: allenai/Molmo3-8Bbase_model_relation: quantizedlibrary_name: mlxpipeline_tag: image-text-to-textlanguage:- entags:- mlx- mlx-vlm- apple-silicon- quantized- molmo- molmo3- multimodal- grounding- spatial---
# Molmo3-8B for MLX, 4bit
[Molmo3-8B](https://huggingface.co/allenai/Molmo3-8B) is Ai2's open vision-language model for spatial and 3Dunderstanding and grounding (pointing, segmentation masks, depth, 3D boxes), built on Qwen3-8B and SigLIP 2(Apache 2.0). This repository is a 4-bit build for Apple silicon in[mlx-vlm](https://github.com/Neywa-Labs/mlx-vlm) format: 6.1 GiB of weights, for Macs with 16 GB (12 GB tight) of memory.The decoder's linear layers and output head are quantized to 4 bits at group size 64; the image encoder,connector, pointing and segmentation heads stay in bf16, as mlx-vlm's Molmo3 port does by design.
| Build | Weights | Bits per weight | Smallest Mac | Decode speed | Peak memory (smoke test) ||---|---|---|---|---|---|| [original](https://huggingface.co/allenai/Molmo3-8B) (fp32 checkpoint) | 32.4 GiB (16.2 GiB as bf16) | 32 | 24 GB in bf16 | not run here | || **4bit** (this repo) | 6.1 GiB | 5.99 | 16 GB (12 GB tight) | 33.7 tok/s | 8.0 GiB || [8bit](https://huggingface.co/VisualInference/Molmo3-8B-MLX-8bit) | 9.6 GiB | 9.47 | 16 GB (24 GB comfortable) | 22.1 tok/s | 11.5 GiB |
Measured on a Mac mini (M4 Pro, 48 GB), greedy decoding, mlx-vlm 0.8.3. Decode speed is from a word-problem answer;peak memory is the highest across the smoke prompts (each under 1k prompt tokens plus at most one image).Held-out loss against the original and task checks: coming. No other numbers are claimed.
The smaller sibling has its own build: [Molmo3-4B-MLX-4bit](https://huggingface.co/VisualInference/Molmo3-4B-MLX-4bit).
## Use
Molmo3 support arrived in mlx-vlm 0.8.3 (pull request 2902).
```shpip install -U "mlx-vlm>=0.8.3"mlx_vlm.generate --model VisualInference/Molmo3-8B-MLX-4bit --image photo.jpg \ --prompt "Describe this image." --max-tokens 256```
Pointing and masks come from separate grounding heads, so decode them with the generation's cache:
```pythonfrom PIL import Imagefrom mlx_vlm import generate, loadfrom mlx_vlm.prompt_utils import apply_chat_template
model, processor = load("VisualInference/Molmo3-8B-MLX-4bit", trust_remote_code=False)image = Image.open("photo.jpg").convert("RGB")cache = model.make_cache()prompt = apply_chat_template(processor, model.config, "Point to the spoon.", num_images=1)result = generate(model, processor, prompt, image=[image], prompt_cache=cache, max_tokens=128, temperature=0, verbose=False)print(processor.decode_text(result.text, model.grounding(cache)[0], images=[image]))```
`Segment the spoon.` returns a COCO RLE mask instead. Use a fresh cache for each multimodal prompt. The mlx-vlm portdoes not support chunked prefill, prefix-cache reuse, speculative decoding or KV-cache quantization for this model.The 3D outputs (depth, normals, 3D boxes) decode through the same processor but were not checked here.
## Smoke test
Greedy, this build, Mac mini (M4 Pro, 48 GB):
- **code** (90 tokens): `python def merge_intervals(intervals): if not intervals: return [] intervals.sort() merged = [intervals[0]] for current in intervals[1:]: last = merged[-1] if current[0] <= last[1]: merged[-1] = [last[0], max …`- **reasoning** (138 tokens): `To find the change Maya gets, we need to calculate the total cost of the pencils and subtract it from the $5 bill. Since the pencils are sold at 3 for $0.75, the cost of one pencil is $0.75 / 3 = $0.25. Maya buys 14 pencils, so the total cost is 14 x $0.25 = …`- **multilingual** (29 tokens): `**Spanish:** La biblioteca abre a las nueve de la mañana. **Chinese:** 图书馆在早上九点开放。`- **image** (167 tokens): `The image contains two main elements: text and shapes. At the top of the image, there's bold black text that reads "MLX 42". This text is centered horizontally and positioned near the top edge of the image. Below the text, there are two shapes: 1. A red squ …`- **point** (16 tokens): `<points coords="<|POINT_PATCH|><|POINT_SUBPATCH|><|POINT_LOC|>1<|POINT_PATCH|>">blue circle</points>` Decoded point: (510, 288) in a 640×400 image; the circle spans x 420-600, y 200-380.
## License and use
Apache 2.0, as the original. Ai2 notes the model is trained on third-party datasets, some of them for academic andnon-commercial research use only, and is intended for research and educational use under its[Responsible Use Guidelines](https://allenai.org/responsible-use). Check the[original card](https://huggingface.co/allenai/Molmo3-8B) before other use.12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364{#- Count the images of the conversation. If there are more than one, each is prefixed with "Image <n>" -#}{%- set counts = namespace(images=0, image=0) -%}{%- for message in messages -%} {%- if message['content'] is not string -%} {%- for item in message['content'] -%} {%- if item['type'] == 'image' -%} {%- set counts.images = counts.images + 1 -%} {%- endif -%} {%- endfor -%} {%- endif -%}{%- endfor -%}
{%- for message in messages -%} {%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) or message['role'] not in ['user', 'assistant'] -%} {{- raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') -}} {%- endif -%}
{%- set text = namespace(value='') -%} {%- if message['content'] is string -%} {%- set text.value = message['content'] -%} {%- else -%} {%- for item in message['content'] -%} {%- if item['type'] == 'image' -%} {%- set counts.image = counts.image + 1 -%} {%- if counts.images > 1 -%} {%- set text.value = text.value + 'Image ' + counts.image|string -%} {%- endif -%} {%- set text.value = text.value + '<|image|>' -%} {%- elif item['type'] == 'video' -%} {%- set text.value = text.value + '<|video|>' -%} {%- elif item['type'] == 'text' -%} {%- if item['style'] is defined and item['style'] -%} {%- set text.value = text.value + item['style'] + ': ' + item['text'] -%} {%- else -%} {%- set text.value = text.value + item['text'] -%} {%- endif -%} {%- elif item['type'] == 'points' -%} {%- set coords = namespace(value='') -%} {%- for coordinate in item['coordinates'] -%} {%- set coords.value = coords.value + '<|POINT_PATCH|><|POINT_SUBPATCH|><|POINT_LOC|>' + loop.index|string -%} {%- endfor -%} {%- set tag = '<points coords="' + coords.value + '<|POINT_PATCH|>"' -%} {%- if item['label'] is defined and item['label'] -%} {%- set text.value = text.value + tag + '>' + item['label'] + '</points>' -%} {%- else -%} {%- set text.value = text.value + tag + '/>' -%} {%- endif -%} {%- endif -%} {%- endfor -%} {%- endif -%}
{%- if message['role'] == 'user' -%} {%- if not loop.first -%} {{- '<|im_end|>\n' -}} {%- endif -%} {{- '<|im_start|>user\n' + text.value + '<|im_end|>\n' -}} {%- else -%} {{- '<|im_start|>assistant\n' + text.value -}} {%- endif -%}{%- endfor -%}
{%- if add_generation_prompt -%} {{- '<|im_start|>assistant\n' -}}{%- endif -%}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123{ "adapter_config": { "attention_bias": true, "attention_dropout": 0.0, "head_dim": 72, "hidden_act": "silu", "hidden_size": 1152, "initializer_range": 0.02, "intermediate_size": 12288, "mlp_bias": false, "model_type": "molmo3_adapter", "num_attention_heads": 16, "num_key_value_heads": 16, "num_pooling_positions": 9, "text_hidden_size": 4096, "vision_feature_layer": [ 24, 18 ] }, "architectures": [ "Molmo3ForConditionalGeneration" ], "auto_map": { "AutoConfig": "configuration_molmo3.Molmo3Config", "AutoModelForImageTextToText": "modeling_molmo3.Molmo3ForConditionalGeneration" }, "center_patch_id": 151954, "corresponding_patch_id": 151955, "do_sample": false, "dtype": "bfloat16", "eos_token_id": 151645, "frame_end_token_id": 151944, "frame_start_token_id": 151943, "generation_config": { "do_sample": false, "eos_token_id": 151645, "pad_token_id": 151643, "transformers_version": "5.2.0", "max_new_tokens": 2048 }, "image_col_id": 151939, "image_end_token_id": 151937, "image_low_res_id": 151942, "image_patch_id": 151938, "image_start_token_id": 151936, "initializer_range": 0.02, "low_res_image_start_token_id": 151940, "mask_diffusion_steps": 2, "model_type": "molmo3", "patch_position_embedding_size": 512, "point_loc_id": 151952, "point_patch_id": 151950, "point_query_dims": [ 512, 512, 32 ], "point_subpatch_id": 151951, "pointer_rope_theta": 50000.0, "quantization": { "group_size": 64, "bits": 4, "mode": "affine" }, "quantization_config": { "group_size": 64, "bits": 4, "mode": "affine" }, "seg_mask_id": 151953, "subpatch_conv_kernel": 3, "subpatch_hidden_size": 512, "subpatch_location_size": 4, "text_config": { "attention_bias": false, "attention_dropout": 0.0, "eos_token_id": 151645, "head_dim": 128, "hidden_act": "silu", "hidden_size": 4096, "initializer_range": 0.02, "intermediate_size": 12288, "max_position_embeddings": 16384, "model_type": "molmo3_text", "num_attention_heads": 32, "num_hidden_layers": 36, "num_key_value_heads": 8, "pad_token_id": 151643, "qk_norm_type": "qwen3", "rms_norm_eps": 1e-06, "rope_parameters": { "rope_theta": 1000000.0, "rope_type": "default" }, "tie_word_embeddings": false, "use_cache": true, "vocab_size": 152064 }, "tie_word_embeddings": false, "transformers_version": "5.25.0.dev0", "vision_config": { "attention_bias": true, "attention_dropout": 0.0, "head_dim": 72, "hidden_act": "gelu_pytorch_tanh", "hidden_size": 1152, "image_size": [ 378, 378 ], "initializer_range": 0.02, "intermediate_size": 4304, "layer_norm_eps": 1e-06, "model_type": "molmo3_vision", "num_attention_heads": 16, "num_channels": 3, "num_hidden_layers": 25, "num_key_value_heads": 16, "num_position_embeddings": 729, "patch_size": 14 }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328"""Molmo3 configuration.
Field names follow the transformers-native Molmo3 config; configs written by older versions ofthis repo (`vit_config`, `vit_layers`, ...) still load. Only the architecture of the Molmo3 4Band 8B stage-2 checkpoints is supported: settings it fixes are checked here and hard-coded in the model."""from typing import Optional
from transformers import PretrainedConfig
def _rename(kwargs: dict, old: str, new: str): """Move a legacy key to its current name.""" if old in kwargs: value = kwargs.pop(old) kwargs.setdefault(new, value)
def _require(name: str, value, expected): if value != expected: raise ValueError(f"{name}={value!r} is not supported (only {expected!r})")
class Molmo3VisionConfig(PretrainedConfig): """SigLIP2 vision encoder, truncated after the deepest layer the adapter reads.""" model_type = "molmo3_vision" base_config_key = "vision_config"
def __init__( self, hidden_size: int = 1152, intermediate_size: int = 4304, num_hidden_layers: int = 25, num_attention_heads: int = 16, num_key_value_heads: Optional[int] = None, head_dim: int = 72, hidden_act: str = "gelu_pytorch_tanh", layer_norm_eps: float = 1e-6, image_size=(378, 378), patch_size: int = 14, num_channels: int = 3, num_position_embeddings: Optional[int] = None, attention_bias: bool = True, attention_dropout: float = 0.0, initializer_range: float = 0.02, **kwargs, ): kwargs.pop("model_type", None) super().__init__(**kwargs) self.hidden_size = hidden_size self.intermediate_size = intermediate_size self.num_hidden_layers = num_hidden_layers self.num_attention_heads = num_attention_heads self.num_key_value_heads = num_key_value_heads or num_attention_heads self.head_dim = head_dim self.hidden_act = hidden_act self.layer_norm_eps = layer_norm_eps self.image_size = [image_size, image_size] if isinstance(image_size, int) else list(image_size) self.patch_size = patch_size self.num_channels = num_channels self.num_position_embeddings = num_position_embeddings or self.grid_size ** 2 self.attention_bias = attention_bias self.attention_dropout = attention_dropout self.initializer_range = initializer_range _require("vision_config.image_size", self.image_size[0], self.image_size[1]) _require("vision_config.num_position_embeddings", self.num_position_embeddings, self.grid_size ** 2) _require("vision_config.num_key_value_heads", self.num_key_value_heads, num_attention_heads) _require("vision_config.num_channels", num_channels, 3) _require("vision_config.attention_bias", attention_bias, True)
@property def grid_size(self) -> int: return self.image_size[0] // self.patch_size
class Molmo3AdapterConfig(PretrainedConfig): """Attention pooling + MLP projector that maps ViT features to LLM tokens.""" model_type = "molmo3_adapter" base_config_key = "adapter_config"
def __init__( self, vision_feature_layer: tuple = (24, 18), hidden_size: Optional[int] = None, num_attention_heads: int = 16, num_key_value_heads: Optional[int] = None, head_dim: int = 72, intermediate_size: int = 9728, hidden_act: str = "silu", num_pooling_positions: int = 9, text_hidden_size: int = 2560, attention_bias: bool = True, mlp_bias: bool = False, attention_dropout: float = 0.0, initializer_range: float = 0.02, **kwargs, ): kwargs.pop("model_type", None) _rename(kwargs, "max_pooling_size", "num_pooling_positions") num_pooling_positions = kwargs.pop("num_pooling_positions", num_pooling_positions) # Legacy `vit_layers` may be negative; Molmo3Config makes them absolute vision_feature_layer = kwargs.pop("vit_layers", vision_feature_layer) super().__init__(**kwargs) self.vision_feature_layer = list(vision_feature_layer) self.hidden_size = hidden_size or num_attention_heads * head_dim self.num_attention_heads = num_attention_heads self.num_key_value_heads = num_key_value_heads or num_attention_heads self.head_dim = head_dim self.intermediate_size = intermediate_size self.hidden_act = hidden_act # Rows of the learned per-slot bias over the pooling window (3x3 video pooling) self.num_pooling_positions = num_pooling_positions self.text_hidden_size = text_hidden_size self.attention_bias = attention_bias self.mlp_bias = mlp_bias self.attention_dropout = attention_dropout self.initializer_range = initializer_range _require("adapter_config.hidden_size", self.hidden_size, num_attention_heads * head_dim) _require("adapter_config.num_key_value_heads", self.num_key_value_heads, num_attention_heads) _require("adapter_config.attention_bias", attention_bias, True) _require("adapter_config.mlp_bias", mlp_bias, False)
class Molmo3TextConfig(PretrainedConfig): """Qwen3-style decoder.
`vocab_size` counts every embedding row; the last `additional_vocab_size` rows (the special tokens) are stored as a separate `new_embedding` weight. """ additional_vocab_size = 128 model_type = "molmo3_text" base_config_key = "text_config" keys_to_ignore_at_inference = ["past_key_values"]
def __init__( self, hidden_size: int = 2560, num_attention_heads: int = 32, num_key_value_heads: int = 8, head_dim: int = 128, vocab_size: int = 152064, num_hidden_layers: int = 36, intermediate_size: int = 9728, hidden_act: str = "silu", max_position_embeddings: int = 16384, rope_parameters: Optional[dict] = None, rms_norm_eps: float = 1e-6, qk_norm_type: str = "qwen3", attention_bias: bool = False, attention_dropout: float = 0.0, initializer_range: float = 0.02, use_cache: bool = True, **kwargs, ): kwargs.pop("model_type", None) kwargs.pop("tie_word_embeddings", None) _rename(kwargs, "layer_norm_eps", "rms_norm_eps") rms_norm_eps = kwargs.pop("rms_norm_eps", rms_norm_eps) _require("text_config.additional_vocab_size", kwargs.pop("additional_vocab_size", 128), 128) legacy_theta = kwargs.pop("rope_theta", None) if rope_parameters is None: rope_parameters = {"rope_theta": legacy_theta or 5000000.0, "rope_type": "default"} super().__init__(tie_word_embeddings=False, **kwargs) self.hidden_size = hidden_size self.num_attention_heads = num_attention_heads self.num_key_value_heads = num_key_value_heads self.head_dim = head_dim self.vocab_size = vocab_size self.num_hidden_layers = num_hidden_layers self.intermediate_size = intermediate_size self.hidden_act = hidden_act self.max_position_embeddings = max_position_embeddings self.rope_parameters = dict(rope_parameters) self.rms_norm_eps = rms_norm_eps self.qk_norm_type = qk_norm_type self.attention_bias = attention_bias self.attention_dropout = attention_dropout self.initializer_range = initializer_range self.use_cache = use_cache _require("text_config.rope_type", self.rope_parameters.get("rope_type", "default"), "default") _require("text_config.qk_norm_type", qk_norm_type, "qwen3") _require("text_config.attention_bias", attention_bias, False)
@property def rope_theta(self) -> float: return self.rope_parameters["rope_theta"]
@rope_theta.setter def rope_theta(self, value: float): # vLLM assigns it while normalizing rope settings self.rope_parameters["rope_theta"] = value
@property def base_vocab_size(self) -> int: return self.vocab_size - self.additional_vocab_size
class Molmo3Config(PretrainedConfig): model_type = "molmo3" sub_configs = { "text_config": Molmo3TextConfig, "vision_config": Molmo3VisionConfig, "adapter_config": Molmo3AdapterConfig, }
def __init__( self, vision_config=None, adapter_config=None, text_config=None, # Visual token ids image_patch_id: Optional[int] = None, image_low_res_id: Optional[int] = None, image_col_id: Optional[int] = None, image_start_token_id: Optional[int] = None, low_res_image_start_token_id: Optional[int] = None, image_end_token_id: Optional[int] = None, frame_start_token_id: Optional[int] = None, frame_end_token_id: Optional[int] = None, # Grounding token ids point_patch_id: Optional[int] = None, point_subpatch_id: Optional[int] = None, point_loc_id: Optional[int] = None, seg_mask_id: Optional[int] = None, center_patch_id: Optional[int] = None, corresponding_patch_id: Optional[int] = None, # deprecated: never generated # Grounding head dimensions point_query_dims: tuple = (512, 512, 32), subpatch_location_size: int = 4, subpatch_hidden_size: int = 512, subpatch_conv_kernel: int = 3, patch_position_embedding_size: int = 512, mask_diffusion_steps: int = 2, pointer_rope_theta: float = 50000.0, # Ground only when the model's probability that anything is present exceeds this presence_threshold: float = 0.5, initializer_range: float = 0.02, **kwargs, ): kwargs.pop("tie_word_embeddings", None) use_cache = kwargs.pop("use_cache", True) _rename(kwargs, "patch_location", "subpatch_location_size") _rename(kwargs, "subpatch_hidden", "subpatch_hidden_size") subpatch_location_size = kwargs.pop("subpatch_location_size", subpatch_location_size) subpatch_hidden_size = kwargs.pop("subpatch_hidden_size", subpatch_hidden_size) legacy_vision = kwargs.pop("vit_config", None) if vision_config is None: vision_config = legacy_vision super().__init__(tie_word_embeddings=False, **kwargs)
def build(cls, value): if value is None: return cls() return cls(**value) if isinstance(value, dict) else value
legacy_text = isinstance(text_config, dict) and "rope_theta" in text_config self.vision_config = build(Molmo3VisionConfig, vision_config) self.adapter_config = build(Molmo3AdapterConfig, adapter_config) self.text_config = build(Molmo3TextConfig, text_config)
if legacy_vision is not None: # Old configs list the full 27-layer ViT and index it from the end n = self.vision_config.num_hidden_layers layers = [l % n for l in self.adapter_config.vision_feature_layer] self.adapter_config.vision_feature_layer = layers self.vision_config.num_hidden_layers = max(layers) + 1 if legacy_text: # Old configs counted `vocab_size` without the additional rows self.text_config.vocab_size += self.text_config.additional_vocab_size self.adapter_config.text_hidden_size = self.text_config.hidden_size
self.image_patch_id = image_patch_id self.image_low_res_id = image_low_res_id self.image_col_id = image_col_id self.image_start_token_id = image_start_token_id self.low_res_image_start_token_id = low_res_image_start_token_id self.image_end_token_id = image_end_token_id self.frame_start_token_id = frame_start_token_id self.frame_end_token_id = frame_end_token_id
self.point_patch_id = point_patch_id self.point_subpatch_id = point_subpatch_id self.point_loc_id = point_loc_id self.seg_mask_id = seg_mask_id self.center_patch_id = center_patch_id self.corresponding_patch_id = corresponding_patch_id
self.point_query_dims = list(point_query_dims) self.subpatch_location_size = subpatch_location_size self.subpatch_hidden_size = subpatch_hidden_size self.subpatch_conv_kernel = subpatch_conv_kernel self.patch_position_embedding_size = patch_position_embedding_size self.mask_diffusion_steps = mask_diffusion_steps self.pointer_rope_theta = pointer_rope_theta self.presence_threshold = presence_threshold self.initializer_range = initializer_range self.use_cache = use_cache _require("patch_position_embedding_size", patch_position_embedding_size, 512) if max(self.adapter_config.vision_feature_layer) >= self.vision_config.num_hidden_layers: raise ValueError(f"vision_feature_layer {self.adapter_config.vision_feature_layer} is past " f"the {self.vision_config.num_hidden_layers} ViT layers")
@property def vision_token_ids(self) -> list: """Tokens that attend bidirectionally within a contiguous run.""" return [self.image_patch_id, self.image_low_res_id, self.image_col_id, self.image_start_token_id, self.low_res_image_start_token_id, self.image_end_token_id, self.frame_start_token_id, self.frame_end_token_id]
@property def grounding_token_ids(self) -> list: return [self.point_patch_id, self.point_subpatch_id, self.point_loc_id, self.seg_mask_id, self.center_patch_id]
@property def vocab_size(self) -> int: return self.text_config.vocab_size
@property def hidden_size(self) -> int: return self.text_config.hidden_size
@property def num_hidden_layers(self) -> int: return self.text_config.num_hidden_layers
__all__ = ["Molmo3Config", "Molmo3VisionConfig", "Molmo3AdapterConfig", "Molmo3TextConfig"]1234567{ "do_sample": false, "eos_token_id": 151645, "pad_token_id": 151643, "transformers_version": "5.2.0", "max_new_tokens": 2048}123version https://git-lfs.github.com/spec/v1oid sha256:0d24660586aa1a707e598784acaf089817d2e0a802c0fcf636e08efb88ccebf6size 5359861741123version https://git-lfs.github.com/spec/v1oid sha256:4bdb523bfa54f5fc6e82e50dac0b30152f59f96bf46cf07801debc6ff4da34fdsize 11507203351234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030{ "metadata": { "total_size": 6510462976 }, "weight_map": { "lm_head.biases": "model-00002-of-00002.safetensors", "lm_head.scales": "model-00002-of-00002.safetensors", "lm_head.weight": "model-00002-of-00002.safetensors", "model.build_location_embeddings.weight": "model-00002-of-00002.safetensors", "model.build_subpatch_embeddings.bias": "model-00002-of-00002.safetensors", "model.build_subpatch_embeddings.weight": "model-00002-of-00002.safetensors", "model.connector.image_pooling_2d.wk.bias": "model-00002-of-00002.safetensors", "model.connector.image_pooling_2d.wk.weight": "model-00002-of-00002.safetensors", "model.connector.image_pooling_2d.wq.bias": "model-00002-of-00002.safetensors", "model.connector.image_pooling_2d.wq.weight": "model-00002-of-00002.safetensors", "model.connector.image_pooling_2d.wv.bias": "model-00002-of-00002.safetensors", "model.connector.image_pooling_2d.wv.weight": "model-00002-of-00002.safetensors", "model.connector.image_projector.w1.weight": "model-00002-of-00002.safetensors", "model.connector.image_projector.w2.weight": "model-00002-of-00002.safetensors", "model.connector.image_projector.w3.weight": "model-00002-of-00002.safetensors", "model.connector.positional_embeddings.bias": "model-00002-of-00002.safetensors", "model.loc_q.bias": "model-00002-of-00002.safetensors", "model.loc_q.weight": "model-00002-of-00002.safetensors", "model.mask_affinity.conv.bias": "model-00002-of-00002.safetensors", "model.mask_affinity.conv.weight": "model-00002-of-00002.safetensors", "model.mask_q.bias": "model-00002-of-00002.safetensors", "model.mask_q.weight": "model-00002-of-00002.safetensors", "model.patch_k.bias": "model-00002-of-00002.safetensors", "model.patch_k.weight": "model-00002-of-00002.safetensors", "model.patch_q.bias": "model-00002-of-00002.safetensors", "model.patch_q.weight": "model-00002-of-00002.safetensors", "model.subpatch_conv.conv.bias": "model-00002-of-00002.safetensors", "model.subpatch_conv.conv.weight": "model-00002-of-00002.safetensors", "model.subpatch_conv.proj.bias": "model-00002-of-00002.safetensors", "model.subpatch_conv.proj.weight": "model-00002-of-00002.safetensors", "model.subpatch_hidden.bias": "model-00002-of-00002.safetensors", "model.subpatch_hidden.weight": "model-00002-of-00002.safetensors", "model.subpatch_loc_k.w_in1.weight": "model-00002-of-00002.safetensors", "model.subpatch_loc_k.w_in2.weight": "model-00002-of-00002.safetensors", "model.subpatch_loc_k.w_out.bias": "model-00002-of-00002.safetensors", "model.subpatch_loc_k.w_out.weight": "model-00002-of-00002.safetensors", "model.subpatch_pos_embed.proj.bias": "model-00002-of-00002.safetensors", "model.subpatch_pos_embed.proj.weight": "model-00002-of-00002.safetensors", "model.subpatch_q.bias": "model-00002-of-00002.safetensors", "model.subpatch_q.weight": "model-00002-of-00002.safetensors", "model.transformer.blocks.0.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.0.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.0.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.0.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.0.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.0.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.0.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.0.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.0.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.0.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.0.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.0.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.0.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.0.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.0.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.0.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.1.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.1.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.1.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.1.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.1.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.1.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.1.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.1.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.1.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.1.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.1.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.1.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.1.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.1.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.1.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.1.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.10.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.10.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.10.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.10.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.10.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.10.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.10.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.10.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.10.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.10.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.10.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.10.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.10.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.10.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.10.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.10.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.11.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.11.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.11.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.11.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.11.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.11.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.11.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.11.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.11.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.11.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.11.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.11.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.11.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.11.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.11.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.11.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.12.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.12.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.12.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.12.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.12.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.12.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.12.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.12.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.12.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.12.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.12.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.12.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.12.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.12.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.12.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.12.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.13.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.13.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.13.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.13.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.13.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.13.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.13.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.13.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.13.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.13.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.13.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.13.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.13.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.13.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.13.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.13.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.14.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.14.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.14.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.14.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.14.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.14.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.14.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.14.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.14.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.14.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.14.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.14.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.14.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.14.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.14.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.14.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.15.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.15.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.15.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.15.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.15.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.15.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.15.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.15.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.15.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.15.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.15.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.15.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.15.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.15.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.15.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.15.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.16.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.16.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.16.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.16.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.16.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.16.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.16.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.16.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.16.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.16.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.16.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.16.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.16.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.16.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.16.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.16.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.17.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.17.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.17.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.17.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.17.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.17.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.17.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.17.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.17.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.17.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.17.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.17.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.17.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.17.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.17.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.17.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.18.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.18.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.18.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.18.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.18.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.18.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.18.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.18.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.18.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.18.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.18.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.18.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.18.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.18.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.18.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.18.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.19.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.19.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.19.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.19.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.19.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.19.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.19.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.19.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.19.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.19.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.19.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.19.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.19.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.19.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.19.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.19.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.2.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.2.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.2.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.2.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.2.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.2.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.2.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.2.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.2.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.2.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.2.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.2.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.2.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.2.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.2.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.2.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.20.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.20.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.20.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.20.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.20.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.20.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.20.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.20.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.20.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.20.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.20.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.20.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.20.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.20.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.20.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.20.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.21.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.21.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.21.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.21.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.21.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.21.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.21.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.21.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.21.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.21.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.21.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.21.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.21.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.21.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.21.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.21.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.22.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.22.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.22.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.22.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.22.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.22.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.22.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.22.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.22.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.22.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.22.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.22.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.22.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.22.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.22.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.22.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.23.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.23.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.23.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.23.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.23.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.23.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.23.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.23.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.23.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.23.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.23.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.23.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.23.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.23.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.23.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.23.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.24.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.24.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.24.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.24.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.24.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.24.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.24.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.24.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.24.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.24.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.24.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.24.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.24.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.24.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.24.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.24.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.25.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.25.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.25.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.25.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.25.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.25.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.25.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.25.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.25.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.25.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.25.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.25.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.25.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.25.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.25.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.25.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.26.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.26.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.26.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.26.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.26.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.26.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.26.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.26.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.26.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.26.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.26.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.26.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.26.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.26.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.26.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.26.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.27.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.27.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.27.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.27.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.27.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.27.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.27.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.27.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.27.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.27.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.27.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.27.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.27.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.27.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.27.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.27.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.28.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.28.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.28.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.28.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.28.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.28.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.28.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.28.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.28.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.28.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.28.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.28.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.28.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.28.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.28.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.28.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.29.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.29.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.29.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.29.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.29.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.29.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.29.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.29.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.29.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.29.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.29.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.29.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.29.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.29.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.29.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.29.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.3.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.3.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.3.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.3.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.3.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.3.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.3.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.3.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.3.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.3.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.3.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.3.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.3.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.3.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.3.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.3.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.30.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.30.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.30.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.30.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.30.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.30.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.30.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.30.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.30.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.30.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.30.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.30.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.30.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.30.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.30.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.30.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.31.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.31.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.31.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.31.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.31.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.31.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.31.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.31.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.31.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.31.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.31.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.31.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.31.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.31.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.31.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.31.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.32.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.32.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.32.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.32.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.32.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.32.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.32.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.32.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.32.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.32.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.32.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.32.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.32.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.32.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.32.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.32.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.33.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.33.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.33.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.33.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.33.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.33.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.33.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.33.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.33.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.33.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.33.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.33.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.33.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.33.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.33.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.33.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.34.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.34.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.34.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.34.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.34.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.34.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.34.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.34.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.34.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.34.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.34.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.34.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.34.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.34.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.34.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.34.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.35.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.35.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.35.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.35.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.35.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.35.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.35.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.35.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.35.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.35.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.35.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.35.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.35.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.35.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.35.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.35.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.4.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.4.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.4.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.4.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.4.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.4.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.4.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.4.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.4.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.4.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.4.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.4.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.4.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.4.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.4.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.4.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.5.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.5.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.5.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.5.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.5.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.5.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.5.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.5.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.5.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.5.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.5.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.5.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.5.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.5.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.5.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.5.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.6.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.6.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.6.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.6.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.6.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.6.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.6.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.6.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.6.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.6.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.6.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.6.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.6.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.6.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.6.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.6.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.7.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.7.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.7.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.7.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.7.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.7.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.7.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.7.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.7.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.7.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.7.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.7.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.7.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.7.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.7.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.7.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.8.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.8.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.8.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.8.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.8.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.8.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.8.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.8.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.8.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.8.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.8.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.8.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.8.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.8.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.8.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.8.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.9.att_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.9.att_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.9.att_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.9.attn_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.9.attn_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.9.attn_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.9.attn_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.9.ff_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.9.ff_out.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.9.ff_out.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.9.ff_out.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.9.ff_proj.biases": "model-00001-of-00002.safetensors", "model.transformer.blocks.9.ff_proj.scales": "model-00001-of-00002.safetensors", "model.transformer.blocks.9.ff_proj.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.9.k_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.blocks.9.q_norm.weight": "model-00001-of-00002.safetensors", "model.transformer.ln_f.weight": "model-00001-of-00002.safetensors", "model.transformer.wte.embedding": "model-00001-of-00002.safetensors", "model.transformer.wte.new_embedding": "model-00001-of-00002.safetensors", "model.vit.patch_embedding.bias": "model-00001-of-00002.safetensors", "model.vit.patch_embedding.weight": "model-00001-of-00002.safetensors", "model.vit.positional_embedding": "model-00001-of-00002.safetensors", "model.vit.resblocks.0.attention.wk.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.0.attention.wk.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.0.attention.wo.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.0.attention.wo.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.0.attention.wq.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.0.attention.wq.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.0.attention.wv.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.0.attention.wv.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.0.attention_norm.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.0.attention_norm.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.0.feed_forward.w1.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.0.feed_forward.w1.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.0.feed_forward.w2.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.0.feed_forward.w2.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.0.ffn_norm.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.0.ffn_norm.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.1.attention.wk.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.1.attention.wk.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.1.attention.wo.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.1.attention.wo.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.1.attention.wq.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.1.attention.wq.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.1.attention.wv.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.1.attention.wv.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.1.attention_norm.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.1.attention_norm.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.1.feed_forward.w1.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.1.feed_forward.w1.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.1.feed_forward.w2.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.1.feed_forward.w2.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.1.ffn_norm.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.1.ffn_norm.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.10.attention.wk.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.10.attention.wk.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.10.attention.wo.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.10.attention.wo.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.10.attention.wq.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.10.attention.wq.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.10.attention.wv.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.10.attention.wv.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.10.attention_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.10.attention_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.10.feed_forward.w1.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.10.feed_forward.w1.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.10.feed_forward.w2.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.10.feed_forward.w2.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.10.ffn_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.10.ffn_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.11.attention.wk.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.11.attention.wk.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.11.attention.wo.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.11.attention.wo.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.11.attention.wq.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.11.attention.wq.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.11.attention.wv.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.11.attention.wv.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.11.attention_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.11.attention_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.11.feed_forward.w1.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.11.feed_forward.w1.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.11.feed_forward.w2.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.11.feed_forward.w2.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.11.ffn_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.11.ffn_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.12.attention.wk.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.12.attention.wk.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.12.attention.wo.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.12.attention.wo.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.12.attention.wq.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.12.attention.wq.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.12.attention.wv.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.12.attention.wv.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.12.attention_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.12.attention_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.12.feed_forward.w1.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.12.feed_forward.w1.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.12.feed_forward.w2.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.12.feed_forward.w2.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.12.ffn_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.12.ffn_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.13.attention.wk.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.13.attention.wk.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.13.attention.wo.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.13.attention.wo.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.13.attention.wq.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.13.attention.wq.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.13.attention.wv.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.13.attention.wv.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.13.attention_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.13.attention_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.13.feed_forward.w1.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.13.feed_forward.w1.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.13.feed_forward.w2.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.13.feed_forward.w2.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.13.ffn_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.13.ffn_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.14.attention.wk.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.14.attention.wk.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.14.attention.wo.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.14.attention.wo.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.14.attention.wq.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.14.attention.wq.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.14.attention.wv.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.14.attention.wv.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.14.attention_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.14.attention_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.14.feed_forward.w1.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.14.feed_forward.w1.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.14.feed_forward.w2.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.14.feed_forward.w2.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.14.ffn_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.14.ffn_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.15.attention.wk.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.15.attention.wk.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.15.attention.wo.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.15.attention.wo.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.15.attention.wq.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.15.attention.wq.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.15.attention.wv.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.15.attention.wv.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.15.attention_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.15.attention_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.15.feed_forward.w1.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.15.feed_forward.w1.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.15.feed_forward.w2.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.15.feed_forward.w2.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.15.ffn_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.15.ffn_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.16.attention.wk.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.16.attention.wk.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.16.attention.wo.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.16.attention.wo.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.16.attention.wq.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.16.attention.wq.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.16.attention.wv.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.16.attention.wv.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.16.attention_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.16.attention_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.16.feed_forward.w1.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.16.feed_forward.w1.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.16.feed_forward.w2.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.16.feed_forward.w2.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.16.ffn_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.16.ffn_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.17.attention.wk.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.17.attention.wk.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.17.attention.wo.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.17.attention.wo.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.17.attention.wq.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.17.attention.wq.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.17.attention.wv.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.17.attention.wv.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.17.attention_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.17.attention_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.17.feed_forward.w1.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.17.feed_forward.w1.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.17.feed_forward.w2.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.17.feed_forward.w2.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.17.ffn_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.17.ffn_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.18.attention.wk.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.18.attention.wk.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.18.attention.wo.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.18.attention.wo.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.18.attention.wq.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.18.attention.wq.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.18.attention.wv.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.18.attention.wv.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.18.attention_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.18.attention_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.18.feed_forward.w1.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.18.feed_forward.w1.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.18.feed_forward.w2.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.18.feed_forward.w2.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.18.ffn_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.18.ffn_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.19.attention.wk.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.19.attention.wk.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.19.attention.wo.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.19.attention.wo.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.19.attention.wq.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.19.attention.wq.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.19.attention.wv.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.19.attention.wv.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.19.attention_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.19.attention_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.19.feed_forward.w1.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.19.feed_forward.w1.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.19.feed_forward.w2.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.19.feed_forward.w2.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.19.ffn_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.19.ffn_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.2.attention.wk.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.2.attention.wk.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.2.attention.wo.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.2.attention.wo.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.2.attention.wq.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.2.attention.wq.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.2.attention.wv.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.2.attention.wv.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.2.attention_norm.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.2.attention_norm.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.2.feed_forward.w1.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.2.feed_forward.w1.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.2.feed_forward.w2.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.2.feed_forward.w2.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.2.ffn_norm.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.2.ffn_norm.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.20.attention.wk.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.20.attention.wk.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.20.attention.wo.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.20.attention.wo.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.20.attention.wq.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.20.attention.wq.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.20.attention.wv.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.20.attention.wv.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.20.attention_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.20.attention_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.20.feed_forward.w1.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.20.feed_forward.w1.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.20.feed_forward.w2.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.20.feed_forward.w2.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.20.ffn_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.20.ffn_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.21.attention.wk.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.21.attention.wk.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.21.attention.wo.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.21.attention.wo.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.21.attention.wq.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.21.attention.wq.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.21.attention.wv.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.21.attention.wv.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.21.attention_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.21.attention_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.21.feed_forward.w1.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.21.feed_forward.w1.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.21.feed_forward.w2.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.21.feed_forward.w2.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.21.ffn_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.21.ffn_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.22.attention.wk.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.22.attention.wk.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.22.attention.wo.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.22.attention.wo.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.22.attention.wq.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.22.attention.wq.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.22.attention.wv.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.22.attention.wv.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.22.attention_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.22.attention_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.22.feed_forward.w1.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.22.feed_forward.w1.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.22.feed_forward.w2.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.22.feed_forward.w2.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.22.ffn_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.22.ffn_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.23.attention.wk.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.23.attention.wk.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.23.attention.wo.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.23.attention.wo.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.23.attention.wq.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.23.attention.wq.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.23.attention.wv.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.23.attention.wv.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.23.attention_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.23.attention_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.23.feed_forward.w1.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.23.feed_forward.w1.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.23.feed_forward.w2.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.23.feed_forward.w2.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.23.ffn_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.23.ffn_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.24.attention.wk.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.24.attention.wk.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.24.attention.wo.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.24.attention.wo.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.24.attention.wq.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.24.attention.wq.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.24.attention.wv.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.24.attention.wv.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.24.attention_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.24.attention_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.24.feed_forward.w1.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.24.feed_forward.w1.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.24.feed_forward.w2.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.24.feed_forward.w2.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.24.ffn_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.24.ffn_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.3.attention.wk.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.3.attention.wk.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.3.attention.wo.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.3.attention.wo.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.3.attention.wq.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.3.attention.wq.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.3.attention.wv.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.3.attention.wv.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.3.attention_norm.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.3.attention_norm.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.3.feed_forward.w1.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.3.feed_forward.w1.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.3.feed_forward.w2.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.3.feed_forward.w2.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.3.ffn_norm.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.3.ffn_norm.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.4.attention.wk.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.4.attention.wk.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.4.attention.wo.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.4.attention.wo.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.4.attention.wq.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.4.attention.wq.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.4.attention.wv.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.4.attention.wv.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.4.attention_norm.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.4.attention_norm.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.4.feed_forward.w1.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.4.feed_forward.w1.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.4.feed_forward.w2.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.4.feed_forward.w2.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.4.ffn_norm.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.4.ffn_norm.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.5.attention.wk.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.5.attention.wk.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.5.attention.wo.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.5.attention.wo.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.5.attention.wq.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.5.attention.wq.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.5.attention.wv.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.5.attention.wv.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.5.attention_norm.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.5.attention_norm.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.5.feed_forward.w1.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.5.feed_forward.w1.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.5.feed_forward.w2.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.5.feed_forward.w2.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.5.ffn_norm.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.5.ffn_norm.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.6.attention.wk.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.6.attention.wk.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.6.attention.wo.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.6.attention.wo.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.6.attention.wq.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.6.attention.wq.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.6.attention.wv.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.6.attention.wv.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.6.attention_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.6.attention_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.6.feed_forward.w1.bias": "model-00001-of-00002.safetensors", "model.vit.resblocks.6.feed_forward.w1.weight": "model-00001-of-00002.safetensors", "model.vit.resblocks.6.feed_forward.w2.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.6.feed_forward.w2.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.6.ffn_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.6.ffn_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.7.attention.wk.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.7.attention.wk.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.7.attention.wo.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.7.attention.wo.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.7.attention.wq.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.7.attention.wq.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.7.attention.wv.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.7.attention.wv.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.7.attention_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.7.attention_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.7.feed_forward.w1.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.7.feed_forward.w1.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.7.feed_forward.w2.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.7.feed_forward.w2.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.7.ffn_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.7.ffn_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.8.attention.wk.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.8.attention.wk.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.8.attention.wo.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.8.attention.wo.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.8.attention.wq.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.8.attention.wq.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.8.attention.wv.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.8.attention.wv.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.8.attention_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.8.attention_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.8.feed_forward.w1.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.8.feed_forward.w1.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.8.feed_forward.w2.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.8.feed_forward.w2.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.8.ffn_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.8.ffn_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.9.attention.wk.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.9.attention.wk.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.9.attention.wo.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.9.attention.wo.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.9.attention.wq.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.9.attention.wq.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.9.attention.wv.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.9.attention.wv.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.9.attention_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.9.attention_norm.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.9.feed_forward.w1.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.9.feed_forward.w1.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.9.feed_forward.w2.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.9.feed_forward.w2.weight": "model-00002-of-00002.safetensors", "model.vit.resblocks.9.ffn_norm.bias": "model-00002-of-00002.safetensors", "model.vit.resblocks.9.ffn_norm.weight": "model-00002-of-00002.safetensors", "model.x_norm.weight": "model-00002-of-00002.safetensors" }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862"""Molmo3 for HuggingFace transformers.
Module and parameter names mirror the native model (olmo/models/molmo3/molmo3.py), so a nativestate dict loads under the `model.` prefix with only the lm_head added.
Pointing and segmentation are resolved during generation: each grounding token is followed by adot-product head that picks a patch, sub-patch, or location, and the pick is fed back into the nexttoken's embedding. With `return_dict_in_generate=True`, `generate` returns those picks per row as`output.grounding`, which `Molmo3Processor.decode` turns into coordinates and masks."""import inspectimport mathfrom dataclasses import dataclassfrom typing import Optional
import torchfrom torch import nnfrom torch.nn import functional as Ffrom transformers import initialization as hf_initfrom transformers.activations import ACT2FNfrom transformers.cache_utils import Cache, DynamicCachefrom transformers.generation import GenerateDecoderOnlyOutput, GenerationMixinfrom transformers.masking_utils import create_causal_maskfrom transformers.modeling_outputs import CausalLMOutputWithPastfrom transformers.utils import ModelOutputfrom transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from .configuration_molmo3 import Molmo3Config, Molmo3TextConfig, Molmo3VisionConfig
SMALL_VALUE = -1000000
# ───────────────────────────── shared ─────────────────────────────
class Molmo3RMSNorm(nn.Module): def __init__(self, size: int, eps: float = 1e-6): super().__init__() self.weight = nn.Parameter(torch.ones(size)) self.eps = eps
def forward(self, x: torch.Tensor) -> torch.Tensor: dtype = x.dtype x = x.float() x = x * torch.rsqrt(x.pow(2).mean(-1, keepdim=True) + self.eps) return self.weight * x.to(dtype)
def rotate_half(x: torch.Tensor) -> torch.Tensor: x1, x2 = x.chunk(2, dim=-1) return torch.cat((-x2, x1), dim=-1)
def rope_sin_cos(positions: torch.Tensor, dim: int, theta: float): """fp32 sin/cos tables for `positions` (any shape) -> `positions.shape + (dim,)`.""" inv_freq = 1.0 / (theta ** (torch.arange(0, dim, 2, device=positions.device, dtype=torch.float) / dim)) freqs = positions.float()[..., None] * inv_freq emb = torch.cat((freqs, freqs), dim=-1) return emb.sin(), emb.cos()
def apply_rope(x: torch.Tensor, sin: torch.Tensor, cos: torch.Tensor) -> torch.Tensor: x_ = x.float() return (x_ * cos + rotate_half(x_) * sin).to(x.dtype)
# ───────────────────────────── vision encoder ─────────────────────────────
class Molmo3VitAttention(nn.Module): def __init__(self, config: Molmo3VisionConfig): super().__init__() self.num_heads = config.num_attention_heads self.head_dim = config.head_dim inner = self.num_heads * self.head_dim self.wq = nn.Linear(config.hidden_size, inner) self.wk = nn.Linear(config.hidden_size, inner) self.wv = nn.Linear(config.hidden_size, inner) self.wo = nn.Linear(inner, config.hidden_size)
def forward(self, x: torch.Tensor) -> torch.Tensor: B, N, _ = x.shape q, k, v = (proj(x).view(B, N, self.num_heads, self.head_dim).transpose(1, 2).float() for proj in (self.wq, self.wk, self.wv)) out = F.scaled_dot_product_attention(q, k, v).transpose(1, 2).reshape(B, N, -1) return self.wo(out.to(x.dtype))
class Molmo3VitMLP(nn.Module): def __init__(self, config: Molmo3VisionConfig): super().__init__() self.w1 = nn.Linear(config.hidden_size, config.intermediate_size) self.act = ACT2FN[config.hidden_act] self.w2 = nn.Linear(config.intermediate_size, config.hidden_size)
def forward(self, x): return self.w2(self.act(self.w1(x)))
class Molmo3VitBlock(nn.Module): def __init__(self, config: Molmo3VisionConfig): super().__init__() self.attention = Molmo3VitAttention(config) self.feed_forward = Molmo3VitMLP(config) self.attention_norm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps) self.ffn_norm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
def forward(self, x): x = x + self.attention(self.attention_norm(x)) return x + self.feed_forward(self.ffn_norm(x))
class Molmo3VitBlocks(nn.Module): def __init__(self, config: Molmo3VisionConfig, n_layers: int): super().__init__() self.resblocks = nn.ModuleList([Molmo3VitBlock(config) for _ in range(n_layers)])
class Molmo3VisionTransformer(nn.Module): """SigLIP2 encoder, truncated after the deepest layer the connector reads."""
def __init__(self, config: Molmo3VisionConfig, n_layers: int): super().__init__() self.positional_embedding = nn.Parameter(torch.zeros(config.grid_size ** 2, config.hidden_size)) self.patch_embedding = nn.Linear(config.patch_size ** 2 * 3, config.hidden_size) self.transformer = Molmo3VitBlocks(config, n_layers)
def forward(self, x: torch.Tensor) -> list: x = self.patch_embedding(x) + self.positional_embedding[None].to(x.dtype) hidden_states = [] for block in self.transformer.resblocks: x = block(x) hidden_states.append(x) return hidden_states
# ───────────────────────────── connector ─────────────────────────────
class Molmo3PoolingAttention(nn.Module): """Single-query attention pooling over each pooling window (no output projection)."""
def __init__(self, input_dim: int, num_heads: int, head_dim: int): super().__init__() self.num_heads, self.head_dim = num_heads, head_dim self.wq = nn.Linear(input_dim, num_heads * head_dim) self.wk = nn.Linear(input_dim, num_heads * head_dim) self.wv = nn.Linear(input_dim, num_heads * head_dim)
def forward(self, query, to_pool, mask): def split(t): return t.reshape(t.shape[:2] + (self.num_heads, self.head_dim)).float() q, k, v = split(self.wq(query)), split(self.wk(to_pool)), split(self.wv(to_pool)) weights = torch.einsum("...qhd,...khd->...hqk", q / math.sqrt(self.head_dim), k) weights = weights.masked_fill(~mask[:, None, None, :], torch.finfo(weights.dtype).min) out = torch.einsum("...hqk,...khd->...qhd", F.softmax(weights, dim=-1), v) return out.to(query.dtype).reshape(out.shape[:2] + (-1,))
class Molmo3ImageProjector(nn.Module): def __init__(self, input_dim, hidden_dim, output_dim, hidden_act): super().__init__() self.w1 = nn.Linear(input_dim, hidden_dim, bias=False) self.w2 = nn.Linear(hidden_dim, output_dim, bias=False) self.w3 = nn.Linear(input_dim, hidden_dim, bias=False) self.act = ACT2FN[hidden_act]
def forward(self, x): return self.w2(self.act(self.w1(x)) * self.w3(x))
class Molmo3AddPosEmbed(nn.Module): def __init__(self, dim: int, n_pos: int): super().__init__() self.bias = nn.Parameter(torch.zeros(n_pos, dim))
def forward(self, x): return x + self.bias[None, :x.shape[-2]].to(x.dtype)
class Molmo3Connector(nn.Module): def __init__(self, config: Molmo3Config): super().__init__() vit, adapter = config.vision_config, config.adapter_config pool_dim = vit.hidden_size * len(adapter.vision_feature_layer) self.image_pooling_2d = Molmo3PoolingAttention( pool_dim, adapter.num_attention_heads, adapter.head_dim) self.image_projector = Molmo3ImageProjector( adapter.num_attention_heads * adapter.head_dim, adapter.intermediate_size, config.text_config.hidden_size, adapter.hidden_act) self.positional_embeddings = Molmo3AddPosEmbed(pool_dim, adapter.num_pooling_positions)
def forward(self, to_pool: torch.Tensor, mask: torch.Tensor) -> torch.Tensor: """`[n, pool, dim]` features with `[n, pool]` validity -> `[n, llm_dim]`.""" # The bias is added after masking, so it also enters the mean of padded slots (as native) to_pool = self.positional_embeddings(to_pool) denom = mask.float().sum(-1).clamp(min=1) query = to_pool.sum(-2, keepdim=True) / denom[:, None, None].to(to_pool.dtype) pooled = self.image_pooling_2d(query, to_pool, mask) return self.image_projector(pooled)[:, 0]
class Molmo3SinusoidalPosEmbed(nn.Module): """(t, h, w) sinusoids projected to the ViT feature width, added before pooling.""" SINUSOID_DIM = 512
def __init__(self, dim: int): super().__init__() self.proj = nn.Linear(self.SINUSOID_DIM * 3, dim)
def forward(self, pos: torch.Tensor) -> torch.Tensor: half = torch.arange(0, self.SINUSOID_DIM, 2, device=pos.device, dtype=torch.float) div = torch.exp(half * (-math.log(10000.0) / self.SINUSOID_DIM)) angles = pos.float()[..., None] * div # [..., 3, 256] emb = torch.stack([angles.sin(), angles.cos()], -1).flatten(-2) # interleaved sin/cos return self.proj(emb.flatten(-2).to(self.proj.weight.dtype))
# ───────────────────────────── language model ─────────────────────────────
class Molmo3DecoderLayer(nn.Module): def __init__(self, config: Molmo3TextConfig, layer_idx: int): super().__init__() self.config = config self.layer_idx = layer_idx self.num_heads = config.num_attention_heads self.num_kv_heads = config.num_key_value_heads self.num_key_value_groups = self.num_heads // self.num_kv_heads self.head_dim = config.head_dim self.scaling = self.head_dim ** -0.5 self.is_causal = True self.fused_dims = (self.num_heads * self.head_dim, self.num_kv_heads * self.head_dim, self.num_kv_heads * self.head_dim) self.att_proj = nn.Linear(config.hidden_size, sum(self.fused_dims), bias=False) self.attn_out = nn.Linear(self.num_heads * self.head_dim, config.hidden_size, bias=False) self.q_norm = Molmo3RMSNorm(self.head_dim, config.rms_norm_eps) self.k_norm = Molmo3RMSNorm(self.head_dim, config.rms_norm_eps) self.ff_proj = nn.Linear(config.hidden_size, 2 * config.intermediate_size, bias=False) self.ff_out = nn.Linear(config.intermediate_size, config.hidden_size, bias=False) self.act = ACT2FN[config.hidden_act] self.attn_norm = Molmo3RMSNorm(config.hidden_size, config.rms_norm_eps) self.ff_norm = Molmo3RMSNorm(config.hidden_size, config.rms_norm_eps)
def forward(self, x, rope, attention_mask, past_key_values): B, L, _ = x.shape q, k, v = self.att_proj(self.attn_norm(x)).split(self.fused_dims, dim=-1) q = self.q_norm(q.view(B, L, -1, self.head_dim)).transpose(1, 2) k = self.k_norm(k.view(B, L, -1, self.head_dim)).transpose(1, 2) v = v.view(B, L, -1, self.head_dim).transpose(1, 2) sin, cos = rope q, k = apply_rope(q, sin, cos), apply_rope(k, sin, cos) if past_key_values is not None: k, v = past_key_values.update(k, v, self.layer_idx) impl = self.config._attn_implementation or "sdpa" attention = eager_attention_forward if impl == "eager" else ALL_ATTENTION_FUNCTIONS[impl] out, _ = attention(self, q, k, v, attention_mask, dropout=0.0, scaling=self.scaling) x = x + self.attn_out(out.reshape(B, L, -1)) h, gate = self.ff_proj(self.ff_norm(x)).chunk(2, dim=-1) return x + self.ff_out(self.act(gate) * h)
def eager_attention_forward(module, q, k, v, attention_mask, scaling, dropout=0.0, **kwargs): k = k.repeat_interleave(module.num_key_value_groups, dim=1) v = v.repeat_interleave(module.num_key_value_groups, dim=1) weights = torch.matmul(q, k.transpose(2, 3)) * scaling if attention_mask is not None: weights = weights + attention_mask[:, :, :, :k.shape[-2]] weights = F.softmax(weights, dim=-1, dtype=torch.float32).to(q.dtype) return torch.matmul(weights, v).transpose(1, 2).contiguous(), weights
class Molmo3Embedding(nn.Module): def __init__(self, num_embeddings: int, num_new_embeddings: int, features: int): super().__init__() self.embedding = nn.Parameter(torch.zeros(num_embeddings, features)) self.new_embedding = nn.Parameter(torch.zeros(num_new_embeddings, features))
def forward(self, x): return F.embedding(x, torch.cat([self.embedding, self.new_embedding], dim=0))
class Molmo3TextModel(nn.Module): def __init__(self, config: Molmo3TextConfig): super().__init__() self.config = config self.wte = Molmo3Embedding(config.base_vocab_size, config.additional_vocab_size, config.hidden_size) self.blocks = nn.ModuleList( [Molmo3DecoderLayer(config, i) for i in range(config.num_hidden_layers)]) self.ln_f = Molmo3RMSNorm(config.hidden_size, config.rms_norm_eps)
def forward(self, x, position_ids, attention_mask, past_key_values): """Returns the final block output *before* `ln_f`; the grounding head reads that.""" sin, cos = rope_sin_cos(position_ids, self.config.head_dim, self.config.rope_theta) rope = (sin[:, None], cos[:, None]) for block in self.blocks: x = block(x, rope, attention_mask, past_key_values) return x
# ───────────────────────────── grounding head ─────────────────────────────
class Molmo3MlpMerge(nn.Module): def __init__(self, in_dim1, in_dim2, hidden_size, out_dim): super().__init__() self.w_in1 = nn.Linear(in_dim1, hidden_size * 2, bias=False) self.w_in2 = nn.Linear(in_dim2, hidden_size * 2, bias=False) self.w_out = nn.Linear(hidden_size, out_dim)
def forward(self, x1, x2): x, gate = (self.w_in1(x1) + self.w_in2(x2)).chunk(2, dim=-1) return self.w_out(x * F.silu(gate))
class Molmo3SubpatchConv(nn.Module): """Mixes each ViT patch with its neighbours before the sub-patch keys are read off it."""
def __init__(self, in_dim, out_dim, kernel): super().__init__() self.proj = nn.Conv2d(in_dim, out_dim, 1) self.conv = nn.Conv2d(out_dim, out_dim, kernel, padding=kernel // 2)
def forward(self, features, grid): batch, n, dim = features.shape x = features.reshape(-1, grid, grid, dim).permute(0, 3, 1, 2) x = self.conv(F.gelu(self.proj(x))) return x.permute(0, 2, 3, 1).reshape(batch, n, -1)
MASK_EDGES = ((-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1))
class Molmo3MaskAffinity(nn.Module): """Per-location edge weights used to diffuse the mask logits, from the image alone."""
def __init__(self, in_dim, n_locations): super().__init__() self.upscale = int(round(math.sqrt(n_locations))) self.conv = nn.Conv2d(in_dim, len(MASK_EDGES) * n_locations, 3, padding=1)
def forward(self, features, grid): """`[batch, n_crops*grid*grid, dim]` -> `[batch*n_crops, 8, grid*r, grid*r]`.""" x = features.reshape(-1, grid, grid, features.shape[-1]).permute(0, 3, 1, 2) return F.pixel_shuffle(self.conv(x), self.upscale)
def diffuse_mask(mask, weights, steps): """`m <- m + sum_j w_j (m_j - m)` over the 8 neighbours, `steps` times.""" h, w = mask.shape[-2:] bounded = torch.tanh(weights) / len(MASK_EDGES) for _ in range(steps): padded = F.pad(mask, (1, 1, 1, 1), mode="replicate") delta = torch.zeros_like(mask) for i, (dy, dx) in enumerate(MASK_EDGES): delta = delta + bounded[:, i:i + 1] * (padded[..., 1 + dy:1 + dy + h, 1 + dx:1 + dx + w] - mask) mask = mask + delta return mask
@dataclassclass Molmo3ImageCache: """Image-side tensors built at prefill, used by every later grounding step.""" patch_k: torch.Tensor # [B, P, q] patch_k_mask: torch.Tensor # [B, P, S], which (token, ViT patch) pairs can be pointed at subpatch_k: torch.Tensor # [B, P, S, s] loc_k: torch.Tensor # [B, P, S, n_locs, l] vit_features: torch.Tensor # [B, P, S, subpatch_hidden] image_features: torch.Tensor # [n_image_tokens, d_model], connector output token_offset: torch.Tensor # [B], offset of each row into `image_features` image_pos_ids: torch.Tensor # [B, P], rotary position of each image token token_pooling: torch.Tensor # [B, P, S] diffusion_weights: torch.Tensor
@dataclassclass Molmo3Grounding: """One generated sequence's grounding picks, in output order: a (patch, subpatch, loc) per `<|POINT_LOC|>`, an anchor patch and `[P, S, 16]` scores per `<|SEG_MASK|>`, and the end-of-points probability at the first patch choice that could stop the list.""" point_ids: list mask_anchors: list mask_scores: list no_point: Optional[float] = None
@dataclassclass Molmo3GenerateOutput(GenerateDecoderOnlyOutput): """`generate` output with `grounding`, one `Molmo3Grounding` per row.""" grounding: Optional[list] = None
class Molmo3GroundingState: """Per-generation pointing/segmentation state, internal to `generate`."""
def __init__(self): self.cache: Optional[Molmo3ImageCache] = None self.point_triples = self.mask_scores = self.mask_anchors = None
def reset(self, batch_size: int, device): def zeros(): return torch.zeros(batch_size, dtype=torch.long, device=device) self.patch, self.subpatch, self.loc, self.rotate_by = zeros(), zeros(), zeros(), zeros() self.patch_resolved = torch.zeros(batch_size, dtype=torch.bool, device=device) self.list_started = [False] * batch_size self.last_patch_token = [None] * batch_size self.prev_token: Optional[torch.Tensor] = None self.point_triples = [[] for _ in range(batch_size)] self.mask_scores = [[] for _ in range(batch_size)] self.mask_anchors = [[] for _ in range(batch_size)] self.first_no_point = [None] * batch_size
# ───────────────────────────── model ─────────────────────────────
class Molmo3PreTrainedModel(PreTrainedModel): config_class = Molmo3Config base_model_prefix = "model" supports_gradient_checkpointing = False _no_split_modules = ["Molmo3DecoderLayer", "Molmo3VitBlock"] _skip_keys_device_placement = "past_key_values" _supports_sdpa = True _supports_flex_attn = True _supports_attention_backend = True
@torch.no_grad() def _init_weights(self, module): # These helpers skip tensors that were loaded from the checkpoint std = 0.02 if isinstance(module, (nn.Linear, nn.Conv2d)): hf_init.normal_(module.weight, 0.0, std) if module.bias is not None: hf_init.zeros_(module.bias) elif isinstance(module, nn.Embedding): hf_init.normal_(module.weight, 0.0, std) elif isinstance(module, Molmo3Embedding): hf_init.normal_(module.embedding, 0.0, std) hf_init.normal_(module.new_embedding, 0.0, std) elif isinstance(module, (Molmo3RMSNorm, nn.LayerNorm)): hf_init.ones_(module.weight) if getattr(module, "bias", None) is not None: hf_init.zeros_(module.bias) elif isinstance(module, Molmo3AddPosEmbed): hf_init.zeros_(module.bias) elif isinstance(module, Molmo3VisionTransformer): hf_init.normal_(module.positional_embedding, 0.0, std)
class Molmo3Model(Molmo3PreTrainedModel):
def __init__(self, config: Molmo3Config): super().__init__(config) vit, adapter, text = config.vision_config, config.adapter_config, config.text_config self.vit_layers = list(adapter.vision_feature_layer) d_vit = vit.hidden_size * len(self.vit_layers) d_model = text.hidden_size q, s, l = config.point_query_dims n_locs = config.subpatch_location_size ** 2 sub = config.subpatch_hidden_size # The mask builder and the attention layers both read this off the text config text._attn_implementation = config._attn_implementation or "sdpa"
self.transformer = Molmo3TextModel(text) self.vit = Molmo3VisionTransformer(vit, max(self.vit_layers) + 1) self.connector = Molmo3Connector(config) self.subpatch_pos_embed = Molmo3SinusoidalPosEmbed(d_vit)
self.x_norm = Molmo3RMSNorm(d_model, text.rms_norm_eps) self.subpatch_hidden = nn.Linear(d_vit, sub) self.subpatch_conv = Molmo3SubpatchConv(d_vit, sub, config.subpatch_conv_kernel) self.mask_affinity = Molmo3MaskAffinity(d_vit, n_locs) self.patch_k = nn.Linear(d_model, q) self.subpatch_loc_k = Molmo3MlpMerge(sub, d_model, sub * 2, s + l * n_locs) self.patch_q = nn.Linear(d_model, q) self.subpatch_q = nn.Linear(d_model, s) self.loc_q = nn.Linear(d_model, n_locs) self.mask_q = nn.Linear(d_model, q + s + l) self.build_subpatch_embeddings = nn.Linear(sub, d_model) self.build_location_embeddings = nn.Embedding(n_locs, d_model) self.post_init() if (config._attn_implementation or "").startswith("flash"): raise ValueError("Molmo3 needs a bidirectional mask over image tokens, which flash " "attention cannot express; use 'sdpa' or 'flex_attention'")
def get_input_embeddings(self): return self.transformer.wte
# ── vision ──
def encode_images(self, pixel_values, token_pooling, patch_pos_ids): """Returns `(image_features [n_tokens, d], vit_features [B, P, S, d_vit], conv, weights)`.""" B, T, N, D = pixel_values.shape grid = self.config.vision_config.grid_size dtype = self.vit.patch_embedding.weight.dtype pixels = pixel_values.reshape(B * T, N, D) if pixels.dtype == torch.uint8: pixels = pixels.float() / 255.0 * 2 - 1 # SigLIP normalization hidden = self.vit(pixels.to(dtype)) features = torch.cat([hidden[i] for i in self.vit_layers], -1).reshape(B, T * N, -1) features = features + self.subpatch_pos_embed( patch_pos_ids.reshape(B, T * N, 3).clamp(min=0)).to(features.dtype)
# Both run on the ViT raster, before the gather by pooled token reorders it diffusion_weights = self.mask_affinity(features, grid) valid = token_pooling >= 0 batch_ix = torch.arange(B, device=features.device)[:, None, None] conv = self.subpatch_conv(features, grid)[batch_ix, token_pooling.clamp(min=0)] conv = conv * valid[..., None].to(conv.dtype)
vit_features = features[batch_ix, token_pooling.clamp(min=0)] * valid[..., None].to(features.dtype) is_token = valid.any(-1) image_features = self.connector(vit_features[is_token], valid[is_token]) return image_features, vit_features, conv, diffusion_weights
def image_pos_ids(self, input_ids): """Rotary position of each image token for the pointer: a running count of high-res tokens, continued across images; low-res tokens share the position of the first high-res token.""" cfg = self.config is_high = input_ids == cfg.image_patch_id is_image = is_high | (input_ids == cfg.image_low_res_id) starts = (input_ids == cfg.low_res_image_start_token_id) | (input_ids == cfg.frame_start_token_id) out = torch.zeros(input_ids.shape[0], int(is_image.sum(-1).max()), dtype=torch.long, device=input_ids.device) for b in range(input_ids.shape[0]): owner = (torch.cumsum(starts[b].long(), 0) - 1)[is_image[b]] high = is_high[b][is_image[b]].long() pos, offset = torch.zeros_like(owner), 0 for i in torch.unique(owner).tolist(): rows = owner == i local = (torch.cumsum(high[rows], 0) - 1).clamp(min=0) pos[rows] = local + offset offset += int(local.max()) + 1 out[b, :len(pos)] = pos return out
def build_image_cache(self, input_ids, x_norm, token_pooling, image_features, vit_features, conv, diffusion_weights) -> Molmo3ImageCache: cfg = self.config B, P, S = token_pooling.shape q, s, l = cfg.point_query_dims n_locs = cfg.subpatch_location_size ** 2 is_high = input_ids == cfg.image_patch_id is_image = is_high | (input_ids == cfg.image_low_res_id) is_token = (token_pooling >= 0).any(-1)
image_pos_ids = self.image_pos_ids(input_ids) image_pos_ids = F.pad(image_pos_ids, [0, max(0, P - image_pos_ids.shape[1])])[:, :P] x_image = x_norm.new_zeros(B, P, x_norm.shape[-1]) x_image[is_token] = x_norm[is_image]
patch_k = self.patch_k(x_image) sin, cos = rope_sin_cos(image_pos_ids, q, cfg.pointer_rope_theta) patch_k = apply_rope(patch_k, sin, cos) * is_token[..., None].to(patch_k.dtype) patch_k_mask = (token_pooling >= 0).clone() is_high_token = torch.zeros_like(is_token) is_high_token[is_token] = is_high[is_image] patch_k_mask &= is_high_token[..., None] # only high-res tokens can be pointed at
vit_features = self.subpatch_hidden(vit_features) keys = self.subpatch_loc_k(vit_features + conv.to(vit_features.dtype), x_image[:, :, None]) subpatch_k, loc_k = keys.split([s, l * n_locs], dim=-1)
counts = is_token.sum(-1) return Molmo3ImageCache( patch_k=patch_k, patch_k_mask=patch_k_mask, subpatch_k=subpatch_k, loc_k=loc_k.reshape(B, P, S, n_locs, l), vit_features=vit_features, image_features=image_features, token_offset=F.pad(counts.cumsum(0)[:-1], [1, 0]), image_pos_ids=image_pos_ids, token_pooling=token_pooling, diffusion_weights=diffusion_weights)
# ── grounding ──
def add_grounding_feedback(self, x, state: Molmo3GroundingState): """Add the previous step's selection to the embedding of the token that follows it.""" cfg, cache, prev = self.config, state.cache, state.prev_token x = x.clone() is_patch = (prev == cfg.point_patch_id) | (prev == cfg.center_patch_id) rows = is_patch & state.patch_resolved if rows.any(): ix = (cache.token_offset + state.patch)[rows] x[rows, -1] += cache.image_features[ix].to(x.dtype) rows = prev == cfg.point_subpatch_id if rows.any(): feats = cache.vit_features[rows, state.patch[rows], state.subpatch[rows]] x[rows, -1] += self.build_subpatch_embeddings(feats).to(x.dtype) rows = prev == cfg.point_loc_id if rows.any(): x[rows, -1] += self.build_location_embeddings(state.loc[rows]).to(x.dtype) return x
def add_input_point_feedback(self, x, input_ids, input_point_ids, token_pooling, image_features, vit_features): """Prefill version of `add_grounding_feedback` for grounding tokens in the prompt.
`input_point_ids` has one (patch, subpatch, loc) row per patch token that is followed by a sub-patch token, or (anchor, -1, -1) for one followed by a mask token, in prompt order. """ cfg = self.config is_patch = torch.isin(input_ids, torch.tensor( [cfg.point_patch_id, cfg.center_patch_id], device=input_ids.device)) nxt = F.pad(input_ids[:, 1:], [0, 1], value=-1) # Not the end-of-points marker real_patch = is_patch & ((nxt == cfg.point_subpatch_id) | (nxt == cfg.seg_mask_id)) counts = (token_pooling >= 0).any(-1).sum(-1) offsets = F.pad(counts.cumsum(0)[:-1], [1, 0]) x = x.clone() for b in range(input_ids.shape[0]): ids = input_point_ids[b] if input_point_ids is not None else input_ids.new_zeros(0, 3) ids = ids[ids[:, 0] >= 0] patch_pos = real_patch[b].nonzero()[:, 0] sub_pos = (input_ids[b] == cfg.point_subpatch_id).nonzero()[:, 0] loc_pos = (input_ids[b] == cfg.point_loc_id).nonzero()[:, 0] is_point = ids[:, 1] >= 0 if not (len(ids) == len(patch_pos) and int(is_point.sum()) == len(sub_pos) == len(loc_pos)): raise ValueError( f"the prompt has {len(patch_pos)} grounding blocks but {len(ids)} input point ids; " "pass groundings through the processor so it can build `input_point_ids`") if not len(ids): continue x[b, patch_pos + 1] += image_features[offsets[b] + ids[:, 0]].to(x.dtype) if not len(sub_pos): continue patch, subpatch, loc = ids[is_point].unbind(-1) feats = self.subpatch_hidden(vit_features[b, patch, subpatch]) x[b, sub_pos + 1] += self.build_subpatch_embeddings(feats).to(x.dtype) x[b, loc_pos + 1] += self.build_location_embeddings(loc).to(x.dtype) return x
def patch_logits(self, h, b, state): """`[n_patches + 1]` logits for row `b`, the last entry being end-of-points.""" cache = state.cache q = self.patch_q(h) sin, cos = rope_sin_cos(cache.image_pos_ids[b, state.rotate_by[b]], q.shape[-1], self.config.pointer_rope_theta) q = apply_rope(q, sin, cos) logits = (cache.patch_k[b].float() @ q.float()) / math.sqrt(q.shape[-1]) logits = torch.where(cache.patch_k_mask[b].any(-1), logits, SMALL_VALUE) return F.pad(logits, [0, 1])
def subpatch_logits(self, h, b, state): k = state.cache.subpatch_k[b, state.patch[b]] return (k.float() @ self.subpatch_q(h).float()) / math.sqrt(k.shape[-1])
def mask_scores(self, h, b, state): """`[P, S, n_locs]` mask probabilities for row `b`, -1 where nothing can be selected.""" cfg, cache = self.config, state.cache tok_q, vit_q, loc_q = self.mask_q(h).float().split(cfg.point_query_dims, dim=-1) sin, cos = rope_sin_cos(cache.image_pos_ids[b, state.patch[b]], tok_q.shape[-1], cfg.pointer_rope_theta) tok_q = apply_rope(tok_q, sin, cos) scores = ( (cache.patch_k[b].float() @ tok_q)[:, None, None] / math.sqrt(tok_q.shape[-1]) + (cache.subpatch_k[b].float() @ vit_q)[..., None] / math.sqrt(vit_q.shape[-1]) + (cache.loc_k[b].float() @ loc_q) / math.sqrt(loc_q.shape[-1])) scores = self.diffuse(scores, b, cache) return torch.where(cache.patch_k_mask[b][..., None], torch.sigmoid(scores), -1.0)
def diffuse(self, scores, b, cache): """Scatter the scores onto each crop's ViT raster, diffuse them, and read them back.""" P, S, n_locs = scores.shape grid = self.config.vision_config.grid_size r = int(round(math.sqrt(n_locs))) weights = cache.diffusion_weights n_crops = weights.shape[0] // cache.token_pooling.shape[0] weights = weights[b * n_crops:(b + 1) * n_crops] pooling = cache.token_pooling[b] keep = pooling >= 0 raster = scores.new_zeros(n_crops * grid * grid, n_locs) raster[pooling[keep]] = scores[keep] m = raster.reshape(n_crops, grid, grid, r, r).permute(0, 1, 3, 2, 4) m = diffuse_mask(m.reshape(n_crops, 1, grid * r, grid * r), weights.to(m.dtype), self.config.mask_diffusion_steps) m = m.reshape(n_crops, grid, r, grid, r).permute(0, 1, 3, 2, 4).reshape(-1, n_locs) out = scores.clone() out[keep] = m[pooling[keep]] return out
# ── forward ──
def bidirectional_mask_fn(self, input_ids): """Contiguous runs of vision tokens attend to each other; a <frame_start> starts a new run.""" is_vision = torch.isin(input_ids, torch.tensor(self.config.vision_token_ids, device=input_ids.device)) span = torch.cumsum((~is_vision) | (input_ids == self.config.frame_start_token_id), -1) n = input_ids.shape[1]
def inner(batch_idx, head_idx, q_idx, kv_idx): kv = torch.where(kv_idx < n, kv_idx, 0) return (is_vision[batch_idx, q_idx] & is_vision[batch_idx, kv] & (kv_idx < n) & (span[batch_idx, q_idx] == span[batch_idx, kv])) return inner
def forward(self, input_ids, attention_mask=None, position_ids=None, past_key_values=None, pixel_values=None, token_pooling=None, patch_pos_ids=None, input_point_ids=None, grounding_state=None, use_cache=True): cfg = self.config B, L = input_ids.shape past_len = 0 if past_key_values is None else past_key_values.get_seq_length() is_prefill = past_len == 0 has_images = is_prefill and pixel_values is not None if use_cache and past_key_values is None: past_key_values = DynamicCache(config=cfg.text_config)
if position_ids is None: if attention_mask is not None and attention_mask.ndim == 2: position_ids = (attention_mask.long().cumsum(-1) - 1).clamp(min=0)[:, -L:] else: position_ids = torch.arange(past_len, past_len + L, device=input_ids.device)[None].expand(B, -1)
has_points = is_prefill and torch.isin(input_ids, torch.tensor( cfg.grounding_token_ids, device=input_ids.device)).any() if has_points and not has_images: raise ValueError("points in the prompt need an image or video")
# <im_low> shares the <im_patch> embedding to_embed = torch.where(input_ids == cfg.image_low_res_id, cfg.image_patch_id, input_ids) x = self.transformer.wte(to_embed) if has_images: image_features, vit_features, conv, weights = self.encode_images( pixel_values, token_pooling, patch_pos_ids) is_image = (input_ids == cfg.image_patch_id) | (input_ids == cfg.image_low_res_id) if int(is_image.sum()) != len(image_features): raise ValueError(f"{int(is_image.sum())} image tokens but {len(image_features)} image features") x = x.clone() x[is_image] = image_features.to(x.dtype) if has_points: x = self.add_input_point_feedback(x, input_ids, input_point_ids, token_pooling, image_features, vit_features) elif grounding_state is not None and grounding_state.cache is not None and not is_prefill: x = self.add_grounding_feedback(x, grounding_state)
mask_kwargs = dict(config=cfg.text_config, inputs_embeds=x, attention_mask=attention_mask, past_key_values=past_key_values, position_ids=position_ids) if "cache_position" in inspect.signature(create_causal_mask).parameters: mask_kwargs["cache_position"] = torch.arange(past_len, past_len + L, device=x.device) if is_prefill: mask_kwargs["or_mask_function"] = self.bidirectional_mask_fn(input_ids) mask = create_causal_mask(**mask_kwargs)
hidden = self.transformer(x, position_ids, mask, past_key_values)
if grounding_state is not None and is_prefill and has_images: grounding_state.reset(B, input_ids.device) grounding_state.cache = self.build_image_cache( input_ids, self.x_norm(hidden), token_pooling, image_features, vit_features, conv, weights) return hidden, past_key_values
class Molmo3ForConditionalGeneration(Molmo3PreTrainedModel, GenerationMixin): _tied_weights_keys = []
def __init__(self, config: Molmo3Config): super().__init__(config) self.model = Molmo3Model(config) self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False) self.post_init()
def get_input_embeddings(self): return self.model.transformer.wte
def get_output_embeddings(self): return self.lm_head
def forward(self, input_ids, attention_mask=None, position_ids=None, past_key_values=None, pixel_values=None, token_pooling=None, patch_pos_ids=None, input_point_ids=None, use_cache=True, logits_to_keep=0, grounding_state: Optional[Molmo3GroundingState] = None, **kwargs): hidden, past_key_values = self.model( input_ids, attention_mask=attention_mask, position_ids=position_ids, past_key_values=past_key_values, pixel_values=pixel_values, token_pooling=token_pooling, patch_pos_ids=patch_pos_ids, input_point_ids=input_point_ids, grounding_state=grounding_state, use_cache=use_cache) keep = slice(-logits_to_keep, None) if isinstance(logits_to_keep, int) else logits_to_keep logits = self.lm_head(self.model.transformer.ln_f(hidden[:, keep])) state = grounding_state if state is not None and state.cache is not None: logits = self.resolve_grounding(input_ids[:, -1], self.model.x_norm(hidden[:, -1]), logits, state) state.prev_token = input_ids[:, -1] return CausalLMOutputWithPast(logits=logits, past_key_values=past_key_values)
@torch.no_grad() def resolve_grounding(self, tokens, h, logits, state: Molmo3GroundingState): """Resolve the grounding token each row was fed, and constrain each row's next token.""" cfg, model = self.config, self.model grounding_ids = cfg.grounding_token_ids patch_tokens = (cfg.point_patch_id, cfg.center_patch_id) for b, token in enumerate(tokens.tolist()): row = logits[b, -1] if cfg.corresponding_patch_id is not None: row[cfg.corresponding_patch_id] = SMALL_VALUE # deprecated if token in patch_tokens: state.last_patch_token[b] = token patch_logits = model.patch_logits(h[b], b, state) eop = len(patch_logits) - 1 if token == cfg.center_patch_id: ix = int(patch_logits[:-1].argmax()) # a center point can never end a list else: no_point = float(torch.softmax(patch_logits.float(), -1)[-1]) if state.first_no_point[b] is None: state.first_no_point[b] = no_point # Point iff the real patches hold more than `presence_threshold` of the mass, # except that a list already under way stops by plain argmax continuing = token == cfg.point_patch_id and state.list_started[b] if not continuing: if 1.0 - no_point > cfg.presence_threshold: patch_logits[-1] = SMALL_VALUE else: patch_logits[:-1] = SMALL_VALUE ix = int(patch_logits.argmax()) if token == cfg.point_patch_id: state.list_started[b] = ix != eop if ix == eop: state.patch[b] = 0 state.rotate_by[b] = 0 state.patch_resolved[b] = False row[grounding_ids] = SMALL_VALUE else: state.patch[b] = ix state.patch_resolved[b] = True if token != cfg.center_patch_id: state.rotate_by[b] = ix # the next patch query rotates to this one allowed = row[grounding_ids].clone() row.fill_(SMALL_VALUE) row[grounding_ids] = allowed elif token == cfg.seg_mask_id: state.mask_scores[b].append(model.mask_scores(h[b], b, state).cpu()) state.mask_anchors[b].append(int(state.patch[b])) elif token == cfg.point_subpatch_id: state.subpatch[b] = int(model.subpatch_logits(h[b], b, state).argmax()) row[cfg.point_loc_id] = 100000 elif token == cfg.point_loc_id: state.loc[b] = int(model.loc_q(h[b]).float().argmax()) state.point_triples[b].append( (int(state.patch[b]), int(state.subpatch[b]), int(state.loc[b]))) if state.last_patch_token[b] == cfg.center_patch_id: row[cfg.center_patch_id] = SMALL_VALUE else: # These can only follow a patch token row[[cfg.seg_mask_id, cfg.point_subpatch_id, cfg.point_loc_id]] = SMALL_VALUE return logits
def generate(self, *args, **kwargs): """`GenerationMixin.generate`. With `return_dict_in_generate=True` the output also has `grounding`, one `Molmo3Grounding` per row, for `Molmo3Processor.decode`.""" config = kwargs.get("generation_config") or self.generation_config setting = lambda name: kwargs.get(name, getattr(config, name, None)) or 1 # unset is None if kwargs.get("pixel_values") is not None and ( setting("num_beams") > 1 or setting("num_return_sequences") > 1): raise NotImplementedError("grounding picks are kept per batch row, so beam search and " "num_return_sequences > 1 are not supported with images") # Grounding tokens are only decoded correctly with a state, so always keep one state = Molmo3GroundingState() if kwargs.get("pixel_values") is not None else None out = super().generate(*args, grounding_state=state, **kwargs) if not isinstance(out, ModelOutput): return out n = out.sequences.shape[0] if state is None or state.point_triples is None: grounding = [Molmo3Grounding([], [], []) for _ in range(n)] else: grounding = [Molmo3Grounding(state.point_triples[b], state.mask_anchors[b], state.mask_scores[b], state.first_no_point[b]) for b in range(n)] return Molmo3GenerateOutput(**out, grounding=grounding)
__all__ = ["Molmo3ForConditionalGeneration", "Molmo3Model", "Molmo3Grounding", "Molmo3GenerateOutput"]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233"""Stand-alone Molmo3 processor: chat formatting, image/video preprocessing and grounding decoding.
processor = Molmo3Processor.from_pretrained(path) messages = [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "Point to the cats."}]}] inputs = processor.apply_chat_template(messages, images=[image], tokenize=True) out = model.generate(**inputs, max_new_tokens=512, return_dict_in_generate=True) answer = processor.decode(out.sequences[0, inputs["input_ids"].shape[1]:], out.grounding[0], images=[image])
`answer` is the same document vLLM's `json_objects` grounding mode returns. For multi-turn chat,append `processor.answer_message(ids, out.grounding[0])`, the raw answer with its grounding;`encode_document` turns a document back into text and grounding.
Images are tiled into up to `max_crops` overlapping 378px crops plus a low-res global crop; videosare sampled at up to `max_fps` (at most `max_frames` frames) and each frame resized to 378px."""import jsonimport mathimport osimport refrom typing import List, Optional, Union
import numpy as npimport torchimport torchvision.transformsfrom PIL import Imagefrom transformers import AutoTokenizer, BatchFeaturefrom transformers.utils import cached_file
from .configuration_molmo3 import Molmo3Config # noqa: F401, remote code copies direct imports onlyfrom .modeling_molmo3 import Molmo3Grounding
IMAGE_PATCH_TOKEN = "<im_patch>"IMAGE_LOW_RES_TOKEN = "<im_low>"IM_START_TOKEN = "<im_start>"LOW_RES_IMAGE_START_TOKEN = "<low_res_im_start>"IM_END_TOKEN = "<im_end>"IM_COL_TOKEN = "<im_col>"FRAME_START_TOKEN = "<frame_start>"FRAME_END_TOKEN = "<frame_end>"IMAGE_PROMPT = "<|image|>"VIDEO_PROMPT = "<|video|>"POINT_PATCH, POINT_SUBPATCH, POINT_LOC = "<|POINT_PATCH|>", "<|POINT_SUBPATCH|>", "<|POINT_LOC|>"SEG_MASK, CENTER_PATCH = "<|SEG_MASK|>", "<|CENTER_PATCH|>"PATCH_LOCATION = 4 # each ViT patch is split into a 4x4 grid of locationsN_PATCH_EXT = 32768 # `<|PATCH_32768|>` is the extended format's end-of-points markerN_SUBPATCH_EXT = 9 # sub-patches per pooled token, up to video's 3x3
# The tags `extract_grounding` decodes, each with its own label / closing-tag rulesTAG_RES = [re.compile(x, re.DOTALL) for x in ( r'<(tracks|bboxes|box3d) coords="([^"]+)">(.*?)</(?:tracks|bboxes|seg|point|box3d)>', r'<(points|trace) coords="([^"]+)"(?:/>|>(?:([^<]*)</(?:points?|trace)>)?)', r'<(seg) coords="([^"]+)"(?:/>|>(?:([^<]*)</seg>)?)', r'<(points3d) coords="([^"]+)"(?:/>|>(?:([^<]*)</points3d>)?)', r'<(pointsn) coords="([^"]+)"(?:/>|>(?:([^<]*)</pointsn>)?)',)]ID_LAST_RE = re.compile(re.escape(POINT_LOC) + r" ?([0-9]+)")DIST_RE = re.compile(r"^\s*(?:1\s+(\d+(?:\.\d+)?)|0(?![\d.]))")NORMAL_RE = re.compile(r"^\s*(?:(0)(?!\S)|([12])\s+(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?))")STANDARD_TOKEN_RE = re.compile(r"(<\|(?:POINT_PATCH|POINT_SUBPATCH|POINT_LOC|SEG_MASK|CENTER_PATCH)\|>)")EXTENDED_TOKEN_RE = re.compile(r"<\|(CENTER_PATCH|PATCH|SUBPATCH|LOC|MASK)(?:_(\d+))?\|>")# Only the extended forms; the standard `<|CENTER_PATCH|>` also matches the pattern aboveEXTENDED_ONLY_RE = re.compile(r"<\|(?:(?:CENTER_PATCH|PATCH|SUBPATCH|LOC)_\d+|MASK)\|>")# A 3D box track's id sits at the box boundary, before the next `<|POINT_PATCH|>`BOX3D_ID_RE = re.compile(r"(?<![\d.])([0-9]+) ?(?=<\|POINT_PATCH\|>)")NUMBER_RE = re.compile(r"-?\d+(?:\.\d+)?")# A predicted camera, `<camera hfov=.. vfov=../>` per image, or the older `<intr vals="1 h v">`CAMERA_TAG_RE = re.compile(r"<camera\s+hfov=(-?[\d.]+)\s+vfov=(-?[\d.]+)\s*/?>")INTR_TAG_RE = re.compile(r'<intr .*?vals="([^"]*)"/?>')INTR_RECORD_SEP_RE = re.compile(r"[;\t:,]")MARKER_RE = re.compile(r'<(points|points3d|pointsn|tracks|seg|box3d|dopoints) id="(\d+)">(.*?)</\1>', re.DOTALL)
# Fields and defaults of each element type, in order; training-only fields of the native# `olmo.message` dataclasses are left outELEMENT_FIELDS = { "points": dict(coordinates=None, label=None, confidence=None, ordered=False), "video_points": dict(coordinates=None, label=None, confidence=None), "points_3d": dict(coordinates=None, label=None, confidence=None), "points_normal": dict(coordinates=None, label=None, confidence=None, flags=None), "video_tracks": dict(coordinates=None, label=None, confidence=None), "segmentation": dict(masks=None, label=None, mm_ids=None, confidence=None), "bounding_boxes_3d": dict(coordinates=None, label=None, K=None, confidence=None),}# One `Box3D` (a `bounding_boxes_3d` coordinate), then the `_norm` companions vLLM addsBOX3D_FIELDS = dict(mm_ix=0, center=None, size=None, rotation=None, time=None, object_id=None, bbox_2d=None, reference_point_2d=None, center_2d=None, depth=None, mask_2d=None)COORDINATE_FIELDS = { "points": ("mm_ix", "x", "y"), "video_points": ("mm_ix", "time", "x", "y"), "points_3d": ("mm_ix", "x", "y", "depth"), "points_normal": ("mm_ix", "x", "y", "nx", "ny", "nz"), "video_tracks": ("mm_ix", "object_id", "time", "x", "y"),}TAG_NAMES = {"points": "points", "points_3d": "points3d", "points_normal": "pointsn", "video_points": "points", "video_tracks": "tracks", "segmentation": "seg", "bounding_boxes_3d": "box3d"}
# Styles the checkpoint was trained to see without their `style: ` prefix (native's# `demo_or_style_v3` with `surface_normal_demo_style`)NO_PREFIX_STYLES = frozenset([ "3d_pointing", "camera_intrinsics", "camera_pose", "correction_qa", "cosyn_point", "long_caption", "multi_image_count_then_point", "multi_image_counting", "multi_image_point_then_count", "multi_image_pointing", "pixmo_seg", "point_count", "point_distance", "point_to_depth", "pointing", "segmentation", "short_caption", "spatial_codes_da", "spatial_da", "spatial_depth_da", "text_sft", "user_qa", "video_clip_caption_start_end", "video_clip_caption_start_end_in_seconds", "video_clip_transcript_start_end", "video_clip_transcript_start_end_in_seconds", "video_count", "video_count_point", "video_frame_caption_timestamp", "video_frame_caption_timestamp_in_seconds", "video_long_caption", "video_point", "video_point_count", "video_point_track_all_frames", "video_point_track_per_frame", "video_point_track_start_end", "video_short_caption", "video_single_point_track_start_end", "video_transcript", "video_multiple_choice", "video_multiple_choice_count_without_pointing", "video_multiple_choice_multiple_correct", "video_multiple_choice_w_subtitle", "a_okvqa_mc", "ai2_diagram", "ai2_diagram_no_letter", "eval_multi_image_mc", "eval_multiple_choice", "mantis_instruct_mc", "multi_image_mc", "multi_image_mc_exp", "science_qa", "spatial_codes_mc", "spatial_depth_mc", "spatial_mc", "points_as_3d_det", "video_points_as_3d_det", "3d_detection_from_jitter", "3d_detection_from_jitter_supervised", "video_box3d_track_per_frame", "video_box3d_ground_start_end", "video_single_box3d_track_per_frame", "surface_normal",])
# The same prompt `Molmo3Processor.apply_chat_template` builds, for servers that format chats with# the tokenizer's template (vLLM). Content items may also be OpenAI-style `image_url` / `video_url`.CHAT_TEMPLATE = ( "{%- set NO_PREFIX = [" + ", ".join(f"'{s}'" for s in sorted(NO_PREFIX_STYLES)) + "] -%}" "{%- set ns = namespace(images=0, n_images=0) -%}" "{%- for message in messages -%}{%- if message['content'] is not string -%}" "{%- for c in message['content'] -%}" "{%- if c['type'] == 'image' or c['type'] == 'image_url' -%}" "{%- set ns.n_images = ns.n_images + 1 -%}{%- endif -%}" "{%- endfor -%}{%- endif -%}{%- endfor -%}" "{%- for message in messages -%}" "{%- if (loop.index0 % 2 == 0 and message['role'] != 'user') or " "(loop.index0 % 2 == 1 and message['role'] != 'assistant') -%}" "{{ raise_exception('roles must alternate user/assistant, starting with user') }}{%- endif -%}" "{%- set m = namespace(text='') -%}" "{%- if message['content'] is string -%}{%- set m.text = message['content'] -%}" "{%- else -%}{%- for c in message['content'] -%}" "{%- if c['type'] == 'text' -%}" "{%- if c['style'] is defined and c['style'] and c['style'] not in NO_PREFIX -%}" "{%- set m.text = m.text ~ c['style'] ~ ': ' ~ c['text'] -%}" "{%- else -%}{%- set m.text = m.text ~ c['text'] -%}{%- endif -%}" "{%- elif c['type'] == 'image' or c['type'] == 'image_url' -%}" "{%- set ns.images = ns.images + 1 -%}" "{%- set m.text = m.text ~ ('Image ' ~ ns.images if ns.n_images > 1 else '') ~ '<|image|>' -%}" "{%- elif c['type'] == 'video' or c['type'] == 'video_url' -%}" "{%- set m.text = m.text ~ '<|video|>' -%}{%- endif -%}" "{%- endfor -%}{%- endif -%}" "{%- if message['role'] == 'user' -%}" "{{ ('<|im_end|>\n' if not loop.first else '') ~ '<|im_start|>user\n' ~ m.text ~ '<|im_end|>\n' }}" "{%- else -%}{{ '<|im_start|>assistant\n' ~ m.text }}{%- endif -%}" "{%- endfor -%}" "{%- if add_generation_prompt -%}{{ '<|im_start|>assistant\n' }}{%- endif -%}")
CROP_SIZE = 378PATCH_SIZE = 14GRID = CROP_SIZE // PATCH_SIZE # ViT patches per crop sideN_PATCHES = GRID * GRIDOVERLAP_MARGINS = (4, 4)IMAGE_POOLING = 2VIDEO_POOLING = 3
# ───────────────────────────── images ─────────────────────────────
def resize(image: np.ndarray, size) -> np.ndarray: """uint8 `[..., H, W, 3]` -> uint8 `[..., h, w, 3]`, bilinear without antialiasing.""" x = torch.from_numpy(np.array(image, dtype=np.uint8)) x = x.permute(2, 0, 1) if x.ndim == 3 else x.permute(0, 3, 1, 2) x = torchvision.transforms.Resize(list(size), torchvision.transforms.InterpolationMode.BILINEAR, antialias=False)(x) x = torch.clip(x, 0, 255).to(torch.uint8) return (x.permute(1, 2, 0) if x.ndim == 3 else x.permute(0, 2, 3, 1)).numpy()
def patchify(crops: np.ndarray) -> np.ndarray: """`[n, H, W, 3]` -> `[n, n_patches, PATCH_SIZE**2 * 3]`.""" n, h, w, c = crops.shape x = crops.reshape(n, h // PATCH_SIZE, PATCH_SIZE, w // PATCH_SIZE, PATCH_SIZE, c) return x.transpose(0, 1, 3, 2, 4, 5).reshape(n, -1, PATCH_SIZE * PATCH_SIZE * c)
def pool_windows(idx: np.ndarray, pool: int) -> np.ndarray: """Group a `[h, w]` patch index grid into `[ceil(h/pool) * ceil(w/pool), pool*pool]` windows.""" h_pad = -idx.shape[0] % pool w_pad = -idx.shape[1] % pool idx = np.pad(idx, [[h_pad // 2, (h_pad + 1) // 2], [w_pad // 2, (w_pad + 1) // 2]], constant_values=-1) h, w = idx.shape[0] // pool, idx.shape[1] // pool return idx.reshape(h, pool, w, pool).transpose(0, 2, 1, 3).reshape(h * w, pool * pool)
def select_tiling(h: float, w: float, tile: int, max_crops: int) -> np.ndarray: tilings = sorted(((i, j) for i in range(1, max_crops + 1) for j in range(1, max_crops + 1) if i * j <= max_crops), key=lambda x: (x[0] * x[1], x[0])) tilings = np.array(tilings, dtype=np.int32) with np.errstate(divide="ignore"): scale = np.min((tilings * tile).astype(np.float32) / np.array([h, w], np.float32), -1) if np.all(scale < 1): return tilings[np.argmax(scale)] # forced to downscale, so downscale as little as possible return tilings[np.argmin(np.where(scale < 1.0, 10e9, scale))]
def image_layout(height: int, width: int, max_crops: int) -> dict: """Everything about how an image is tiled that does not depend on its pixels.""" left, right = OVERLAP_MARGINS margin_px = PATCH_SIZE * (left + right) window = (GRID - left - right) * PATCH_SIZE tiling = select_tiling(height - margin_px, width - margin_px, window, max_crops)
# For each crop, which of its patches lie outside the overlap margins crops = [] for i in range(tiling[0]): for j in range(tiling[1]): idx = np.arange(N_PATCHES).reshape(GRID, GRID) + len(crops) * N_PATCHES if i != 0: idx[:left, :] = -1 if j != 0: idx[:, :left] = -1 if i != tiling[0] - 1: idx[-right:, :] = -1 if j != tiling[1] - 1: idx[:, -right:] = -1 crops.append(idx) resized_hw = (int(tiling[0] * window + margin_px), int(tiling[1] * window + margin_px)) mapping = np.stack(crops).reshape(tiling[0], tiling[1], GRID, GRID).transpose(0, 2, 1, 3).reshape(-1) # `mapping[y, x]` is the ViT patch for each patch of the resized image; the global crop goes first mapping = mapping[mapping >= 0].reshape(resized_hw[0] // PATCH_SIZE, resized_hw[1] // PATCH_SIZE) mapping = mapping + N_PATCHES
global_pooling = pool_windows(np.arange(N_PATCHES).reshape(GRID, GRID), IMAGE_POOLING) token_pooling = np.concatenate([global_pooling, pool_windows(mapping, IMAGE_POOLING)]) n_global = -(-GRID // IMAGE_POOLING) grid_h, grid_w = -(-mapping.shape[0] // IMAGE_POOLING), -(-mapping.shape[1] // IMAGE_POOLING)
# (t, h, w) of each ViT patch: t=0 for the global crop, t=1 for the high-res crops n_crops = 1 + len(crops) pos = np.zeros((n_crops, N_PATCHES, 3), dtype=np.int64) pos[0, :, 1], pos[0, :, 2] = np.divmod(np.arange(N_PATCHES), GRID) hh, ww = np.indices(mapping.shape) flat = mapping.reshape(-1) pos[flat // N_PATCHES, flat % N_PATCHES] = np.stack( [np.ones_like(flat), hh.reshape(-1), ww.reshape(-1)], -1) return dict(tiling=tiling, resized_hw=resized_hw, window=window, mapping=mapping, token_pooling=token_pooling, patch_pos_ids=pos, n_global_tokens=n_global ** 2, grid=(n_global, n_global, grid_h, grid_w))
def image_tokens(grid) -> str: low_h, low_w, h, w = grid return (LOW_RES_IMAGE_START_TOKEN + IMAGE_LOW_RES_TOKEN * (low_h * low_w) + IM_END_TOKEN + IM_START_TOKEN + (IMAGE_PATCH_TOKEN * w + IM_COL_TOKEN) * h + IM_END_TOKEN)
def preprocess_image(image, max_crops: int) -> dict: image = np.asarray(image.convert("RGB") if isinstance(image, Image.Image) else image) if image.dtype != np.uint8: raise ValueError("images must be PIL images or uint8 arrays") layout = image_layout(image.shape[0], image.shape[1], max_crops) src = resize(image, layout["resized_hw"]) crops = [resize(image, (CROP_SIZE, CROP_SIZE))] window = layout["window"] for i in range(layout["tiling"][0]): for j in range(layout["tiling"][1]): crops.append(src[i * window:i * window + CROP_SIZE, j * window:j * window + CROP_SIZE]) return dict(pixels=patchify(np.stack(crops)), token_pooling=layout["token_pooling"], patch_pos_ids=layout["patch_pos_ids"], tokens=image_tokens(layout["grid"]))
# ───────────────────────────── video ─────────────────────────────
def sample_times(duration: float, max_frames: int, max_fps: float) -> np.ndarray: """Every `1/max_fps` seconds, or `max_frames` evenly spaced times when that would not fit.""" if max_frames / max_fps >= duration: times = np.arange(0.0, duration, 1 / max_fps) else: times = np.linspace(0, duration, num=max_frames, endpoint=False, dtype=np.float64) return times if len(times) else np.zeros(1)
def load_video(path: str, max_frames: int = 128, max_fps: float = 2.0) -> dict: """Decode the frames to show the model; returns `{"frames": [T, H, W, 3] uint8, "timestamps": [T]}`.""" try: from torchcodec.decoders import VideoDecoder except ImportError: return _load_video_pyav(path, max_frames, max_fps) decoder = VideoDecoder(path, seek_mode="exact", num_ffmpeg_threads=0) meta = decoder.metadata times = sample_times(meta.duration_seconds, max_frames, max_fps) offset = meta.begin_stream_seconds_from_content lo, hi = offset + 1e-6, meta.end_stream_seconds_from_content - 1e-6 played = [max(lo, min(hi, float(t) + offset)) for t in times] frames = decoder.get_frames_played_at(played).data.numpy().transpose(0, 2, 3, 1) return dict(frames=frames, timestamps=times)
def _load_video_pyav(path: str, max_frames: int, max_fps: float) -> dict: try: # optional: trust_remote_code requires every import outside a try block import av except ImportError: raise ImportError("video loading needs torchcodec or PyAV (`pip install torchcodec` or `av`)") with av.open(path) as container: stream = container.streams.video[0] frames = list(container.decode(video=0)) start = float(frames[0].pts * stream.time_base) ends = np.array([float(f.pts * stream.time_base) - start for f in frames[1:]]) fps = float(stream.average_rate or stream.guessed_rate) duration = float(frames[-1].pts * stream.time_base) - start + 1 / fps times = sample_times(duration, max_frames, max_fps) ix = np.minimum(np.searchsorted(np.append(ends, duration), times, side="right"), len(frames) - 1) video = np.stack([frames[i].to_ndarray(format="rgb24") for i in ix]) return dict(frames=video, timestamps=times)
def preprocess_video(video: dict) -> dict: frames, times = np.asarray(video["frames"]), np.asarray(video["timestamps"]) n = len(frames) pooling = pool_windows(np.arange(N_PATCHES).reshape(GRID, GRID), VIDEO_POOLING) token_pooling = np.concatenate([pooling + i * N_PATCHES for i in range(n)]) pos = np.stack(np.indices((n, GRID, GRID)), -1).reshape(n, N_PATCHES, 3) per_frame = IMAGE_PATCH_TOKEN * len(pooling) tokens = FRAME_START_TOKEN + "".join( f"{' ' if i else ''}{t:.1f} " + per_frame for i, t in enumerate(times)) + FRAME_END_TOKEN return dict(pixels=patchify(resize(frames, (CROP_SIZE, CROP_SIZE))), token_pooling=token_pooling, patch_pos_ids=pos, tokens=tokens)
def mask_to_rle(mask: np.ndarray) -> dict: """A boolean `[H, W]` mask as COCO compressed RLE, as `pycocotools.mask.encode` writes it.""" h, w = mask.shape flat = np.asarray(mask, dtype=bool).reshape(-1, order="F") change = np.flatnonzero(flat[1:] != flat[:-1]) + 1 runs = np.diff(np.concatenate([[0], change, [flat.size]])).tolist() if flat.size and flat[0]: runs = [0] + runs chars = [] for i, x in enumerate(runs): x = int(x) - (int(runs[i - 2]) if i > 2 else 0) more = True while more: c = x & 0x1F x >>= 5 more = x != -1 if c & 0x10 else x != 0 chars.append(chr((c | 0x20 if more else c) + 48)) return {"size": [int(h), int(w)], "counts": "".join(chars)}
def rle_to_mask(rle: dict) -> np.ndarray: """COCO compressed RLE (as in `decode` output) -> a boolean `[H, W]` mask.""" h, w = rle["size"] s, counts, p = rle["counts"], [], 0 while p < len(s): x = k = 0 more = True while more: c = ord(s[p]) - 48 x |= (c & 0x1F) << (5 * k) more = bool(c & 0x20) p, k = p + 1, k + 1 if not more and c & 0x10: x |= -1 << (5 * k) counts.append(x + (counts[-2] if len(counts) > 2 else 0)) flat = np.zeros(h * w, dtype=bool) pos = 0 for i, c in enumerate(counts): flat[pos:pos + c] = i % 2 == 1 pos += c return flat.reshape((h, w), order="F")
def extended_grounding_tokens() -> List[str]: """The extended grounding tokens in id order: `<|PATCH_n|>` (the last one is end-of-points), `<|SUBPATCH_n|>`, `<|LOC_n|>`, `<|MASK|>` and `<|CENTER_PATCH_n|>`.""" return ([f"<|PATCH_{i}|>" for i in range(N_PATCH_EXT + 1)] + [f"<|SUBPATCH_{i}|>" for i in range(N_SUBPATCH_EXT)] + [f"<|LOC_{i}|>" for i in range(PATCH_LOCATION ** 2)] + ["<|MASK|>"] + [f"<|CENTER_PATCH_{i}|>" for i in range(N_PATCH_EXT + 1)])
def add_extended_tokens(tokenizer, vocab_size: int) -> int: """Mint the extended grounding tokens right after the model's `vocab_size` rows, where vLLM reads them; returns how many were added (0 if they already are).
Non-special, so they survive `skip_special_tokens`. This processor never tokenizes them: it rejects them in text and takes groundings as `Molmo3Grounding` instead. """ tokens = extended_grounding_tokens() if tokenizer.convert_tokens_to_ids(tokens[0]) == vocab_size: return 0 if len(tokenizer) != vocab_size: raise ValueError(f"the tokenizer has {len(tokenizer)} tokens, so the extended tokens would " f"not start at {vocab_size}, after the model's vocabulary") from tokenizers import AddedToken added = tokenizer.add_tokens([AddedToken(t, special=False, normalized=False) for t in tokens], special_tokens=False) assert tokenizer.convert_tokens_to_ids(tokens[0]) == vocab_size return added
def merge_groundings(groundings) -> Optional[Molmo3Grounding]: """One chat's message groundings, in order, as one; None when there are none.""" groundings = [g for g in groundings if g is not None] if not groundings: return None return Molmo3Grounding(point_ids=[p for g in groundings for p in g.point_ids], mask_anchors=[a for g in groundings for a in g.mask_anchors], mask_scores=[])
def media_metadata(images=None, video=None, max_crops: int = 8) -> list: """Per image, or for the one video, the layout grounding is decoded and encoded against.
Reads no pixels: `images` are PIL images, uint8 arrays or `(width, height)` sizes, and `video` is a `load_video` dict or `{"size": (width, height), "timestamps": [...]}`. """ if video is not None: if "frames" in video: n, h, w = np.asarray(video["frames"]).shape[:3] else: (w, h), n = video["size"], len(video["timestamps"]) pooling = pool_windows(np.arange(N_PATCHES).reshape(GRID, GRID), VIDEO_POOLING) return [dict(size=(w, h), timestamps=np.asarray(video["timestamps"], dtype=np.float64), token_pooling=np.concatenate([pooling + i * N_PATCHES for i in range(n)]))] metadata = [] for image in images or []: if isinstance(image, Image.Image): w, h = image.size elif isinstance(image, (tuple, list)): w, h = (int(v) for v in image) else: h, w = np.asarray(image).shape[:2] layout = image_layout(h, w, max_crops) mapping = layout["mapping"] inverse = {int(v): divmod(i, mapping.shape[1]) for i, v in enumerate(mapping.reshape(-1))} metadata.append(dict(size=(w, h), mapping=mapping, mapping_shape=mapping.shape, inverse=inverse, token_pooling=layout["token_pooling"], n_global_tokens=layout["n_global_tokens"])) return metadata
# ───────────────────────────── processor ─────────────────────────────
class Molmo3Processor: config_keys = ("max_crops", "max_frames", "max_fps")
def __init__(self, tokenizer, max_crops: int = 8, max_frames: int = 128, max_fps: float = 2.0): self.tokenizer = tokenizer self.max_crops = max_crops self.max_frames = max_frames self.max_fps = max_fps
# so trust_remote_code users, who cannot import this module, still reach the mask helpers rle_to_mask = staticmethod(rle_to_mask) mask_to_rle = staticmethod(mask_to_rle)
@classmethod def register_for_auto_class(cls, auto_class="AutoProcessor"): """Called by AutoProcessor when loading with trust_remote_code; nothing to register."""
@classmethod def from_pretrained(cls, path, **kwargs): hub_kwargs = {k: kwargs.pop(k) for k in ("revision", "token", "cache_dir") if k in kwargs} config_file = cached_file(path, "processor_config.json", **hub_kwargs) with open(config_file) as f: config = cls._read_config(json.load(f)) config.update({k: kwargs.pop(k) for k in cls.config_keys if k in kwargs}) tokenizer = AutoTokenizer.from_pretrained(path, **hub_kwargs, **kwargs) return cls(tokenizer, **config)
@staticmethod def _sub_config(pooling: int, **extra) -> dict: """The fixed preprocessing settings, in the transformers-native processor config layout.""" return dict(do_convert_rgb=True, do_normalize=True, do_rescale=True, do_resize=True, image_mean=[0.5] * 3, image_std=[0.5] * 3, patch_size=PATCH_SIZE, pooling_size=[pooling, pooling], resample=2, rescale_factor=1 / 255, size={"height": CROP_SIZE, "width": CROP_SIZE}, **extra)
@classmethod def _read_config(cls, config: dict) -> dict: """Our settings from a processor config, either layout; raises on fixed settings we don't match.""" if "image_processor" not in config: # this repo's older flat layout return {k: v for k, v in config.items() if k in cls.config_keys} image, video = config["image_processor"], config.get("video_processor", {}) expected = [(image, cls._sub_config(IMAGE_POOLING, overlap_margins=list(OVERLAP_MARGINS))), (video, cls._sub_config(VIDEO_POOLING))] for sub, fixed in expected: for k, v in fixed.items(): if k in sub and sub[k] != v and not (isinstance(v, float) and abs(sub[k] - v) < 1e-9): raise ValueError(f"processor setting {k}={sub[k]!r} is not supported (only {v!r})") out = {"max_crops": image.get("max_crops"), "max_frames": video.get("num_frames"), "max_fps": video.get("max_fps")} return {k: v for k, v in out.items() if v is not None}
def save_pretrained(self, path): os.makedirs(path, exist_ok=True) self.tokenizer.save_pretrained(path) config = dict( image_processor=self._sub_config( IMAGE_POOLING, image_processor_type="Molmo2ImageProcessor", max_crops=self.max_crops, overlap_margins=list(OVERLAP_MARGINS)), processor_class="Molmo3Processor", subpatch_location_size=4, video_processor=self._sub_config( VIDEO_POOLING, video_processor_type="Molmo3VideoProcessor", do_sample_frames=True, max_fps=self.max_fps, num_frames=self.max_frames, return_metadata=False)) with open(os.path.join(path, "processor_config.json"), "w") as f: json.dump(config, f, indent=2, sort_keys=True)
def load_video(self, path: str) -> dict: return load_video(path, self.max_frames, self.max_fps)
def apply_chat_template(self, conversation: list, add_generation_prompt: bool = True, tokenize: bool = False, images=None, videos=None, return_tensors: Optional[str] = "pt"): """Format a chat, or a batch of chats, as a prompt; with `tokenize=True` also run the processor on it and return the model inputs.
Messages are `{"role", "content", "grounding"?}`, alternating user / assistant. Content is a string or a list of `{"type": "image"}` / `{"type": "video"}` (consuming `images` / `videos` in order) and `{"type": "text", "text", "style"?}` items; a `style` is prefixed as "style: text". A message whose text has grounding tokens needs the matching `Molmo3Grounding` as `grounding`: for an earlier answer, the message `answer_message` builds, or text and grounding from `encode_document`. Put images and videos first, as in training. """ batched = bool(conversation) and isinstance(conversation[0], (list, tuple)) convs = conversation if batched else [conversation] prompts = [self._format_chat(conv, add_generation_prompt) for conv in convs] groundings = [merge_groundings([m.get("grounding") for m in conv]) for conv in convs] if not tokenize: if any(g is not None for g in groundings): raise ValueError("a grounding cannot be carried in a prompt string; use tokenize=True") return prompts if batched else prompts[0] return self(prompts if batched else prompts[0], images=images, videos=videos, grounding=groundings if batched else groundings[0], return_tensors=return_tensors)
def _format_chat(self, messages, add_generation_prompt) -> str: n_images = sum(1 for m in messages if isinstance(m["content"], list) for c in m["content"] if c.get("type") == "image") prompt, on_image = "", 0 for ix, message in enumerate(messages): role = message["role"] if role != ("user" if ix % 2 == 0 else "assistant"): raise ValueError("roles must alternate user/assistant, starting with user") content = message["content"] if isinstance(content, str): text = content else: text = "" for item in content: kind = item.get("type") if kind == "image": on_image += 1 text += (f"Image {on_image}" if n_images > 1 else "") + IMAGE_PROMPT elif kind == "video": text += VIDEO_PROMPT elif kind == "text": style = item.get("style") text += (f"{style}: {item['text']}" if style and style not in NO_PREFIX_STYLES else item["text"]) else: raise ValueError(f"unknown content type {kind}") if role == "user": prompt += ("<|im_end|>\n" if ix else "") + f"<|im_start|>user\n{text}<|im_end|>\n" else: prompt += f"<|im_start|>assistant\n{text}" if add_generation_prompt: prompt += "<|im_start|>assistant\n" return prompt
def encode_document(self, document, images=None, videos=None): """A grounding document -> `(text, Molmo3Grounding)` for a message's content and grounding.
`document` is what `decode` returns (or its JSON string): each `<points id="N">` marker in its `text` becomes element N's tag, and elements no marker names are appended. An element with its `text` is used as is; a points element can instead give `coordinates` in pixels (`x`, `y`) or normalized (`x_norm`, `y_norm`), plus `time` for a video, which needs the chat's `images` / `videos`. A bare element or list of elements gives just the tags. """ text, rows = self._parse_extended(self.render_document(document, images, videos)) return text, Molmo3Grounding(point_ids=[r for r in rows if r[1] >= 0], mask_anchors=[r[0] for r in rows if r[1] < 0], mask_scores=[])
def render_document(self, document, images=None, videos=None, seen_images: Optional[int] = None) -> str: """`encode_document`'s text before it is split from its grounding: every grounding in extended tokens, the format vLLM takes in a prompt. `images` may be `(width, height)` sizes and a video `{"size", "timestamps"}`. A point may name only the first `seen_images` images (default: all of them).""" if isinstance(document, str): document = json.loads(document) if isinstance(document, list) or "multi_modal" not in document: document = {"text": None, "multi_modal": document} videos = [self.load_video(v) if isinstance(v, str) else v for v in videos or []] metadata = None
def render(element): nonlocal metadata if isinstance(element.get("text"), str): return element["text"] if metadata is None: metadata = self._mm_metadata(images, videos[0] if videos else None) return self._render_points(element, metadata, len(metadata) if seen_images is None else seen_images)
return self._render_document(document, render)
@staticmethod def _render_document(document, render) -> str: """A `{"text", "multi_modal"}` document as prompt text: each `<points id="N">` marker replaced by element N, and elements no marker names appended after a space.""" elements = document.get("multi_modal") or [] elements = [elements] if isinstance(elements, dict) else elements # A predicted camera's tag is already in the text elements = [e for e in elements if e.get("type") != "camera_intrinsics"] by_id = {e.get("grounding_id"): e for e in elements if e.get("grounding_id") is not None} used = set()
def substitute(match): number = int(match.group(2)) if number not in by_id: return match.group(0) used.add(number) return render(by_id[number])
text = document.get("text") placed = MARKER_RE.sub(substitute, text) if text else "" trailing = "".join(render(e) for e in elements if e.get("grounding_id") not in used) if not trailing: return placed if text is None: return trailing return placed + ("" if not placed or placed[-1].isspace() else " ") + trailing
def _render_points(self, element, metadata, seen_images) -> str: """A points element given by coordinates as the tag an answer uses, in extended tokens.""" if element.get("type") not in (None, "points", "video_points"): raise ValueError(f"a {element.get('type')} element needs its `text`; only points can be " "given by coordinates") if not metadata: raise ValueError("a point was given but the chat has no image or video") is_video = "timestamps" in metadata[0] triples = [] for c in element.get("coordinates") or []: index = int(c.get("mm_ix", c.get("mm_id", 0))) if not 0 <= index < len(metadata): raise ValueError(f"a point refers to image {index}, but there are {len(metadata)}") if not is_video and index >= seen_images: raise ValueError("a point refers to an image that comes after it; put images first") w, h = metadata[index]["size"] if "x" in c and "y" in c: x, y = float(c["x"]), float(c["y"]) elif "x_norm" in c and "y_norm" in c: x, y = float(c["x_norm"]) * w, float(c["y_norm"]) * h else: raise ValueError(f"a point needs x and y, or x_norm and y_norm; got {sorted(c)}") where = float(c.get("time", 0.0)) if is_video else index triples.append(self._pixels_to_ids(where, x, y, metadata, is_video)) coords = "".join(f"<|PATCH_{t}|><|SUBPATCH_{s}|><|LOC_{l}|>{i + 1}" for i, (t, s, l) in enumerate(sorted(triples))) coords += f"<|PATCH_{N_PATCH_EXT}|>" label = element.get("label") return f'<points coords="{coords}">{label}</points>' if label else f'<points coords="{coords}"/>'
def __call__(self, text: Union[str, List[str]], images=None, videos=None, grounding=None, return_tensors: Optional[str] = "pt") -> BatchFeature: """`text` holds one `<|image|>` / `<|video|>` per image / video, each consumed in order across the batch. A video is a path or a `load_video`-style dict.
`grounding` is a `Molmo3Grounding` per text (or one for a single text) whose ids match the text's grounding tokens in order; they become `input_point_ids`. """ texts = [text] if isinstance(text, str) else list(text) groundings = grounding if isinstance(grounding, (list, tuple)) else [grounding] * len(texts) if len(groundings) != len(texts): raise ValueError(f"{len(groundings)} groundings for {len(texts)} texts") images, videos = list(images or []), list(videos or []) split_re = "(" + "|".join(re.escape(t) for t in (IMAGE_PROMPT, VIDEO_PROMPT)) + ")" examples, point_ids = [], [] for t, g in zip(texts, groundings): if EXTENDED_ONLY_RE.search(t): raise ValueError("extended grounding tokens in text; convert the document with " "`encode_document` and pass its grounding") rows = self._grounding_rows(t, g) parts, pieces = [], re.split(split_re, t) for i, piece in enumerate(pieces): if piece == IMAGE_PROMPT: part = preprocess_image(images.pop(0), self.max_crops) elif piece == VIDEO_PROMPT: video = videos.pop(0) part = preprocess_video(self.load_video(video) if isinstance(video, str) else video) else: continue pieces[i] = part["tokens"] parts.append(part) n_tokens = sum(len(p["token_pooling"]) for p in parts) if rows and (not parts or max(r[0] for r in rows) >= n_tokens): raise ValueError("a grounding refers to an image token this prompt does not have") point_ids.append(rows) examples.append(("".join(pieces), parts)) if images or videos: raise ValueError("more images/videos than placeholders in the text")
ids = [self.tokenizer.encode(t, add_special_tokens=False) for t, _ in examples] seq_len = max(len(x) for x in ids) pad = self.tokenizer.pad_token_id out = dict( input_ids=np.array([[pad] * (seq_len - len(x)) + x for x in ids], dtype=np.int64), attention_mask=np.array([[0] * (seq_len - len(x)) + [1] * len(x) for x in ids], dtype=np.int64), ) if any(parts for _, parts in examples): out.update(self._batch_visual([parts for _, parts in examples])) if any(point_ids): arr = np.full((len(point_ids), max(len(x) for x in point_ids), 3), -1, dtype=np.int64) for b, x in enumerate(point_ids): if x: arr[b, :len(x)] = x out["input_point_ids"] = arr return BatchFeature(out, tensor_type=return_tensors)
@staticmethod def _grounding_rows(text, grounding) -> list: """The `input_point_ids` rows for `text`'s grounding blocks: the next of `grounding.point_ids` for each point and (anchor, -1, -1) for each mask, in order.""" adjacent = list(re.finditer( "(" + "|".join(re.escape(t) for t in (POINT_PATCH, CENTER_PATCH)) + ")" "(" + re.escape(POINT_SUBPATCH) + "|" + re.escape(SEG_MASK) + ")", text)) if grounding is None: if adjacent: raise ValueError("this text has grounding tokens but no `grounding`; pass the " "Molmo3Grounding they came with") return [] points, anchors = list(grounding.point_ids), list(grounding.mask_anchors) n_points = sum(m.group(2) == POINT_SUBPATCH for m in adjacent) if n_points != len(points) or len(adjacent) - n_points != len(anchors): raise ValueError(f"the text has {n_points} points and {len(adjacent) - n_points} masks, " f"but the grounding has {len(points)} and {len(anchors)}") rows = [] for m in adjacent: rows.append(tuple(int(v) for v in points.pop(0)[:3]) if m.group(2) == POINT_SUBPATCH else (int(anchors.pop(0)), -1, -1)) return rows
@staticmethod def _parse_extended(text): """Extended grounding tokens -> standard ones, plus a (patch, subpatch, loc) row per point and an (anchor, -1, -1) row per mask, in order.""" out, rows, at = [], [], 0 tokens = list(EXTENDED_TOKEN_RE.finditer(text)) i = 0 while i < len(tokens): m = tokens[i] kind, index = m.group(1), m.group(2) if kind not in ("PATCH", "CENTER_PATCH") or index is None: raise ValueError(f"grounding: {m.group(0)} does not follow a patch token") patch_token = POINT_PATCH if kind == "PATCH" else CENTER_PATCH out.append(text[at:m.start()]) nxt = [t for t in tokens[i + 1:i + 3]] follows = lambda k, j: (j < len(nxt) and nxt[j].group(1) == k and nxt[j].start() == (nxt[j - 1].end() if j else m.end())) if int(index) == N_PATCH_EXT: out.append(patch_token) at, i = m.end(), i + 1 elif follows("MASK", 0): out.append(patch_token + SEG_MASK) rows.append((int(index), -1, -1)) at, i = nxt[0].end(), i + 2 elif follows("SUBPATCH", 0) and follows("LOC", 1): out.append(patch_token + POINT_SUBPATCH + POINT_LOC) rows.append((int(index), int(nxt[0].group(2)), int(nxt[1].group(2)))) at, i = nxt[1].end(), i + 3 else: raise ValueError(f"grounding: {m.group(0)} is not followed by a sub-patch and " "location, or a mask") out.append(text[at:]) return "".join(out), rows
@staticmethod def _pixels_to_ids(where, x, y, metadata, is_video): """Pixel coordinates -> (token, subpatch, location) ids, the inverse of `_point_to_pixels`.""" if is_video: meta = metadata[0] frame = int(np.argmin(np.abs(meta["timestamps"] - where))) mapping = np.arange(N_PATCHES).reshape(GRID, GRID) + frame * N_PATCHES offset = 0 else: meta = metadata[int(where)] mapping = meta["mapping"] offset = sum(len(m["token_pooling"]) for m in metadata[:int(where)]) w, h = meta["size"] ph, pw = mapping.shape px, py = pw * (x / w), ph * (y / h) ix, iy = min(math.floor(px), pw - 1), min(math.floor(py), ph - 1) vit_patch = mapping[iy, ix] token, subpatch = np.argwhere(meta["token_pooling"] == vit_patch)[0] n = PATCH_LOCATION loc = min(math.floor((py - iy) * n), n - 1) + min(math.floor((px - ix) * n), n - 1) * n return int(token) + offset, int(subpatch), int(loc)
@staticmethod def _batch_visual(batch_parts) -> dict: """Concatenate each example's crops/frames, offsetting the pooling indices and the patch `t` positions part by part, then pad across the batch.""" examples = [] for parts in batch_parts: pixels, pooling, pos, n_crops, t_offset = [], [], [], 0, 0 for part in parts: p = part["patch_pos_ids"].copy() p[..., 0] += t_offset used = part["token_pooling"][part["token_pooling"] >= 0] t_offset = int(p.reshape(-1, 3)[used, 0].max()) + 1 pooling.append(np.where(part["token_pooling"] >= 0, part["token_pooling"] + n_crops * N_PATCHES, -1)) pixels.append(part["pixels"]) pos.append(p) n_crops += len(part["pixels"]) examples.append((pixels, pooling, pos)) n_crops = max((sum(len(x) for x in e[0]) for e in examples), default=0) n_tokens = max((sum(len(x) for x in e[1]) for e in examples), default=0) pool = max((x.shape[1] for e in examples for x in e[1]), default=1) pixel_values = np.zeros((len(examples), n_crops, N_PATCHES, PATCH_SIZE ** 2 * 3), np.uint8) token_pooling = np.full((len(examples), n_tokens, pool), -1, np.int64) patch_pos_ids = np.zeros((len(examples), n_crops, N_PATCHES, 3), np.int64) for b, (pixels, pooling, pos) in enumerate(examples): if not pixels: continue pixels, pos = np.concatenate(pixels), np.concatenate(pos) pooling = np.concatenate([np.pad(x, [[0, 0], [0, pool - x.shape[1]]], constant_values=-1) for x in pooling]) pixel_values[b, :len(pixels)] = pixels patch_pos_ids[b, :len(pos)] = pos token_pooling[b, :len(pooling)] = pooling return dict(pixel_values=pixel_values, token_pooling=token_pooling, patch_pos_ids=patch_pos_ids)
# ── decoding ──
def decode(self, token_ids, grounding=None, images=None, video: Optional[dict] = None, mask_threshold: float = 0.5, mode: str = "structured", intrinsics=None): """Decode one generated sequence (without its prompt) into the document vLLM's `json_objects` grounding mode returns.
`{"text", "multi_modal", "type": "text"}`: `text` names each grounding as `<points id="N">label</points>`, and `multi_modal` holds the elements, each with pixel and normalized coordinates (masks as COCO RLE) and its `text`, the tag exactly as generated. `grounding` is the row's `Molmo3Grounding` from `generate(..., return_dict_in_generate=True)`; pass the same `images` (or loaded `video` dict) the prompt used. `encode_document` inverts it.
`mode="json"` returns the document as a JSON string, and `mode="string"` the raw generated text, which carries the groundings only together with `grounding`.
A 3D box's center is lifted into camera coordinates with `intrinsics`: a 3x3 `K` or an `(hfov, vfov)` pair in degrees, for all images or one per image. Without them, an image the model predicted a `<camera>` for uses that, and otherwise a box has only its `center_2d` pixel, `depth`, size and rotation. Predicted cameras are also returned, like vLLM, as a `camera_intrinsics` element (the tag stays in `text`). """ if mode not in ("structured", "json", "string"): raise ValueError(f"mode must be 'structured', 'json' or 'string', not {mode!r}") text = self._answer_text(token_ids) if mode == "string": return text doc = self.decode_text(text, grounding, images=images, video=video, mask_threshold=mask_threshold, intrinsics=intrinsics) return json.dumps(doc) if mode == "json" else doc
def decode_text(self, text: str, grounding=None, images=None, video: Optional[dict] = None, mask_threshold: float = 0.5, intrinsics=None) -> dict: """`decode` from the generated text rather than its ids. `images` may be `(width, height)` sizes and `video` `{"size", "timestamps"}`, since only the layout is needed.""" fovs = self._camera_fovs(text) camera = [] if not any(fovs) else [dict(type="camera_intrinsics", label=None, coordinates=[ dict(mm_ix=i, hfov=fov[0], vfov=fov[1]) for i, fov in enumerate(fovs) if fov is not None])] if grounding is None or not (images or video is not None): return dict(text=text, multi_modal=camera, type="text")
triples = [tuple(int(v) for v in t[:3]) for t in grounding.point_ids] masks = list(grounding.mask_scores) anchors = [int(a) for a in grounding.mask_anchors] metadata = self._mm_metadata(images, video) if intrinsics is None and any(fovs): intrinsics = [fovs[i] if i < len(fovs) else None for i in range(len(metadata))] for meta, K in zip(metadata, self._camera_matrices(intrinsics, metadata)): meta["K"] = K matches = sorted((m for r in TAG_RES for m in r.finditer(text)), key=lambda m: m.start()) parts, elements, on = [], [], 0 for tag in matches: if tag.start() < on: continue before, coords = text[:tag.start()], tag.group(2) t0, m0 = before.count(POINT_LOC), before.count(SEG_MASK) span_triples = triples[t0:t0 + coords.count(POINT_LOC)] n_masks = coords.count(SEG_MASK) element = self._element(tag.group(1), coords, tag.group(3) or None, span_triples, masks[m0:m0 + n_masks], anchors[m0:m0 + n_masks], metadata, mask_threshold) if element is None: continue # left in the text as generated, like vLLM element["text"] = self._extended_tag(tag.group(0), span_triples, anchors[m0:m0 + n_masks]) parts.append(text[on:tag.start()]) on = tag.end() elements.append(element) parts.append(text[on:])
out = [parts[0]] for number, (element, tail) in enumerate(zip(elements, parts[1:]), start=1): element_text = element.pop("text") element["grounding_id"] = number element["text"] = element_text name = TAG_NAMES[element["type"]] out.append(f'<{name} id="{number}">{element.get("label") or ""}</{name}>') out.append(tail) # The first patch choice decides whether the answer grounds anything, so like native its # complement is the first element's confidence if elements and grounding.no_point is not None: elements[0]["confidence"] = 1.0 - grounding.no_point return dict(text="".join(out), multi_modal=elements + camera, type="text")
def answer_message(self, token_ids, grounding=None) -> dict: """The assistant message for a generated answer, to continue the chat: its raw text plus the `Molmo3Grounding` it came with, both trimmed if the answer was cut off mid-tag.""" text = self._answer_text(token_ids) if grounding is None: return {"role": "assistant", "content": text} n_points, n_masks = text.count(POINT_LOC), text.count(SEG_MASK) grounding = Molmo3Grounding(point_ids=list(grounding.point_ids)[:n_points], mask_anchors=list(grounding.mask_anchors)[:n_masks], mask_scores=list(grounding.mask_scores)[:n_masks], no_point=grounding.no_point) return {"role": "assistant", "content": text, "grounding": grounding}
def _answer_text(self, token_ids) -> str: """Generated ids as text, without the stop tokens. An answer that does not end in one was cut off, and like vLLM a trailing tag that never closed is dropped.""" ids = [int(t) for t in token_ids] stop = {self.tokenizer.eos_token_id, self.tokenizer.pad_token_id, self.tokenizer.convert_tokens_to_ids("<|im_end|>")} truncated = not ids or ids[-1] not in stop while ids and ids[-1] in stop: ids.pop() text = self.tokenizer.decode(ids, skip_special_tokens=False) if not truncated: return text cut = len(text) for kind in ("points3d", "pointsn", "points", "trace", "tracks", "bboxes", "seg", "box3d", "dopoints"): at = text.rfind(f'<{kind} coords="') if at >= 0 and f"</{kind}>" not in text[at:] and '"/>' not in text[at:]: cut = min(cut, at) return text[:cut]
def _element(self, kind, coords, label, triples, masks, anchors, metadata, mask_threshold): """One tag as a vLLM `json_objects` element, or None when it decodes to nothing.""" is_video = "timestamps" in metadata[0] if kind == "bboxes": return None # not supported by this port if kind == "box3d" or (kind == "tracks" and CENTER_PATCH in coords): return self._box_element(kind, coords, label, triples, metadata) if kind == "seg": if is_video or not masks: return None decoded, mm_ids = [], [] for i, scores in enumerate(masks): anchor = anchors[i] if i < len(anchors) else 0 decoded.append(self._decode_mask(scores, anchor, metadata, mask_threshold)) mm_ids.append(self._image_of_token(anchor, metadata)) return self._make_element("segmentation", metadata, label=label, masks=[mask_to_rle(m) for m in decoded], mm_ids=None if len(metadata) == 1 else mm_ids)
if kind in ("points3d", "pointsn"): targets = triples else: targets = triples[:len(ID_LAST_RE.findall(coords))] points, kept = [], [] for i, triple in enumerate(targets): point = self._point_to_pixels(triple, metadata) if point is not None: points.append(point) kept.append(i) if not points: return None
if kind in ("points3d", "pointsn"): block = f"{POINT_PATCH}{POINT_SUBPATCH}{POINT_LOC}" groups = [re.sub(r"^\s*\d+", "", g) for g in coords.split(block)[1:]] if kind == "points3d": dists = [] for g in groups: m = DIST_RE.match(g) dists.append(float(m.group(1)) if m and m.group(1) is not None else -1.0) return self._make_element("points_3d", metadata, label=label, coordinates=[ (p.get("image", 0), p["x"], p["y"], dists[i] if i < len(dists) else -1.0) for p, i in zip(points, kept)]) if kind == "pointsn": normals, flags = [], [] for g in groups: m = NORMAL_RE.match(g) unattainable = m is not None and m.group(1) == "0" flags.append(int(m.group(2)) if m is not None and not unattainable else 1) normals.append(None if m is None or unattainable else tuple(float(m.group(j)) for j in (3, 4, 5))) return self._make_element("points_normal", metadata, label=label, coordinates=[ (p.get("image", 0), p["x"], p["y"], *(normals[i] if i < len(normals) and normals[i] else (None,) * 3)) for p, i in zip(points, kept)], flags=[flags[i] if i < len(flags) else 1 for i in kept]) if kind == "tracks": ex_ids = [int(x) for x in ID_LAST_RE.findall(coords)] return self._make_element("video_tracks", metadata, label=label, coordinates=[ (0, ex_ids[i], p["time"], p["x"], p["y"]) for p, i in zip(points, kept)]) if is_video: return self._make_element("video_points", metadata, label=label, coordinates=[ (0, p["time"], p["x"], p["y"]) for p in points]) trace = kind == "trace" return self._make_element("points", metadata, label=label, coordinates=[ (p["image"], p["x"], p["y"]) for p in points], ordered=trace)
@staticmethod def _make_element(kind, metadata, **values) -> dict: element = dict(ELEMENT_FIELDS[kind], **values) if kind in COORDINATE_FIELDS: keys = COORDINATE_FIELDS[kind] named = [] for coord in element["coordinates"]: c = dict(zip(keys, coord)) w, h = metadata[c["mm_ix"]]["size"] if c["mm_ix"] < len(metadata) else (None, None) for key in keys: size = {"x": w, "y": h}.get(key[0]) if key[0] in "xy": c[f"{key}_norm"] = None if size is None or c[key] is None else c[key] / size named.append(c) element["coordinates"] = named element["type"] = kind return element
def _box_element(self, kind, coords, label, triples, metadata) -> Optional[dict]: """A `<box3d>` tag, or a `<tracks>` of boxes, as a `bounding_boxes_3d` element.
Each box is an optional anchor point, its center point, then `log(depth) W H L` and a 6D rotation; the center is lifted into the camera frame when its image has a `K`.""" is_video = "timestamps" in metadata[0] anchor_block = f"{POINT_PATCH}{POINT_SUBPATCH}{POINT_LOC}" center_block = f"{CENTER_PATCH}{POINT_SUBPATCH}{POINT_LOC}" stride, delim = (2, anchor_block + center_block) if anchor_block in coords else (1, center_block) track_ids = [int(m.group(1)) for m in BOX3D_ID_RE.finditer(coords)] if kind == "tracks" else [] # Group points by emitted index, so a point that cannot be placed does not shift the roles by_box = {} for i, triple in enumerate(triples): point = self._point_to_pixels(triple, metadata) if point is not None: box_ix, role = divmod(i, stride) by_box.setdefault(box_ix, {})["center" if role == stride - 1 else "anchor"] = point boxes, box_K = [], None for box_ix, group in enumerate(coords.split(delim)[1:]): entry = by_box.get(box_ix, {}) nums = [float(v) for v in NUMBER_RE.findall(group)[:10]] if "center" not in entry or len(nums) < 10: continue c, anchor = entry["center"], entry.get("anchor") mm_ix = 0 if is_video else c["image"] meta = metadata[mm_ix] depth = math.exp(nums[0]) center, K = None, meta.get("K") if K is not None: center = [depth * (c["x"] - K[0][2]) / K[0][0], depth * (c["y"] - K[1][2]) / K[1][1], depth] box_K = K a1, a2 = np.array(nums[4:7]), np.array(nums[7:10]) b1 = a1 / np.linalg.norm(a1) b2 = a2 - b1.dot(a2) * b1 b2 = b2 / np.linalg.norm(b2) rotation = np.stack([b1, b2, np.cross(b1, b2)], axis=1).tolist() box = dict(BOX3D_FIELDS, mm_ix=mm_ix, center=center, size=nums[1:4], rotation=rotation, time=c["time"] if is_video else None, object_id=track_ids[box_ix] if box_ix < len(track_ids) else None, reference_point_2d=[anchor["x"], anchor["y"]] if anchor else None, center_2d=[c["x"], c["y"]], depth=depth) w, h = meta["size"] for key in ("center_2d", "reference_point_2d", "bbox_2d"): box[f"{key}_norm"] = None if box[key] is None else [ v / (w if i % 2 == 0 else h) for i, v in enumerate(box[key])] boxes.append(box) if not boxes: return None return self._make_element("bounding_boxes_3d", metadata, coordinates=boxes, label=label, K=box_K)
@staticmethod def _camera_fovs(text) -> list: """`(hfov, vfov)` per predicted camera in `text`, in order; None for an invalid one.""" def pair(h, v): try: h, v = float(h), float(v) except ValueError: # a malformed number, e.g. `1.2.3` return None return (h, v) if 0 < h < 180 and 0 < v < 180 else None
found = [pair(h, v) for h, v in CAMERA_TAG_RE.findall(text)] if not found and (m := INTR_TAG_RE.search(text)): for record in INTR_RECORD_SEP_RE.split(m.group(1)): toks = record.split() if len(toks) == 3 and toks[0].isdigit(): found.append(pair(toks[1], toks[2])) return found
@staticmethod def _camera_matrices(intrinsics, metadata) -> list: """A 3x3 `K` (as lists) or None per image, from a K or (hfov, vfov) for all or per image.""" def shape(value): try: return np.shape(value) except ValueError: # a per-image list mixing None and values return None
if intrinsics is None: return [None] * len(metadata) if shape(intrinsics) in ((3, 3), (2,)): intrinsics = [intrinsics] * len(metadata) if len(intrinsics) != len(metadata): raise ValueError(f"got intrinsics for {len(intrinsics)} images, but there are {len(metadata)}") out = [] for value, meta in zip(intrinsics, metadata): if value is None or shape(value) == (3, 3): out.append(None if value is None else np.asarray(value, dtype=np.float64).tolist()) continue if shape(value) != (2,): raise ValueError(f"intrinsics must be a 3x3 K or (hfov, vfov), got {value!r}") (w, h), (hfov, vfov) = meta["size"], value fx = w / 2 / math.tan(math.radians(hfov) / 2) fy = h / 2 / math.tan(math.radians(vfov) / 2) out.append([[fx, 0.0, w / 2], [0.0, fy, h / 2], [0.0, 0.0, 1.0]]) return out
@staticmethod def _image_of_token(token, metadata) -> int: offset = 0 for image_ix, meta in enumerate(metadata): offset += len(meta["token_pooling"]) if token < offset: return image_ix return len(metadata) - 1
@staticmethod def _extended_tag(span, triples, anchors) -> str: """A generated tag in the extended format: each point as `<|PATCH_n|><|SUBPATCH_s|><|LOC_l|>`, each mask as `<|PATCH_anchor|><|MASK|>`, and end-of-points as `<|PATCH_32768|>`.""" pieces = [p for p in STANDARD_TOKEN_RE.split(span) if p] grounding = {POINT_PATCH, POINT_SUBPATCH, POINT_LOC, SEG_MASK, CENTER_PATCH} out = list(pieces) name = lambda patch, n: f"<|PATCH_{n}|>" if patch == POINT_PATCH else f"<|CENTER_PATCH_{n}|>" patch_at = sub_at = patch = None on_triple = on_mask = 0 for pos, piece in enumerate(pieces): following = pieces[pos + 1] if pos + 1 < len(pieces) else None if piece in (POINT_PATCH, CENTER_PATCH): if following not in grounding: out[pos] = name(piece, N_PATCH_EXT) patch_at = sub_at = None continue patch_at, patch, sub_at = pos, piece, None elif piece == POINT_SUBPATCH: sub_at = pos elif piece == SEG_MASK: if on_mask < len(anchors): if patch_at is not None: out[patch_at] = name(patch, anchors[on_mask]) out[pos] = "<|MASK|>" on_mask += 1 patch_at = sub_at = None elif piece == POINT_LOC: if on_triple >= len(triples): raise ValueError("more location tokens than recorded points") t, sp, loc = triples[on_triple] on_triple += 1 if patch_at is not None and sub_at is not None: out[patch_at] = name(patch, t) out[sub_at] = f"<|SUBPATCH_{sp}|>" out[pos] = f"<|LOC_{loc}|>" patch_at = sub_at = None return "".join(out)
def _mm_metadata(self, images, video) -> list: return media_metadata(images, video, self.max_crops)
def _point_to_pixels(self, triple, metadata) -> Optional[dict]: token, subpatch, loc = triple n = PATCH_LOCATION dx, dy = (loc // n + 0.5) / n, (loc % n + 0.5) / n if "timestamps" in metadata[0]: meta = metadata[0] if not (0 <= token < len(meta["token_pooling"])): return None vit_patch = int(meta["token_pooling"][token, subpatch]) frame, (y, x) = divmod(vit_patch, N_PATCHES)[0], divmod(vit_patch % N_PATCHES, GRID) w, h = meta["size"] return dict(time=float(meta["timestamps"][frame]), x=(x + dx) / GRID * w, y=(y + dy) / GRID * h) offset = 0 for image_ix, meta in enumerate(metadata): n_tokens = len(meta["token_pooling"]) if token < offset + n_tokens: break offset += n_tokens else: return None pooling = meta["token_pooling"] if subpatch >= pooling.shape[1]: return None rc = meta["inverse"].get(int(pooling[token - offset, subpatch])) if rc is None: # a low-res token or a padded slot, which cannot be pointed at return None (y, x), (ph, pw), (w, h) = rc, meta["mapping_shape"], meta["size"] return dict(image=image_ix, x=(x + dx) / pw * w, y=(y + dy) / ph * h)
def _decode_mask(self, scores, anchor, metadata, threshold) -> Optional[np.ndarray]: """`[P, S, n_locs]` mask probabilities -> a boolean mask the size of its image.""" if "timestamps" in metadata[0]: return None # masks are only decoded for images offset = 0 for image_ix, meta in enumerate(metadata): if anchor < offset + len(meta["token_pooling"]) or image_ix == len(metadata) - 1: break offset += len(meta["token_pooling"]) ph, pw = meta["mapping_shape"] pool, r = IMAGE_POOLING, 4 gh, gw = -(-ph // pool), -(-pw // pool) lo = offset + meta["n_global_tokens"] score = torch.as_tensor(scores[lo:lo + gh * gw, :pool * pool]).float() score = score.reshape(gh, gw, pool, pool, r, r).permute(0, 2, 4, 1, 3, 5) score = score.reshape(gh * pool * r, gw * pool * r)[:ph * r, :pw * r] w, h = meta["size"] score = torch.nn.functional.interpolate(score[None, None], size=(h, w), mode="bilinear", align_corners=False, antialias=False)[0, 0] return (score > threshold).numpy()
__all__ = ["Molmo3Processor", "load_video", "mask_to_rle", "rle_to_mask"]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869{ "image_processor": { "do_convert_rgb": true, "do_normalize": true, "do_rescale": true, "do_resize": true, "image_mean": [ 0.5, 0.5, 0.5 ], "image_processor_type": "Molmo2ImageProcessor", "image_std": [ 0.5, 0.5, 0.5 ], "max_crops": 8, "overlap_margins": [ 4, 4 ], "patch_size": 14, "pooling_size": [ 2, 2 ], "resample": 2, "rescale_factor": 0.00392156862745098, "size": { "height": 378, "width": 378 } }, "processor_class": "Molmo3Processor", "subpatch_location_size": 4, "video_processor": { "do_convert_rgb": true, "do_normalize": true, "do_rescale": true, "do_resize": true, "do_sample_frames": true, "image_mean": [ 0.5, 0.5, 0.5 ], "image_std": [ 0.5, 0.5, 0.5 ], "max_fps": 2.0, "num_frames": 128, "patch_size": 14, "pooling_size": [ 3, 3 ], "resample": 2, "rescale_factor": 0.00392156862745098, "return_metadata": false, "size": { "height": 378, "width": 378 }, "video_processor_type": "Molmo3VideoProcessor" }}123version https://git-lfs.github.com/spec/v1oid sha256:0f668f214176a05a05096f603fc944092ea11ebeeb65970550ff25dd01686b85size 11499339123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463{ "add_prefix_space": false, "backend": "tokenizers", "bos_token": null, "center_patch_token": "<|CENTER_PATCH|>", "clean_up_tokenization_spaces": false, "corresponding_patch_token": "<|CORRESPONDING_PATCH|>", "eos_token": "<|im_end|>", "errors": "replace", "extra_special_tokens": [ "|<EXTRA_TOKENS_0>|", "|<EXTRA_TOKENS_1>|", "|<EXTRA_TOKENS_2>|", "|<EXTRA_TOKENS_3>|", "|<EXTRA_TOKENS_4>|", "|<EXTRA_TOKENS_5>|", "|<EXTRA_TOKENS_6>|", "|<EXTRA_TOKENS_7>|", "|<EXTRA_TOKENS_8>|", "|<EXTRA_TOKENS_9>|", "|<EXTRA_TOKENS_10>|", "|<EXTRA_TOKENS_11>|", "|<EXTRA_TOKENS_12>|", "|<EXTRA_TOKENS_13>|", "|<EXTRA_TOKENS_14>|", "|<EXTRA_TOKENS_15>|", "|<EXTRA_TOKENS_16>|", "|<EXTRA_TOKENS_17>|", "|<EXTRA_TOKENS_18>|", "|<EXTRA_TOKENS_19>|", "|<EXTRA_TOKENS_20>|", "|<EXTRA_TOKENS_21>|", "|<EXTRA_TOKENS_22>|", "|<EXTRA_TOKENS_23>|", "|<EXTRA_TOKENS_24>|", "|<EXTRA_TOKENS_25>|", "|<EXTRA_TOKENS_26>|", "|<EXTRA_TOKENS_27>|", "|<EXTRA_TOKENS_28>|", "|<EXTRA_TOKENS_29>|", "|<EXTRA_TOKENS_30>|", "|<EXTRA_TOKENS_31>|", "|<EXTRA_TOKENS_32>|", "|<EXTRA_TOKENS_33>|", "|<EXTRA_TOKENS_34>|", "|<EXTRA_TOKENS_35>|", "|<EXTRA_TOKENS_36>|", "|<EXTRA_TOKENS_37>|", "|<EXTRA_TOKENS_38>|", "|<EXTRA_TOKENS_39>|", "|<EXTRA_TOKENS_40>|", "|<EXTRA_TOKENS_41>|", "|<EXTRA_TOKENS_42>|", "|<EXTRA_TOKENS_43>|", "|<EXTRA_TOKENS_44>|", "|<EXTRA_TOKENS_45>|", "|<EXTRA_TOKENS_46>|", "|<EXTRA_TOKENS_47>|", "|<EXTRA_TOKENS_48>|", "|<EXTRA_TOKENS_49>|", "|<EXTRA_TOKENS_50>|", "|<EXTRA_TOKENS_51>|", "|<EXTRA_TOKENS_52>|", "|<EXTRA_TOKENS_53>|", "|<EXTRA_TOKENS_54>|", "|<EXTRA_TOKENS_55>|", "|<EXTRA_TOKENS_56>|", "|<EXTRA_TOKENS_57>|", "|<EXTRA_TOKENS_58>|", "|<EXTRA_TOKENS_59>|", "|<EXTRA_TOKENS_60>|", "|<EXTRA_TOKENS_61>|", "|<EXTRA_TOKENS_62>|", "|<EXTRA_TOKENS_63>|", "|<EXTRA_TOKENS_64>|", "|<EXTRA_TOKENS_65>|", "|<EXTRA_TOKENS_66>|", "|<EXTRA_TOKENS_67>|", "|<EXTRA_TOKENS_68>|", "|<EXTRA_TOKENS_69>|", "|<EXTRA_TOKENS_70>|", "|<EXTRA_TOKENS_71>|", "|<EXTRA_TOKENS_72>|", "|<EXTRA_TOKENS_73>|", "|<EXTRA_TOKENS_74>|", "|<EXTRA_TOKENS_75>|", "|<EXTRA_TOKENS_76>|", "|<EXTRA_TOKENS_77>|", "|<EXTRA_TOKENS_78>|", "|<EXTRA_TOKENS_79>|", "|<EXTRA_TOKENS_80>|", "|<EXTRA_TOKENS_81>|", "|<EXTRA_TOKENS_82>|", "|<EXTRA_TOKENS_83>|", "|<EXTRA_TOKENS_84>|", "|<EXTRA_TOKENS_85>|", "|<EXTRA_TOKENS_86>|", "|<EXTRA_TOKENS_87>|", "|<EXTRA_TOKENS_88>|", "|<EXTRA_TOKENS_89>|", "|<EXTRA_TOKENS_90>|", "|<EXTRA_TOKENS_91>|", "|<EXTRA_TOKENS_92>|", "|<EXTRA_TOKENS_93>|", "|<EXTRA_TOKENS_94>|", "|<EXTRA_TOKENS_95>|", "|<EXTRA_TOKENS_96>|", "|<EXTRA_TOKENS_97>|", "|<EXTRA_TOKENS_98>|", "|<EXTRA_TOKENS_99>|", "|<EXTRA_TOKENS_100>|", "|<EXTRA_TOKENS_101>|", "|<EXTRA_TOKENS_102>|", "|<EXTRA_TOKENS_103>|", "|<EXTRA_TOKENS_104>|", "|<EXTRA_TOKENS_105>|", "|<EXTRA_TOKENS_106>|", "|<EXTRA_TOKENS_107>|", "|<EXTRA_TOKENS_108>|", "|<EXTRA_TOKENS_109>|", "|<EXTRA_TOKENS_110>|", "|<EXTRA_TOKENS_111>|", "|<EXTRA_TOKENS_112>|", "|<EXTRA_TOKENS_113>|", "|<EXTRA_TOKENS_114>|", "|<EXTRA_TOKENS_115>|", "|<EXTRA_TOKENS_116>|", "|<EXTRA_TOKENS_117>|", "|<EXTRA_TOKENS_118>|", "|<EXTRA_TOKENS_119>|", "|<EXTRA_TOKENS_120>|", "|<EXTRA_TOKENS_121>|", "|<EXTRA_TOKENS_122>|", "|<EXTRA_TOKENS_123>|", "|<EXTRA_TOKENS_124>|", "|<EXTRA_TOKENS_125>|", "|<EXTRA_TOKENS_126>|", "|<EXTRA_TOKENS_127>|", "|<EXTRA_TOKENS_128>|", "|<EXTRA_TOKENS_129>|", "|<EXTRA_TOKENS_130>|", "|<EXTRA_TOKENS_131>|", "|<EXTRA_TOKENS_132>|", "|<EXTRA_TOKENS_133>|", "|<EXTRA_TOKENS_134>|", "|<EXTRA_TOKENS_135>|", "|<EXTRA_TOKENS_136>|", "|<EXTRA_TOKENS_137>|", "|<EXTRA_TOKENS_138>|", "|<EXTRA_TOKENS_139>|", "|<EXTRA_TOKENS_140>|", "|<EXTRA_TOKENS_141>|", "|<EXTRA_TOKENS_142>|", "|<EXTRA_TOKENS_143>|", "|<EXTRA_TOKENS_144>|", "|<EXTRA_TOKENS_145>|", "|<EXTRA_TOKENS_146>|", "|<EXTRA_TOKENS_147>|", "|<EXTRA_TOKENS_148>|", "|<EXTRA_TOKENS_149>|", "|<EXTRA_TOKENS_150>|", "|<EXTRA_TOKENS_151>|", "|<EXTRA_TOKENS_152>|", "|<EXTRA_TOKENS_153>|", "|<EXTRA_TOKENS_154>|", "|<EXTRA_TOKENS_155>|", "|<EXTRA_TOKENS_156>|", "|<EXTRA_TOKENS_157>|", "|<EXTRA_TOKENS_158>|", "|<EXTRA_TOKENS_159>|", "|<EXTRA_TOKENS_160>|", "|<EXTRA_TOKENS_161>|", "|<EXTRA_TOKENS_162>|", "|<EXTRA_TOKENS_163>|", "|<EXTRA_TOKENS_164>|", "|<EXTRA_TOKENS_165>|", "|<EXTRA_TOKENS_166>|", "|<EXTRA_TOKENS_167>|", "|<EXTRA_TOKENS_168>|", "|<EXTRA_TOKENS_169>|", "|<EXTRA_TOKENS_170>|", "|<EXTRA_TOKENS_171>|", "|<EXTRA_TOKENS_172>|", "|<EXTRA_TOKENS_173>|", "|<EXTRA_TOKENS_174>|", "|<EXTRA_TOKENS_175>|", "|<EXTRA_TOKENS_176>|", "|<EXTRA_TOKENS_177>|", "|<EXTRA_TOKENS_178>|", "|<EXTRA_TOKENS_179>|", "|<EXTRA_TOKENS_180>|", "|<EXTRA_TOKENS_181>|", "|<EXTRA_TOKENS_182>|", "|<EXTRA_TOKENS_183>|", "|<EXTRA_TOKENS_184>|", "|<EXTRA_TOKENS_185>|", "|<EXTRA_TOKENS_186>|", "|<EXTRA_TOKENS_187>|", "|<EXTRA_TOKENS_188>|", "|<EXTRA_TOKENS_189>|", "|<EXTRA_TOKENS_190>|", "|<EXTRA_TOKENS_191>|", "|<EXTRA_TOKENS_192>|", "|<EXTRA_TOKENS_193>|", "|<EXTRA_TOKENS_194>|", "|<EXTRA_TOKENS_195>|", "|<EXTRA_TOKENS_196>|", "|<EXTRA_TOKENS_197>|", "|<EXTRA_TOKENS_198>|", "|<EXTRA_TOKENS_199>|", "|<EXTRA_TOKENS_200>|", "|<EXTRA_TOKENS_201>|", "|<EXTRA_TOKENS_202>|", "|<EXTRA_TOKENS_203>|", "|<EXTRA_TOKENS_204>|", "|<EXTRA_TOKENS_205>|", "|<EXTRA_TOKENS_206>|", "|<EXTRA_TOKENS_207>|", "|<EXTRA_TOKENS_208>|", "|<EXTRA_TOKENS_209>|", "|<EXTRA_TOKENS_210>|", "|<EXTRA_TOKENS_211>|", "|<EXTRA_TOKENS_212>|", "|<EXTRA_TOKENS_213>|", "|<EXTRA_TOKENS_214>|", "|<EXTRA_TOKENS_215>|", "|<EXTRA_TOKENS_216>|", "|<EXTRA_TOKENS_217>|", "|<EXTRA_TOKENS_218>|", "|<EXTRA_TOKENS_219>|", "|<EXTRA_TOKENS_220>|", "|<EXTRA_TOKENS_221>|", "|<EXTRA_TOKENS_222>|", "|<EXTRA_TOKENS_223>|", "|<EXTRA_TOKENS_224>|", "|<EXTRA_TOKENS_225>|", "|<EXTRA_TOKENS_226>|", "|<EXTRA_TOKENS_227>|", "|<EXTRA_TOKENS_228>|", "|<EXTRA_TOKENS_229>|", "|<EXTRA_TOKENS_230>|", "|<EXTRA_TOKENS_231>|", "|<EXTRA_TOKENS_232>|", "|<EXTRA_TOKENS_233>|", "|<EXTRA_TOKENS_234>|", "|<EXTRA_TOKENS_235>|", "|<EXTRA_TOKENS_236>|", "|<EXTRA_TOKENS_237>|", "|<EXTRA_TOKENS_238>|", "|<EXTRA_TOKENS_239>|", "|<EXTRA_TOKENS_240>|", "|<EXTRA_TOKENS_241>|", "|<EXTRA_TOKENS_242>|", "|<EXTRA_TOKENS_243>|", "|<EXTRA_TOKENS_244>|", "|<EXTRA_TOKENS_245>|", "|<EXTRA_TOKENS_246>|", "|<EXTRA_TOKENS_247>|", "|<EXTRA_TOKENS_248>|", "|<EXTRA_TOKENS_249>|", "|<EXTRA_TOKENS_250>|", "|<EXTRA_TOKENS_251>|", "|<EXTRA_TOKENS_252>|", "|<EXTRA_TOKENS_253>|", "|<EXTRA_TOKENS_254>|", "|<EXTRA_TOKENS_255>|", "|<EXTRA_TOKENS_256>|", "|<EXTRA_TOKENS_257>|", "|<EXTRA_TOKENS_258>|", "|<EXTRA_TOKENS_259>|", "|<EXTRA_TOKENS_260>|", "|<EXTRA_TOKENS_261>|", "|<EXTRA_TOKENS_262>|", "|<EXTRA_TOKENS_263>|", "|<EXTRA_TOKENS_264>|", "|<EXTRA_TOKENS_265>|", "|<EXTRA_TOKENS_266>|", "<im_start>", "<im_end>", "<im_patch>", "<im_col>", "<low_res_im_start>", "<|image|>", "<im_low>", "<frame_start>", "<frame_end>", "<|video|>", "<|points|>", "<|token_index|>", "<|vit_index|>", "<|vit_loc|>", "<|POINT_PATCH|>", "<|POINT_SUBPATCH|>", "<|POINT_LOC|>", "<|SEG_MASK|>", "<|CENTER_PATCH|>", "<|CORRESPONDING_PATCH|>", "<|EXTRA_0|>", "<|EXTRA_1|>", "<|EXTRA_2|>", "<|EXTRA_3|>", "<|EXTRA_4|>", "<|EXTRA_5|>", "<|EXTRA_6|>", "<|EXTRA_7|>", "<|EXTRA_8|>", "<|EXTRA_9|>", "<|EXTRA_10|>", "<|EXTRA_11|>", "<|EXTRA_12|>", "<|EXTRA_13|>", "<|EXTRA_14|>", "<|EXTRA_15|>", "<|EXTRA_16|>", "<|EXTRA_17|>", "<|EXTRA_18|>", "<|EXTRA_19|>", "<|EXTRA_20|>", "<|EXTRA_21|>", "<|EXTRA_22|>", "<|EXTRA_23|>", "<|EXTRA_24|>", "<|EXTRA_25|>", "<|EXTRA_26|>", "<|EXTRA_27|>", "<|EXTRA_28|>", "<|EXTRA_29|>", "<|EXTRA_30|>", "<|EXTRA_31|>", "<|EXTRA_32|>", "<|EXTRA_33|>", "<|EXTRA_34|>", "<|EXTRA_35|>", "<|EXTRA_36|>", "<|EXTRA_37|>", "<|EXTRA_38|>", "<|EXTRA_39|>", "<|EXTRA_40|>", "<|EXTRA_41|>", "<|EXTRA_42|>", "<|EXTRA_43|>", "<|EXTRA_44|>", "<|EXTRA_45|>", "<|EXTRA_46|>", "<|EXTRA_47|>", "<|EXTRA_48|>", "<|EXTRA_49|>", "<|EXTRA_50|>", "<|EXTRA_51|>", "<|EXTRA_52|>", "<|EXTRA_53|>", "<|EXTRA_54|>", "<|EXTRA_55|>", "<|EXTRA_56|>", "<|EXTRA_57|>", "<|EXTRA_58|>", "<|EXTRA_59|>", "<|EXTRA_60|>", "<|EXTRA_61|>", "<|EXTRA_62|>", "<|EXTRA_63|>", "<|EXTRA_64|>", "<|EXTRA_65|>", "<|EXTRA_66|>", "<|EXTRA_67|>", "<|EXTRA_68|>", "<|EXTRA_69|>", "<|EXTRA_70|>", "<|EXTRA_71|>", "<|EXTRA_72|>", "<|EXTRA_73|>", "<|EXTRA_74|>", "<|EXTRA_75|>", "<|EXTRA_76|>", "<|EXTRA_77|>", "<|EXTRA_78|>", "<|EXTRA_79|>", "<|EXTRA_80|>", "<|EXTRA_81|>", "<|EXTRA_82|>", "<|EXTRA_83|>", "<|EXTRA_84|>", "<|EXTRA_85|>", "<|EXTRA_86|>", "<|EXTRA_87|>", "<|EXTRA_88|>", "<|EXTRA_89|>", "<|EXTRA_90|>", "<|EXTRA_91|>", "<|EXTRA_92|>", "<|EXTRA_93|>", "<|EXTRA_94|>", "<|EXTRA_95|>", "<|EXTRA_96|>", "<|EXTRA_97|>", "<|EXTRA_98|>", "<|EXTRA_99|>", "<|EXTRA_100|>", "<|EXTRA_101|>", "<|EXTRA_102|>", "<|EXTRA_103|>", "<|EXTRA_104|>", "<|EXTRA_105|>", "<|EXTRA_106|>", "<|EXTRA_107|>" ], "frame_end_token": "<frame_end>", "frame_start_token": "<frame_start>", "image_col_token": "<im_col>", "image_end_token": "<im_end>", "image_low_res_token": "<im_low>", "image_patch_token": "<im_patch>", "image_start_token": "<im_start>", "image_token": "<|image|>", "is_local": true, "local_files_only": false, "low_res_image_start_token": "<low_res_im_start>", "model_max_length": 16384, "model_specific_special_tokens": { "center_patch_token": "<|CENTER_PATCH|>", "corresponding_patch_token": "<|CORRESPONDING_PATCH|>", "frame_end_token": "<frame_end>", "frame_start_token": "<frame_start>", "image_col_token": "<im_col>", "image_end_token": "<im_end>", "image_low_res_token": "<im_low>", "image_patch_token": "<im_patch>", "image_start_token": "<im_start>", "image_token": "<|image|>", "low_res_image_start_token": "<low_res_im_start>", "point_location_token": "<|POINT_LOC|>", "point_patch_token": "<|POINT_PATCH|>", "point_subpatch_token": "<|POINT_SUBPATCH|>", "segmentation_mask_token": "<|SEG_MASK|>", "video_token": "<|video|>" }, "pad_token": "<|endoftext|>", "padding_side": "left", "point_location_token": "<|POINT_LOC|>", "point_patch_token": "<|POINT_PATCH|>", "point_subpatch_token": "<|POINT_SUBPATCH|>", "processor_class": "Molmo3Processor", "response_template": { "defaults": { "role": "assistant" }, "fields": { "content": { "close": [ "<|im_end|>", "<|endoftext|>" ], "content": "text" } }, "start_anchor": "<|im_start|>assistant\n" }, "segmentation_mask_token": "<|SEG_MASK|>", "split_special_tokens": false, "tokenizer_class": "Qwen2Tokenizer", "unk_token": null, "video_token": "<|video|>"}.gitattributes+1
LICENSEAdded+202
README.mdAdded+88
chat_template.jinjaAdded+64
config.jsonAdded+123
configuration_molmo3.pyAdded+328
generation_config.jsonAdded+7
model-00001-of-00002.safetensorsAdded+3
model-00002-of-00002.safetensorsAdded+3
model.safetensors.index.jsonAdded+1030
modeling_molmo3.pyAdded+862
processing_molmo3.pyAdded+1233
processor_config.jsonAdded+69
tokenizer.jsonAdded+3
tokenizer_config.jsonAdded+463