Model
ankit/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-NVFP4
- Task:Image Text To Text
- Libraries:transformerspytorch
- Formats:safetensors
- Languages:GermanEnglishSpanishFrenchItalianJapanese
- License:other
Dedicated endpoint
Sign in to deployInference Providers
This hub serves this model on demand.
Try itSpaces
Create a Space with this modelUse this model
Choose individual files there, or download a full snapshot with the Python example below.
Download with the whiteduck client
pip install https://provyd.xyz/clients/whiteduck-0.1.0-py3-none-any.whl
wd login --host 'https://api.provyd.xyz'
wd download 'ankit/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-NVFP4'Using the Hugging Face client instead
Install huggingface_hub with pip install huggingface_hub, then download this pinned snapshot. Set HF_TOKEN (the variable the Hugging Face client reads) to a whiteduck Read token for private repositories. Running the downloaded model requires software that supports its architecture.
Keep your whiteduck token away from calls that ignore HF_ENDPOINT, such as list_inference_endpoints: they send it to Hugging Face. See Docs.
from huggingface_hub import snapshot_download
import os
path = snapshot_download(
repo_id='ankit/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-NVFP4',
revision='f145a010eb6cafac2e532b8b81c2dc76df47ff25',
endpoint='https://api.provyd.xyz',
token=os.environ.get("HF_TOKEN") or False,
)Load with transformers
import os
os.environ["HF_ENDPOINT"] = 'https://api.provyd.xyz'
from transformers import AutoModel, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained('ankit/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-NVFP4')
model = AutoModel.from_pretrained('ankit/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-NVFP4')Use with local apps
This hub is self-hosted, so each command points the tool at it. Add a whiteduck access token as HF_TOKEN (the variable the Hugging Face client reads) for private repositories.
vLLM
# vLLM downloads through huggingface_hub, which honours HF_ENDPOINT; set HF_TOKEN for a private repository.
HF_ENDPOINT='https://api.provyd.xyz' vllm serve 'ankit/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-NVFP4'Clone with git
git clone 'https://api.provyd.xyz/ankit/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-NVFP4'Clone with git over SSH
git clone 'ssh://git@wd.provyd.xyz:2222/ankit/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-NVFP4'Needs an SSH key on your account. Add an SSH key
Use the API
Read repository metadata at this commit. Set HF_TOKEN (the variable the Hugging Face client reads) to a whiteduck Read token. Tokens grant account-level access, not access to just this model.
curl 'https://api.provyd.xyz/api/models/ankit/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-NVFP4/revision/f145a010eb6cafac2e532b8b81c2dc76df47ff25' \
-H "Authorization: Bearer $HF_TOKEN"Inference is separate from file storage. The owner must configure and start a supported model using the inference controls. To call it you need a model API key (made on the model page), or a token of any scope (Read or stronger) from the model owner. Visitors can use the try box only when the owner allows it. A token cannot enable unavailable GPU hardware.
Add files using upload-large-folder tool
ankit committed on October 28, 2026
bf6c919a39c14a62eb7dee1a3cf7cc3331de293bParent 93541a6Browse files
50 files changed+739 -0
.gitattributes
Modified+6 -0
.gitattributes
| @@ -33,3 +33,9 @@ | |||
| 33 | 33 | *.zip filter=lfs diff=lfs merge=lfs -text | |
| 34 | 34 | *.zst filter=lfs diff=lfs merge=lfs -text | |
| 35 | 35 | *tfevents* filter=lfs diff=lfs merge=lfs -text | |
| 36 | Added: tokenizer.json filter=lfs diff=lfs merge=lfs -text | ||
| 37 | Added: model.safetensors.index.json filter=lfs diff=lfs merge=lfs -text | ||
| 38 | Added: Nemotron_3.5_Super_VL_EU_Training_Content_Summary.pdf filter=lfs diff=lfs merge=lfs -text | ||
| 39 | Added: accuracy_plot.png filter=lfs diff=lfs merge=lfs -text | ||
| 40 | Added: harness_comparisons.png.png filter=lfs diff=lfs merge=lfs -text | ||
| 41 | Added: harness_comparisons.png filter=lfs diff=lfs merge=lfs -text | ||
__init__.py
Added
__init__.py
No content changes.
accuracy_plot.png
Added
accuracy_plot.png
This file is too large to display.
bias.md
Added+10 -0
bias.md
| @@ -0,0 +1,10 @@ | |||
| 1 | Added: | Field | Response | | ||
| 2 | Added: | :---- | :---- | | ||
| 3 | Added: | Participation considerations from adversely impacted groups [protected classes](https://www.senate.ca.gov/content/protected-classes) in model design and testing: | None | | ||
| 4 | Added: | Bias Metric (If Measured): | [BBQ Accuracy Scores in Ambiguous Contexts](https://github.com/nyu-mll/BBQ/) | | ||
| 5 | Added: | Which characteristic (feature) show(s) the greatest difference in performance?: | The model shows high variance in the characteristics when it is used with a high temperature. | | ||
| 6 | Added: | Measures taken to mitigate against unwanted bias: | Supervised Fine-Tuning (SFT) and Reinforcement Learning from Human Feedback (RLHF) employed to calibrate the model’s reasoning capabilities to maintain logical consistency and appropriate complexity when interacting with or interpreting data from diverse age demographics. | | ||
| 7 | Added: | If using internal data, description of methods implemented in data acquisition or processing, if any, to address the prevalence of identifiable biases in the training, testing, and validation data: | The training datasets contain a large amount of synthetic data generated by LLMs. We manually curated prompts. | | ||
| 8 | Added: | Tools used to assess statistical imbalances and highlight patterns that may introduce bias into AI models: | [BBQ](https://github.com/nyu-mll/BBQ/) | | ||
| 9 | Added: | Tools used to assess statistical imbalances and highlight patterns that may introduce bias into AI models: | These datasets, such as web-scraped finance reasoning data derived from SEC EDGAR filings, science and math problem datasets, OpenResearcher/source-document datasets, Common Crawl, CC-News, Wikimedia, and long-context document datasets, do not collectively or exhaustively represent all demographic groups (and proportionally therein). For instance, these datasets do not contain explicit mentions of demographic classes such as age, gender, or ethnicity in approximately 97% to 99.9% of finance reasoning samples and in over 85% of samples across the broader assessed datasets. In the subset where such terms are present, these datasets contain notable representational skews. For example, ethnicity mentions are often dominated by Middle Eastern contexts (found in finance documents) or "White," "Two or more," and "Black or African American" as the most frequent ethnic identifiers, while references categorized as male-only significantly outnumber those categorized as female-only. Furthermore, gender is explicitly mentioned in approximately 12% of samples across the broader dataset assessment, yet in only 0.9% of finance-specific samples. Dataset-level results vary by source type, with long-context/source-document datasets containing higher explicit demographic mention rates compared to certain web-scraped sources. To mitigate these imbalances, we recommend considering evaluation techniques such as bias audits, fine-tuning with demographically balanced datasets, and mitigation strategies such as counterfactual data augmentation to align with the desired model behavior. This evaluation used a 3,000-sample subset per dataset, identified as the optimal threshold for maximizing embedder accuracy. | | ||
| 10 | Added: | Unwanted Bias Testing: | Constrained to English-language inputs. Multi-lingual parity is not currently claimed or guaranteed. |(no newline at end of file) | ||
chat_template.jinja
Added+246 -0
chat_template.jinja
| @@ -0,0 +1,246 @@ | |||
| 1 | Added: {% macro render_extra_keys(json_dict, handled_keys) %} | ||
| 2 | Added: {%- if json_dict is mapping %} | ||
| 3 | Added: {%- for json_key in json_dict if json_key not in handled_keys %} | ||
| 4 | Added: {%- if json_dict[json_key] is mapping or (json_dict[json_key] is sequence and json_dict[json_key] is not string) %} | ||
| 5 | Added: {{- '\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | tojson | safe) ~ '</' ~ json_key ~ '>' }} | ||
| 6 | Added: {%- else %} | ||
| 7 | Added: {{-'\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | string) ~ '</' ~ json_key ~ '>' }} | ||
| 8 | Added: {%- endif %} | ||
| 9 | Added: {%- endfor %} | ||
| 10 | Added: {%- endif %} | ||
| 11 | Added: {% endmacro %} | ||
| 12 | Added: {%- macro render_content(content) -%} | ||
| 13 | Added: {%- if content is none -%} | ||
| 14 | Added: {{- '' -}} | ||
| 15 | Added: {%- elif content is string -%} | ||
| 16 | Added: {{- content | string -}} | ||
| 17 | Added: {%- else -%} | ||
| 18 | Added: {%- set text_ns = namespace(val='') -%} | ||
| 19 | Added: {%- set counters = namespace(images=0, videos=0) -%} | ||
| 20 | Added: {%- for part in content -%} | ||
| 21 | Added: {%- if part['type'] == 'image' or part['type'] == 'image_url' or part['type'] == 'input_image' -%} | ||
| 22 | Added: {%- set counters.images = counters.images + 1 -%} | ||
| 23 | Added: {%- elif part['type'] == 'video' or part['type'] == 'video_url' or part['type'] == 'input_video' -%} | ||
| 24 | Added: {%- set counters.videos = counters.videos + 1 -%} | ||
| 25 | Added: {%- elif part['type'] == 'text' or part['type'] == 'input_text' -%} | ||
| 26 | Added: {%- set text_ns.val = text_ns.val + (part['text'] | default('', true)) -%} | ||
| 27 | Added: {%- endif -%} | ||
| 28 | Added: {%- endfor -%} | ||
| 29 | Added: {%- if '<image>' in text_ns.val -%} | ||
| 30 | Added: {%- set counters.images = 0 -%} | ||
| 31 | Added: {%- endif -%} | ||
| 32 | Added: {%- if '<video>' in text_ns.val -%} | ||
| 33 | Added: {%- set counters.videos = 0 -%} | ||
| 34 | Added: {%- endif -%} | ||
| 35 | Added: {%- set content_ns = namespace(val='') -%} | ||
| 36 | Added: {%- set render_ns = namespace(image_index=0, after_text=false) -%} | ||
| 37 | Added: {%- for part in content -%} | ||
| 38 | Added: {%- set sep = '\n' if render_ns.after_text and not content_ns.val.endswith('\n') else '' -%} | ||
| 39 | Added: {%- if part['type'] == 'image' or part['type'] == 'image_url' or part['type'] == 'input_image' -%} | ||
| 40 | Added: {%- set render_ns.image_index = render_ns.image_index + 1 -%} | ||
| 41 | Added: {%- if counters.images > 0 -%} | ||
| 42 | Added: {%- if counters.images > 1 -%} | ||
| 43 | Added: {%- set content_ns.val = content_ns.val + sep | ||
| 44 | Added: + '<image ' + render_ns.image_index|string + '><image>' -%} | ||
| 45 | Added: {%- else -%} | ||
| 46 | Added: {%- set content_ns.val = content_ns.val + sep + '<image>' -%} | ||
| 47 | Added: {%- endif -%} | ||
| 48 | Added: {%- set render_ns.after_text = false -%} | ||
| 49 | Added: {%- endif -%} | ||
| 50 | Added: {%- elif part['type'] == 'video' or part['type'] == 'video_url' or part['type'] == 'input_video' -%} | ||
| 51 | Added: {%- if counters.videos > 0 -%} | ||
| 52 | Added: {%- set content_ns.val = content_ns.val + sep + '<video>' -%} | ||
| 53 | Added: {%- set render_ns.after_text = false -%} | ||
| 54 | Added: {%- endif -%} | ||
| 55 | Added: {%- elif part['type'] == 'text' or part['type'] == 'input_text' -%} | ||
| 56 | Added: {%- set content_ns.val = content_ns.val + (part['text'] | default('', true)) -%} | ||
| 57 | Added: {%- if part['text'] | default('', true) -%} | ||
| 58 | Added: {%- set render_ns.after_text = true -%} | ||
| 59 | Added: {%- endif -%} | ||
| 60 | Added: {%- endif -%} | ||
| 61 | Added: {%- endfor -%} | ||
| 62 | Added: {{- content_ns.val -}} | ||
| 63 | Added: {%- endif -%} | ||
| 64 | Added: {%- endmacro %} | ||
| 65 | Added: {%- set enable_thinking = enable_thinking if enable_thinking is defined else True %} | ||
| 66 | Added: {%- set medium_effort = medium_effort if medium_effort is defined else False %} | ||
| 67 | Added: {%- set truncate_history_thinking = truncate_history_thinking if truncate_history_thinking is defined else True %} | ||
| 68 | Added: {%- set ns = namespace(last_user_idx = -1) %} | ||
| 69 | Added: {%- set loop_messages = messages %} | ||
| 70 | Added: {%- for m in loop_messages %} | ||
| 71 | Added: {%- if m["role"] == "user" %} | ||
| 72 | Added: {%- set ns.last_user_idx = loop.index0 %} | ||
| 73 | Added: {%- endif %} | ||
| 74 | Added: {%- endfor %} | ||
| 75 | Added: {%- if messages[0]["role"] == "system" %} | ||
| 76 | Added: {%- set system_message = messages[0]["content"] %} | ||
| 77 | Added: {%- set loop_messages = messages[1:] %} | ||
| 78 | Added: {%- else %} | ||
| 79 | Added: {%- set system_message = "" %} | ||
| 80 | Added: {%- set loop_messages = messages %} | ||
| 81 | Added: {%- endif %} | ||
| 82 | Added: {%- if not tools is defined %} | ||
| 83 | Added: {%- set tools = [] %} | ||
| 84 | Added: {%- endif %} | ||
| 85 | Added: {%- set ns = namespace(last_user_idx = -1) %} | ||
| 86 | Added: {%- for m in loop_messages %} | ||
| 87 | Added: {%- if m["role"] == "user" %} | ||
| 88 | Added: {%- set ns.last_user_idx = loop.index0 %} | ||
| 89 | Added: {%- endif %} | ||
| 90 | Added: {%- endfor %} | ||
| 91 | Added: {%- if system_message is defined %} | ||
| 92 | Added: {{- "<|im_start|>system\n" ~ render_content(system_message) }} | ||
| 93 | Added: {%- else %} | ||
| 94 | Added: {%- if tools is iterable and tools | length > 0 %} | ||
| 95 | Added: {{- "<|im_start|>system\n" }} | ||
| 96 | Added: {%- endif %} | ||
| 97 | Added: {%- endif %} | ||
| 98 | Added: {%- if tools is iterable and tools | length > 0 %} | ||
| 99 | Added: {%- if system_message is defined and system_message | length > 0 %} | ||
| 100 | Added: {{- "\n\n" }} | ||
| 101 | Added: {%- endif %} | ||
| 102 | Added: {{- "# Tools\n\nYou have access to the following functions:\n\n" }} | ||
| 103 | Added: {{- "<tools>" }} | ||
| 104 | Added: {%- for tool in tools %} | ||
| 105 | Added: {%- if tool.function is defined %} | ||
| 106 | Added: {%- set tool = tool.function %} | ||
| 107 | Added: {%- endif %} | ||
| 108 | Added: {{- "\n<function>\n<name>" ~ tool.name ~ "</name>" }} | ||
| 109 | Added: {%- if tool.description is defined %} | ||
| 110 | Added: {{- '\n<description>' ~ (tool.description | trim) ~ '</description>' }} | ||
| 111 | Added: {%- endif %} | ||
| 112 | Added: {{- '\n<parameters>' }} | ||
| 113 | Added: {%- if tool.parameters is defined and tool.parameters is mapping and tool.parameters.properties is defined and tool.parameters.properties is mapping %} | ||
| 114 | Added: {%- for param_name, param_fields in tool.parameters.properties|items %} | ||
| 115 | Added: {{- '\n<parameter>' }} | ||
| 116 | Added: {{- '\n<name>' ~ param_name ~ '</name>' }} | ||
| 117 | Added: {%- if param_fields.type is defined %} | ||
| 118 | Added: {{- '\n<type>' ~ (param_fields.type | string) ~ '</type>' }} | ||
| 119 | Added: {%- endif %} | ||
| 120 | Added: {%- if param_fields.description is defined %} | ||
| 121 | Added: {{- '\n<description>' ~ (param_fields.description | trim) ~ '</description>' }} | ||
| 122 | Added: {%- endif %} | ||
| 123 | Added: {%- if param_fields.enum is defined %} | ||
| 124 | Added: {{- '\n<enum>' ~ (param_fields.enum | tojson | safe) ~ '</enum>' }} | ||
| 125 | Added: {%- endif %} | ||
| 126 | Added: {%- set handled_keys = ['name', 'type', 'description', 'enum'] %} | ||
| 127 | Added: {{- render_extra_keys(param_fields, handled_keys) }} | ||
| 128 | Added: {{- '\n</parameter>' }} | ||
| 129 | Added: {%- endfor %} | ||
| 130 | Added: {%- endif %} | ||
| 131 | Added: {% set handled_keys = ['type', 'properties', 'required'] %} | ||
| 132 | Added: {{- render_extra_keys(tool.parameters, handled_keys) }} | ||
| 133 | Added: {%- if tool.parameters is defined and tool.parameters.required is defined %} | ||
| 134 | Added: {{- '\n<required>' ~ (tool.parameters.required | tojson | safe) ~ '</required>' }} | ||
| 135 | Added: {%- endif %} | ||
| 136 | Added: {{- '\n</parameters>' }} | ||
| 137 | Added: {%- set handled_keys = ['type', 'name', 'description', 'parameters'] %} | ||
| 138 | Added: {{- render_extra_keys(tool, handled_keys) }} | ||
| 139 | Added: {{- '\n</function>' }} | ||
| 140 | Added: {%- endfor %} | ||
| 141 | Added: {{- "\n</tools>" }} | ||
| 142 | Added: {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }} | ||
| 143 | Added: {%- endif %} | ||
| 144 | Added: {%- if system_message is defined %} | ||
| 145 | Added: {{- '<|im_end|>\n' }} | ||
| 146 | Added: {%- else %} | ||
| 147 | Added: {%- if tools is iterable and tools | length > 0 %} | ||
| 148 | Added: {{- '<|im_end|>\n' }} | ||
| 149 | Added: {%- endif %} | ||
| 150 | Added: {%- endif %} | ||
| 151 | Added: {%- for message in loop_messages %} | ||
| 152 | Added: {%- set content = render_content(message.content | default('', true)) %} | ||
| 153 | Added: {%- if message.role == "assistant" %} | ||
| 154 | Added: {%- if message.reasoning_content is defined and message.reasoning_content is string and message.reasoning_content | trim | length > 0 %} | ||
| 155 | Added: {%- set content = "<think>\n" ~ message.reasoning_content ~ "</think>" ~ content %} | ||
| 156 | Added: {%- else %} | ||
| 157 | Added: {%- if content is string -%} | ||
| 158 | Added: {%- if '<think>' not in content and '</think>' not in content -%} | ||
| 159 | Added: {%- set content = "<think></think>" ~ content -%} | ||
| 160 | Added: {%- endif -%} | ||
| 161 | Added: {%- endif -%} | ||
| 162 | Added: {%- endif %} | ||
| 163 | Added: {%- if message.tool_calls is defined and message.tool_calls is iterable and message.tool_calls | length > 0 %} | ||
| 164 | Added: {{- '<|im_start|>assistant\n' }} | ||
| 165 | Added: {%- set include_content = not (truncate_history_thinking and loop.index0 < ns.last_user_idx) %} | ||
| 166 | Added: {%- if content is string and content | trim | length > 0 %} | ||
| 167 | Added: {%- if include_content %} | ||
| 168 | Added: {{- (content | trim) ~ '\n' -}} | ||
| 169 | Added: {%- else %} | ||
| 170 | Added: {%- set c = (content | string) %} | ||
| 171 | Added: {%- if '</think>' in c %} | ||
| 172 | Added: {%- set c = c.split('</think>')[-1] %} | ||
| 173 | Added: {%- elif '<think>' in c %} | ||
| 174 | Added: {%- set c = c.split('<think>')[0] %} | ||
| 175 | Added: {%- endif %} | ||
| 176 | Added: {%- set c = "<think></think>" ~ c %} | ||
| 177 | Added: {%- if c | length > 0 %} | ||
| 178 | Added: {{- c ~ '\n' -}} | ||
| 179 | Added: {%- endif %} | ||
| 180 | Added: {%- endif %} | ||
| 181 | Added: {%- else %} | ||
| 182 | Added: {{- "<think></think>" -}} | ||
| 183 | Added: {%- endif %} | ||
| 184 | Added: {%- for tool_call in message.tool_calls %} | ||
| 185 | Added: {%- if tool_call.function is defined %} | ||
| 186 | Added: {%- set tool_call = tool_call.function %} | ||
| 187 | Added: {%- endif %} | ||
| 188 | Added: {{- '<tool_call>\n<function=' ~ tool_call.name ~ '>\n' -}} | ||
| 189 | Added: {%- if tool_call.arguments is defined %} | ||
| 190 | Added: {%- for args_name, args_value in tool_call.arguments|items %} | ||
| 191 | Added: {{- '<parameter=' ~ args_name ~ '>\n' -}} | ||
| 192 | Added: {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %} | ||
| 193 | Added: {{- args_value ~ '\n</parameter>\n' -}} | ||
| 194 | Added: {%- endfor %} | ||
| 195 | Added: {%- endif %} | ||
| 196 | Added: {{- '</function>\n</tool_call>\n' -}} | ||
| 197 | Added: {%- endfor %} | ||
| 198 | Added: {{- '<|im_end|>\n' }} | ||
| 199 | Added: {%- else %} | ||
| 200 | Added: {%- if not (truncate_history_thinking and loop.index0 < ns.last_user_idx) %} | ||
| 201 | Added: {{- '<|im_start|>assistant\n' ~ (content | default('', true) | string | trim) ~ '<|im_end|>\n' }} | ||
| 202 | Added: {%- else %} | ||
| 203 | Added: {%- set c = (content | default('', true) | string) %} | ||
| 204 | Added: {%- if '<think>' in c and '</think>' in c %} | ||
| 205 | Added: {%- set c = "<think></think>" ~ c.split('</think>')[-1] %} | ||
| 206 | Added: {%- endif %} | ||
| 207 | Added: {%- set c = c | trim %} | ||
| 208 | Added: {%- if c | length > 0 %} | ||
| 209 | Added: {{- '<|im_start|>assistant\n' ~ c ~ '<|im_end|>\n' }} | ||
| 210 | Added: {%- else %} | ||
| 211 | Added: {{- '<|im_start|>assistant\n<|im_end|>\n' }} | ||
| 212 | Added: {%- endif %} | ||
| 213 | Added: {%- endif %} | ||
| 214 | Added: {%- endif %} | ||
| 215 | Added: {%- elif message.role == "user" or message.role == "system" %} | ||
| 216 | Added: {{- '<|im_start|>' + message.role + '\n' }} | ||
| 217 | Added: {#- Render structured image/video content in its original order. -#} | ||
| 218 | Added: {%- if message.role == "user" and loop.index0 == ns.last_user_idx and medium_effort %} | ||
| 219 | Added: {{- content + '\n\n{reasoning effort: efficient}' }} | ||
| 220 | Added: {%- else %} | ||
| 221 | Added: {{- content }} | ||
| 222 | Added: {%- endif %} | ||
| 223 | Added: {{- '<|im_end|>\n' }} | ||
| 224 | Added: {%- elif message.role == "tool" %} | ||
| 225 | Added: {%- if loop.previtem and loop.previtem.role != "tool" %} | ||
| 226 | Added: {{- '<|im_start|>user\n' }} | ||
| 227 | Added: {%- endif %} | ||
| 228 | Added: {{- '<tool_response>\n' }} | ||
| 229 | Added: {{- content }} | ||
| 230 | Added: {{- '\n</tool_response>\n' }} | ||
| 231 | Added: {%- if not loop.last and loop.nextitem.role != "tool" %} | ||
| 232 | Added: {{- '<|im_end|>\n' }} | ||
| 233 | Added: {%- elif loop.last %} | ||
| 234 | Added: {{- '<|im_end|>\n' }} | ||
| 235 | Added: {%- endif %} | ||
| 236 | Added: {%- else %} | ||
| 237 | Added: {{- '<|im_start|>' ~ message.role ~ '\n' ~ content ~ '<|im_end|>\n' }} | ||
| 238 | Added: {%- endif %} | ||
| 239 | Added: {%- endfor %} | ||
| 240 | Added: {%- if add_generation_prompt %} | ||
| 241 | Added: {%- if enable_thinking %} | ||
| 242 | Added: {{- '<|im_start|>assistant\n<think>\n' }} | ||
| 243 | Added: {%- else %} | ||
| 244 | Added: {{- '<|im_start|>assistant\n<think></think>' }} | ||
| 245 | Added: {%- endif %} | ||
| 246 | Added: {%- endif %} | ||
configuration_nemotron_h_omni.py
Added+141 -0
configuration_nemotron_h_omni.py
| @@ -0,0 +1,141 @@ | |||
| 1 | Added: # Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. | ||
| 2 | Added: # | ||
| 3 | Added: # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | Added: # you may not use this file except in compliance with the License. | ||
| 5 | Added: # You may obtain a copy of the License at | ||
| 6 | Added: # | ||
| 7 | Added: # http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | Added: # | ||
| 9 | Added: # Unless required by applicable law or agreed to in writing, software | ||
| 10 | Added: # distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | Added: # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | Added: # See the License for the specific language governing permissions and | ||
| 13 | Added: # limitations under the License. | ||
| 14 | Added: from huggingface_hub.dataclasses import strict | ||
| 15 | Added: from transformers.configuration_utils import PreTrainedConfig | ||
| 16 | Added: from transformers.models.nemotron_h import NemotronHConfig | ||
| 17 | Added: from transformers.models.parakeet.configuration_parakeet import ParakeetEncoderConfig | ||
| 18 | Added: from transformers.utils import auto_docstring, logging | ||
| 19 | Added: | ||
| 20 | Added: from .configuration_radio import RadioConfig | ||
| 21 | Added: | ||
| 22 | Added: | ||
| 23 | Added: __all__ = ["NemotronH_Omni_Reasoning_V3_Config"] | ||
| 24 | Added: | ||
| 25 | Added: logger = logging.get_logger(__name__) | ||
| 26 | Added: | ||
| 27 | Added: | ||
| 28 | Added: def _nemotron_h_compatible_config(config: dict) -> dict: | ||
| 29 | Added: """Translate current Nemotron-H layer names for Transformers versions using legacy names.""" | ||
| 30 | Added: config = dict(config) | ||
| 31 | Added: legacy_names = {"linear_attention": "mamba", "full_attention": "attention"} | ||
| 32 | Added: for field in ("layers_block_type", "mtp_layers_block_type"): | ||
| 33 | Added: if field in config and config[field] is not None: | ||
| 34 | Added: config[field] = [legacy_names.get(layer_type, layer_type) for layer_type in config[field]] | ||
| 35 | Added: return config | ||
| 36 | Added: | ||
| 37 | Added: | ||
| 38 | Added: @auto_docstring(checkpoint="nvidia/Nemotron-3-Nano-Omni-30B-A3B-Reasoning-BF16") | ||
| 39 | Added: @strict | ||
| 40 | Added: class NemotronH_Omni_Reasoning_V3_Config(PreTrainedConfig): | ||
| 41 | Added: r""" | ||
| 42 | Added: vision_config (`dict` or `RadioConfig`, *optional*): | ||
| 43 | Added: Configuration for the RADIO vision encoder. Defaults to a default [`RadioConfig`]. | ||
| 44 | Added: llm_config (`dict` or `NemotronHConfig`, *optional*): | ||
| 45 | Added: Configuration for the NemotronH language model. Defaults to a default [`NemotronHConfig`]. | ||
| 46 | Added: sound_config (`dict` or `ParakeetEncoderConfig`, *optional*): | ||
| 47 | Added: Configuration for the optional Parakeet sound encoder. `None` disables the audio branch. | ||
| 48 | Added: force_image_size (`int`, *optional*): | ||
| 49 | Added: Fixed input image resolution (in pixels) the vision tower expects. | ||
| 50 | Added: downsample_ratio (`float`, *optional*, defaults to 0.5): | ||
| 51 | Added: Pixel-shuffle spatial downsample ratio applied to the vision features. | ||
| 52 | Added: template (`str`, *optional*): | ||
| 53 | Added: Conversation template name (legacy; the chat template is carried by the processor). | ||
| 54 | Added: ps_version (`str`, *optional*, defaults to `"v1"`): | ||
| 55 | Added: Pixel-shuffle implementation version (`"v2"` swaps height/width back; `"v1"` is the legacy | ||
| 56 | Added: transposed variant). | ||
| 57 | Added: image_tag_type (`str`, *optional*, defaults to `"internvl"`): | ||
| 58 | Added: Image-tag convention used when expanding image placeholders. | ||
| 59 | Added: projector_hidden_size (`int`, *optional*, defaults to 4096): | ||
| 60 | Added: Hidden size of the vision-to-LLM MLP projector. | ||
| 61 | Added: vit_hidden_size (`int`, *optional*, defaults to 1280): | ||
| 62 | Added: Hidden size of the RADIO vision features. | ||
| 63 | Added: video_pruning_rate (`float`, *optional*, defaults to 0.0): | ||
| 64 | Added: Efficient-Video-Sampling token pruning rate; `0.0` disables pruning. | ||
| 65 | Added: video_temporal_patch_size (`int`, *optional*, defaults to 2): | ||
| 66 | Added: Number of frames collapsed into a single temporal patch by the video embedder. | ||
| 67 | Added: patch_size (`int`, *optional*, defaults to 16): | ||
| 68 | Added: Vision patch size in pixels. | ||
| 69 | Added: img_context_token_id (`int`, *optional*): | ||
| 70 | Added: Token id used as the image-context placeholder in `input_ids`. | ||
| 71 | Added: img_context_token (`str`, *optional*, defaults to `"<image>"`): | ||
| 72 | Added: Textual image-context placeholder token. | ||
| 73 | Added: video_context_token_id (`int`, *optional*): | ||
| 74 | Added: Token id used as the video-context placeholder in `input_ids`. | ||
| 75 | Added: video_context_token (`str`, *optional*, defaults to `"<video>"`): | ||
| 76 | Added: Textual video-context placeholder token. | ||
| 77 | Added: sound_context_token_id (`int`, *optional*): | ||
| 78 | Added: Token id used as the audio-context placeholder in `input_ids`. | ||
| 79 | Added: sound_context_token (`str`, *optional*, defaults to `"<audio>"`): | ||
| 80 | Added: Textual audio-context placeholder token. | ||
| 81 | Added: """ | ||
| 82 | Added: | ||
| 83 | Added: model_type = "nemotron_h_omni" | ||
| 84 | Added: is_composition = True | ||
| 85 | Added: | ||
| 86 | Added: vision_config: dict | RadioConfig | None = None | ||
| 87 | Added: llm_config: dict | NemotronHConfig | None = None | ||
| 88 | Added: sound_config: dict | ParakeetEncoderConfig | None = None | ||
| 89 | Added: force_image_size: int | None = None | ||
| 90 | Added: downsample_ratio: float = 0.5 | ||
| 91 | Added: template: str | None = None # TODO move out of here and into the tokenizer | ||
| 92 | Added: ps_version: str = "v1" # Pixel shuffle version | ||
| 93 | Added: image_tag_type: str = "internvl" # TODO: into the tokenizer too? | ||
| 94 | Added: projector_hidden_size: int = 4096 | ||
| 95 | Added: vit_hidden_size: int = 1280 | ||
| 96 | Added: video_pruning_rate: float = 0.0 | ||
| 97 | Added: video_temporal_patch_size: int = 2 | ||
| 98 | Added: # Vision token settings | ||
| 99 | Added: patch_size: int = 16 | ||
| 100 | Added: img_context_token_id: int | None = None | ||
| 101 | Added: img_context_token: str = "<image>" | ||
| 102 | Added: video_context_token_id: int | None = None | ||
| 103 | Added: video_context_token: str = "<video>" | ||
| 104 | Added: # Sound/audio token settings | ||
| 105 | Added: sound_context_token_id: int | None = None | ||
| 106 | Added: sound_context_token: str = "<audio>" | ||
| 107 | Added: | ||
| 108 | Added: def __post_init__(self, **kwargs): | ||
| 109 | Added: if isinstance(self.vision_config, dict): | ||
| 110 | Added: self.vision_config = RadioConfig(**self.vision_config) | ||
| 111 | Added: elif self.vision_config is None: | ||
| 112 | Added: self.vision_config = RadioConfig() | ||
| 113 | Added: # The vision tower needs the temporal patch size to build its video patch projection. | ||
| 114 | Added: self.vision_config.video_temporal_patch_size = self.video_temporal_patch_size | ||
| 115 | Added: | ||
| 116 | Added: # Handle both cases: when loading from JSON (llm_config is dict) and when called | ||
| 117 | Added: # internally by transformers (llm_config is None). | ||
| 118 | Added: if isinstance(self.llm_config, dict): | ||
| 119 | Added: self.llm_config = NemotronHConfig(**_nemotron_h_compatible_config(self.llm_config)) | ||
| 120 | Added: elif self.llm_config is None: | ||
| 121 | Added: self.llm_config = NemotronHConfig() | ||
| 122 | Added: | ||
| 123 | Added: # This checkpoint's sound_config omits `attention_bias`/`scale_input`, which are `False` for | ||
| 124 | Added: # its Parakeet variant, so supply them before building the encoder config. | ||
| 125 | Added: if isinstance(self.sound_config, dict): | ||
| 126 | Added: sound_config = {"attention_bias": False, "scale_input": False, **self.sound_config} | ||
| 127 | Added: sound_config.pop("model_type", None) | ||
| 128 | Added: self.sound_config = ParakeetEncoderConfig(**sound_config) | ||
| 129 | Added: | ||
| 130 | Added: super().__post_init__(**kwargs) | ||
| 131 | Added: | ||
| 132 | Added: # `attn_implementation` flows in through `**kwargs` (the base `PreTrainedConfig` stores it as | ||
| 133 | Added: # `self._attn_implementation`, as for every other model); propagate it to the language model. | ||
| 134 | Added: self.llm_config._attn_implementation = self._attn_implementation | ||
| 135 | Added: | ||
| 136 | Added: # vLLM's `NemotronH_Nano_VL_V2` implementation reads the language-model sub-config as | ||
| 137 | Added: # `config.text_config`. Our HF config stores it as `config.llm_config`; expose an alias so the | ||
| 138 | Added: # same config object loads under both loaders without having to duplicate the dict on disk. | ||
| 139 | Added: @property | ||
| 140 | Added: def text_config(self): | ||
| 141 | Added: return self.llm_config | ||
configuration_radio.py
Added+93 -0
configuration_radio.py
| @@ -0,0 +1,93 @@ | |||
| 1 | Added: # Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved. | ||
| 2 | Added: # | ||
| 3 | Added: # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | Added: # you may not use this file except in compliance with the License. | ||
| 5 | Added: # You may obtain a copy of the License at | ||
| 6 | Added: # | ||
| 7 | Added: # http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | Added: # | ||
| 9 | Added: # Unless required by applicable law or agreed to in writing, software | ||
| 10 | Added: # distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | Added: # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | Added: # See the License for the specific language governing permissions and | ||
| 13 | Added: # limitations under the License. | ||
| 14 | Added: """RADIO vision encoder configuration.""" | ||
| 15 | Added: | ||
| 16 | Added: from huggingface_hub.dataclasses import strict | ||
| 17 | Added: from transformers.configuration_utils import PreTrainedConfig | ||
| 18 | Added: from transformers.image_utils import OPENAI_CLIP_MEAN, OPENAI_CLIP_STD | ||
| 19 | Added: from transformers.utils import auto_docstring | ||
| 20 | Added: | ||
| 21 | Added: | ||
| 22 | Added: __all__ = ["RadioConfig"] | ||
| 23 | Added: | ||
| 24 | Added: | ||
| 25 | Added: @auto_docstring(checkpoint="nvidia/C-RADIOv4-H") | ||
| 26 | Added: @strict | ||
| 27 | Added: class RadioConfig(PreTrainedConfig): | ||
| 28 | Added: r""" | ||
| 29 | Added: mlp_ratio (`float`, *optional*, defaults to 4.0): | ||
| 30 | Added: Ratio of the hidden size of the MLP relative to `hidden_size`. | ||
| 31 | Added: use_swiglu_ffn (`bool`, *optional*, defaults to `False`): | ||
| 32 | Added: Whether to use a SwiGLU feed-forward network in the encoder layers instead of the standard MLP. | ||
| 33 | Added: layerscale_value (`float`, *optional*, defaults to 1.0): | ||
| 34 | Added: Initial value for the LayerScale parameters. C-RADIO has no LayerScale; the default of `1.0` makes the | ||
| 35 | Added: (inherited) LayerScale an identity operation. | ||
| 36 | Added: max_img_size (`int`, *optional*, defaults to 2048): | ||
| 37 | Added: Maximum supported image size (in pixels) used to size the position embedding table of the CPE patch generator. | ||
| 38 | Added: num_cls_tokens (`int`, *optional*, defaults to 3): | ||
| 39 | Added: Number of learned class (summary) tokens prepended to the patch sequence. | ||
| 40 | Added: num_registers (`int`, *optional*, defaults to 7): | ||
| 41 | Added: Number of learned register tokens prepended to the patch sequence. | ||
| 42 | Added: summary_idxs (`list[int]`, *optional*, defaults to `[0, 1]`): | ||
| 43 | Added: Indices of the class tokens to gather and flatten into the `summary` output embedding. | ||
| 44 | Added: norm_mean (`tuple[float, float, float]`, *optional*, defaults to `OPENAI_CLIP_MEAN`): | ||
| 45 | Added: Per-channel mean used by the input conditioner to normalize pixel values. | ||
| 46 | Added: norm_std (`tuple[float, float, float]`, *optional*, defaults to `OPENAI_CLIP_STD`): | ||
| 47 | Added: Per-channel standard deviation used by the input conditioner to normalize pixel values. | ||
| 48 | Added: video_temporal_patch_size (`int`, *optional*): | ||
| 49 | Added: Number of temporally-stacked frames per patch. When set, the patch generator also builds a | ||
| 50 | Added: `video_patch_projection` for temporally-packed video patches; `None` disables the video path. | ||
| 51 | Added: """ | ||
| 52 | Added: | ||
| 53 | Added: model_type = "radio" | ||
| 54 | Added: | ||
| 55 | Added: hidden_size: int = 1280 | ||
| 56 | Added: num_hidden_layers: int = 32 | ||
| 57 | Added: num_attention_heads: int = 16 | ||
| 58 | Added: mlp_ratio: float = 4.0 | ||
| 59 | Added: hidden_act: str = "gelu" | ||
| 60 | Added: layer_norm_eps: float = 1e-6 | ||
| 61 | Added: attention_probs_dropout_prob: float = 0.0 | ||
| 62 | Added: hidden_dropout_prob: float = 0.0 | ||
| 63 | Added: drop_path_rate: float = 0.0 | ||
| 64 | Added: use_swiglu_ffn: bool = False | ||
| 65 | Added: qkv_bias: bool = True | ||
| 66 | Added: # C-RADIO has no layerscale; 1.0 makes the (inherited) layerscale an identity op. | ||
| 67 | Added: layerscale_value: float = 1.0 | ||
| 68 | Added: # patch / image | ||
| 69 | Added: num_channels: int = 3 | ||
| 70 | Added: patch_size: int = 16 | ||
| 71 | Added: image_size: int = 224 | ||
| 72 | Added: # CPE patch generator | ||
| 73 | Added: max_img_size: int = 2048 | ||
| 74 | Added: num_cls_tokens: int = 3 | ||
| 75 | Added: num_registers: int = 7 | ||
| 76 | Added: video_temporal_patch_size: int | None = None | ||
| 77 | Added: summary_idxs: list[int] | None = None | ||
| 78 | Added: # input conditioner | ||
| 79 | Added: norm_mean: list[float] | tuple[float, float, float] = tuple(OPENAI_CLIP_MEAN) | ||
| 80 | Added: norm_std: list[float] | tuple[float, float, float] = tuple(OPENAI_CLIP_STD) | ||
| 81 | Added: initializer_range: float = 0.02 | ||
| 82 | Added: | ||
| 83 | Added: def __post_init__(self, **kwargs): | ||
| 84 | Added: if self.summary_idxs is None: | ||
| 85 | Added: self.summary_idxs = [0, 1] | ||
| 86 | Added: self.norm_mean = list(self.norm_mean) | ||
| 87 | Added: self.norm_std = list(self.norm_std) | ||
| 88 | Added: super().__post_init__(**kwargs) | ||
| 89 | Added: | ||
| 90 | Added: @property | ||
| 91 | Added: def num_summary_tokens(self) -> int: | ||
| 92 | Added: """Number of skipped prefix tokens (cls + registers) before spatial features.""" | ||
| 93 | Added: return self.num_cls_tokens + self.num_registers | ||
explainability.md
Added+14 -0
explainability.md
| @@ -0,0 +1,14 @@ | |||
| 1 | Added: | Field | Response | | ||
| 2 | Added: | :---- | :---- | | ||
| 3 | Added: | Intended Task/Domain: | Text generation, reasoning, and chat | | ||
| 4 | Added: | Model Type: | Text-to-text Mamba2-Transformer Hybrid | | ||
| 5 | Added: | Intended Users: | Generative AI creators working with conversational AI models and image content. | | ||
| 6 | Added: | Output: | Text | | ||
| 7 | Added: | Tools used to evaluate datasets to identify synthetic data and ensure data authenticity. | We used a Gemma-3 4B-based filtering model fine-tuned on [Nemotron Content Safety Dataset v2](https://huggingface.co/datasets/nvidia/Aegis-AI-Content-Safety-Dataset-2.0) to ensure the quality of synthetic data. | | ||
| 8 | Added: | Describe how the model works: | Generates text by predicting the next word or token based on the context provided in the input sequence using multiple self-attention layers. | | ||
| 9 | Added: | Name the adversely impacted groups this has been tested to deliver comparable outcomes regardless of: | Age, Disability Status, Gender Identity, Nationality, Physical Appearance, Ethnicity, Socioeconomic Status, Sexual Orientation, Religion | | ||
| 10 | Added: | Technical Limitations & Mitigation: | This model performs particularly well in instruction following regimes, as such may be strongly influenced by untrusted inputs and should be paired with appropriate guardrails and data filtering to better align use-case behaviors when exposed to such data. | | ||
| 11 | Added: | Verified to have met prescribed NVIDIA quality standards: | Yes | | ||
| 12 | Added: | Performance Metrics: | Accuracy, Throughput, and User-side throughput | | ||
| 13 | Added: | Potential Known Risks: | The model was optimized explicitly for instruction following and as such is more susceptible to prompt injection and jailbreaking in various forms as a result of its instruction tuning. This means that the model should be paired with additional rails or system filtering to limit exposure to instructions from malicious sources -- either directly or indirectly by retrieval (e.g. via visiting a website) -- as they may yield outputs that can lead to harmful, system-level outcomes up to and including remote code execution in agentic systems when effective security controls including guardrails are not in place. The model may generate answers that may be inaccurate, omit key information, include irrelevant or redundant text, or produce socially unacceptable or undesirable text, even if the prompt itself does not include anything explicitly offensive. The model may exhibit self-anthropomorphism (e.g., displaying human-like characteristics in dialogue, such as expressing preferences and emotions). | | ||
| 14 | Added: | Licensing: | Use of this model is governed by the [OpenMDW License Agreement, version 1.1](https://raw.githubusercontent.com/OpenMDW/OpenMDW/refs/heads/main/1.1/LICENSE.OpenMDW-1.1) (OpenMDW-1.1). |(no newline at end of file) | ||
generation_config.json
Added+13 -0
generation_config.json
| @@ -0,0 +1,13 @@ | |||
| 1 | Added: { | ||
| 2 | Added: "_from_model_config": true, | ||
| 3 | Added: "bos_token_id": 1, | ||
| 4 | Added: "do_sample": true, | ||
| 5 | Added: "eos_token_id": [ | ||
| 6 | Added: 2, | ||
| 7 | Added: 11 | ||
| 8 | Added: ], | ||
| 9 | Added: "pad_token_id": 0, | ||
| 10 | Added: "temperature": 1.0, | ||
| 11 | Added: "top_p": 0.95, | ||
| 12 | Added: "transformers_version": "5.8.1" | ||
| 13 | Added: } | ||
harness_comparisons.png
Added
harness_comparisons.png
Binary file not shown.
hf_quant_config.json
Added
hf_quant_config.json
Large (LFS-tracked) file content changed — 5.4 MB
image_processing_nemotron_h_omni.py
Added+216 -0
image_processing_nemotron_h_omni.py
| @@ -0,0 +1,216 @@ | |||
| 1 | Added: # Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved. | ||
| 2 | Added: # | ||
| 3 | Added: # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | Added: # you may not use this file except in compliance with the License. | ||
| 5 | Added: # You may obtain a copy of the License at | ||
| 6 | Added: # | ||
| 7 | Added: # http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | Added: # | ||
| 9 | Added: # Unless required by applicable law or agreed to in writing, software | ||
| 10 | Added: # distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | Added: # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | Added: # See the License for the specific language governing permissions and | ||
| 13 | Added: # limitations under the License. | ||
| 14 | Added: """Fast image processor for the NemotronH Omni model.""" | ||
| 15 | Added: | ||
| 16 | Added: import math | ||
| 17 | Added: | ||
| 18 | Added: import numpy as np | ||
| 19 | Added: from transformers.image_processing_backends import TorchvisionBackend | ||
| 20 | Added: from transformers.image_processing_base import BatchFeature | ||
| 21 | Added: from transformers.image_utils import ImageInput, ImageType, get_image_type, make_list_of_images | ||
| 22 | Added: from transformers.utils import is_torch_available | ||
| 23 | Added: | ||
| 24 | Added: | ||
| 25 | Added: if is_torch_available(): | ||
| 26 | Added: import torch | ||
| 27 | Added: | ||
| 28 | Added: | ||
| 29 | Added: class NemotronH_Omni_Reasoning_V3ImageProcessor(TorchvisionBackend): | ||
| 30 | Added: """ | ||
| 31 | Added: Dynamic-resolution image processor for the NemotronH Omni model. | ||
| 32 | Added: | ||
| 33 | Added: Each image is resized to a single tile whose patch-grid `(h_patches, w_patches)` is chosen to | ||
| 34 | Added: land between `min_num_patches` and `max_num_patches` (on a `patch_size` grid), respecting the | ||
| 35 | Added: aspect ratio, then normalized with `norm_mean` / `norm_std`. Video frames use a separate fixed | ||
| 36 | Added: target-patch budget with aspect ratio preserved (toggled via `_is_video_mode`). | ||
| 37 | Added: """ | ||
| 38 | Added: | ||
| 39 | Added: model_input_names = ["pixel_values"] | ||
| 40 | Added: | ||
| 41 | Added: def __init__( | ||
| 42 | Added: self, | ||
| 43 | Added: norm_mean=None, | ||
| 44 | Added: norm_std=None, | ||
| 45 | Added: patch_size=16, | ||
| 46 | Added: downsample_ratio=0.5, | ||
| 47 | Added: min_num_patches=1024, | ||
| 48 | Added: max_num_patches=13312, | ||
| 49 | Added: max_model_len=16384, | ||
| 50 | Added: video_target_num_patches=1024, | ||
| 51 | Added: video_maintain_aspect_ratio=True, | ||
| 52 | Added: **kwargs, | ||
| 53 | Added: ): | ||
| 54 | Added: super().__init__(**kwargs) | ||
| 55 | Added: self.norm_mean = norm_mean | ||
| 56 | Added: self.norm_std = norm_std | ||
| 57 | Added: self.patch_size = patch_size | ||
| 58 | Added: self.downsample_ratio = downsample_ratio | ||
| 59 | Added: # Integer reduction factor for pixel_shuffle (downsample_ratio = 0.5 -> factor 2). | ||
| 60 | Added: self._downsample_factor = int(round(1.0 / downsample_ratio)) | ||
| 61 | Added: # Per-image patch-grid bounds (on the pre-pixel-shuffle `patch_size` grid). | ||
| 62 | Added: self.min_num_patches = min_num_patches | ||
| 63 | Added: self.max_num_patches = max_num_patches | ||
| 64 | Added: self.max_model_len = max_model_len | ||
| 65 | Added: # Video frames use a separate (fixed) target-patch budget with aspect-ratio preserved. | ||
| 66 | Added: self.video_target_num_patches = video_target_num_patches | ||
| 67 | Added: self.video_maintain_aspect_ratio = video_maintain_aspect_ratio | ||
| 68 | Added: | ||
| 69 | Added: # Keep the PIL image through to `_preprocess`: we need PIL.resize semantics to match the | ||
| 70 | Added: # reference tiling algorithm exactly; resizing a tensor via `torchvision.transforms.Resize` | ||
| 71 | Added: # uses different kernels and breaks bit-exact agreement. | ||
| 72 | Added: def _process_image(self, image: ImageInput, **kwargs): | ||
| 73 | Added: if get_image_type(image) == ImageType.PIL: | ||
| 74 | Added: if image.mode != "RGB": | ||
| 75 | Added: image = image.convert("RGB") | ||
| 76 | Added: return image | ||
| 77 | Added: | ||
| 78 | Added: # transformers 5.6 renamed this hook from `_process_image` to `process_image`; alias both. | ||
| 79 | Added: process_image = _process_image | ||
| 80 | Added: | ||
| 81 | Added: # Toggled by the processor around video calls (the strict `ImagesKwargs` validator won't let us | ||
| 82 | Added: # thread a new kwarg down, so we use a flag on the instance instead). | ||
| 83 | Added: _is_video_mode: bool = False | ||
| 84 | Added: | ||
| 85 | Added: def _preprocess(self, images, return_tensors=None, **kwargs) -> BatchFeature: | ||
| 86 | Added: """Resize each image to its dynamic-resolution tile, normalize, and return pixel values. | ||
| 87 | Added: | ||
| 88 | Added: When `self._is_video_mode=True` (flipped by the processor before the video call), each | ||
| 89 | Added: input is resized using the **video** target-size rule (`video_target_num_patches`, | ||
| 90 | Added: aspect-ratio preserved) instead of the image dynamic-res rule. | ||
| 91 | Added: """ | ||
| 92 | Added: is_video = self._is_video_mode | ||
| 93 | Added: images = make_list_of_images(images) | ||
| 94 | Added: | ||
| 95 | Added: target_sizes = [] | ||
| 96 | Added: if is_video: | ||
| 97 | Added: for img in images: | ||
| 98 | Added: target_w_patches, target_h_patches = self._compute_target_patches_video(img) | ||
| 99 | Added: target_sizes.append((target_w_patches, target_h_patches)) | ||
| 100 | Added: else: | ||
| 101 | Added: # Image path: per-image budget bounded by [min_num_patches, max_num_patches], with a | ||
| 102 | Added: # global cap derived from `max_model_len` x pixel-shuffle factor^2. | ||
| 103 | Added: num_tokens_available = self.max_model_len - 4 | ||
| 104 | Added: budget = num_tokens_available * (self._downsample_factor**2) | ||
| 105 | Added: budget = max(budget, self.min_num_patches * len(images)) | ||
| 106 | Added: max_budget = self.max_num_patches if (self.max_num_patches and self.max_num_patches > 0) else float("inf") | ||
| 107 | Added: per_image_budget = [max(min(budget, max_budget), self.min_num_patches) for _ in images] | ||
| 108 | Added: for img, tokens_for_media in zip(images, per_image_budget): | ||
| 109 | Added: target_w_patches, target_h_patches = self._compute_target_patches(img, tokens_for_media) | ||
| 110 | Added: target_sizes.append((target_w_patches, target_h_patches)) | ||
| 111 | Added: | ||
| 112 | Added: norm_mean = torch.tensor(self.norm_mean).view(1, 3, 1, 1) | ||
| 113 | Added: norm_std = torch.tensor(self.norm_std).view(1, 3, 1, 1) | ||
| 114 | Added: | ||
| 115 | Added: pixel_values_list = [] | ||
| 116 | Added: num_tokens_per_image = [] | ||
| 117 | Added: imgs_sizes = [] | ||
| 118 | Added: for img, (wp, hp) in zip(images, target_sizes): | ||
| 119 | Added: target_w = wp * self.patch_size | ||
| 120 | Added: target_h = hp * self.patch_size | ||
| 121 | Added: # Antialiased bicubic interpolation via `torch.nn.functional.interpolate`. PIL's bicubic | ||
| 122 | Added: # uses a different kernel (and no antialiasing), producing pixel values that amplify | ||
| 123 | Added: # through the ViT / mamba stack and cause outputs to diverge past the first few tokens. | ||
| 124 | Added: arr = np.asarray(img, dtype=np.uint8) # (H, W, 3) | ||
| 125 | Added: t = torch.from_numpy(arr).permute(2, 0, 1).unsqueeze(0).to(dtype=torch.float32) # (1, 3, H, W) | ||
| 126 | Added: if t.shape[-2] != target_h or t.shape[-1] != target_w: | ||
| 127 | Added: t = torch.nn.functional.interpolate( | ||
| 128 | Added: t, size=(target_h, target_w), mode="bicubic", align_corners=False, antialias=True | ||
| 129 | Added: ) | ||
| 130 | Added: t = (t / 255.0 - norm_mean) / norm_std | ||
| 131 | Added: pixel_values_list.append(t.squeeze(0)) # (3, H, W) | ||
| 132 | Added: num_tokens_per_image.append((wp * hp) // (self._downsample_factor**2)) | ||
| 133 | Added: imgs_sizes.append((target_h, target_w)) | ||
| 134 | Added: | ||
| 135 | Added: # Stack if all images have the same target size; otherwise keep as a list of | ||
| 136 | Added: # (3, H_i, W_i) tensors (the model's `extract_feature` handles both). | ||
| 137 | Added: all_same_shape = all(t.shape == pixel_values_list[0].shape for t in pixel_values_list) | ||
| 138 | Added: pixel_values = torch.stack(pixel_values_list, dim=0) if all_same_shape else pixel_values_list | ||
| 139 | Added: | ||
| 140 | Added: return BatchFeature( | ||
| 141 | Added: data={ | ||
| 142 | Added: "pixel_values": pixel_values, | ||
| 143 | Added: "num_patches": [1] * len(images), | ||
| 144 | Added: "num_tokens": num_tokens_per_image, | ||
| 145 | Added: "imgs_sizes": imgs_sizes, | ||
| 146 | Added: }, | ||
| 147 | Added: tensor_type=(return_tensors if all_same_shape else None), | ||
| 148 | Added: ) | ||
| 149 | Added: | ||
| 150 | Added: def _compute_target_patches(self, img, tokens_available: int): | ||
| 151 | Added: """Choose the `(w_patches, h_patches)` tile that best fits `tokens_available` (image path).""" | ||
| 152 | Added: orig_w, orig_h = img.width, img.height | ||
| 153 | Added: # Ceil-ish: `round(x + 0.5)` == `floor(x) + 1` for non-integer x, `x` for integer. | ||
| 154 | Added: closest_patch_h = round(orig_h / self.patch_size + 0.5) | ||
| 155 | Added: closest_patch_w = round(orig_w / self.patch_size + 0.5) | ||
| 156 | Added: patches = closest_patch_h * closest_patch_w | ||
| 157 | Added: | ||
| 158 | Added: # Downscale to fit the token budget. | ||
| 159 | Added: factor = min(math.sqrt(tokens_available / patches), 1.0) | ||
| 160 | Added: target_h = math.floor(factor * closest_patch_h) | ||
| 161 | Added: target_w = math.floor(factor * closest_patch_w) | ||
| 162 | Added: | ||
| 163 | Added: # Scale up if below the per-image minimum. | ||
| 164 | Added: if tokens_available > self.min_num_patches and target_h * target_w < self.min_num_patches: | ||
| 165 | Added: up = math.sqrt(self.min_num_patches / (target_h * target_w)) | ||
| 166 | Added: target_h = math.ceil(up * target_h) | ||
| 167 | Added: target_w = math.ceil(up * target_w) | ||
| 168 | Added: | ||
| 169 | Added: # Round each dim to a multiple of the pixel_shuffle factor so tokens divide evenly. | ||
| 170 | Added: divisor = self._downsample_factor | ||
| 171 | Added: rem_h = target_h % divisor | ||
| 172 | Added: if rem_h: | ||
| 173 | Added: inc_h = divisor - rem_h | ||
| 174 | Added: if (target_h + inc_h) * target_w <= tokens_available: | ||
| 175 | Added: target_h += inc_h | ||
| 176 | Added: else: | ||
| 177 | Added: target_h = max(divisor, target_h - rem_h) | ||
| 178 | Added: rem_w = target_w % divisor | ||
| 179 | Added: if rem_w: | ||
| 180 | Added: inc_w = divisor - rem_w | ||
| 181 | Added: if target_h * (target_w + inc_w) <= tokens_available: | ||
| 182 | Added: target_w += inc_w | ||
| 183 | Added: else: | ||
| 184 | Added: target_w = max(divisor, target_w - rem_w) | ||
| 185 | Added: | ||
| 186 | Added: return target_w, target_h | ||
| 187 | Added: | ||
| 188 | Added: def _compute_target_patches_video(self, img): | ||
| 189 | Added: """Choose an aspect-preserving `(w_patches, h_patches)` tile near `video_target_num_patches`.""" | ||
| 190 | Added: orig_w, orig_h = img.width, img.height | ||
| 191 | Added: target = self.video_target_num_patches | ||
| 192 | Added: divisor = self._downsample_factor | ||
| 193 | Added: if self.video_maintain_aspect_ratio: | ||
| 194 | Added: aspect_wh = orig_w / max(orig_h, 1) | ||
| 195 | Added: ph = max(round(math.sqrt(target / aspect_wh)), 1) | ||
| 196 | Added: pw = max(round(math.sqrt(target * aspect_wh)), 1) | ||
| 197 | Added: if divisor > 1: | ||
| 198 | Added: rem_h = ph % divisor | ||
| 199 | Added: rem_w = pw % divisor | ||
| 200 | Added: ph_up = ph + (divisor - rem_h if rem_h else 0) | ||
| 201 | Added: ph_down = ph - rem_h | ||
| 202 | Added: pw_up = pw + (divisor - rem_w if rem_w else 0) | ||
| 203 | Added: pw_down = pw - rem_w | ||
| 204 | Added: if ph_up * pw_up <= target: | ||
| 205 | Added: ph, pw = ph_up, pw_up | ||
| 206 | Added: else: | ||
| 207 | Added: ph = max(divisor, ph_down) | ||
| 208 | Added: pw = max(divisor, pw_down) | ||
| 209 | Added: else: | ||
| 210 | Added: side = int(math.sqrt(target)) | ||
| 211 | Added: side = max(divisor, (side // divisor) * divisor) | ||
| 212 | Added: ph = pw = side | ||
| 213 | Added: return pw, ph | ||
| 214 | Added: | ||
| 215 | Added: | ||
| 216 | Added: __all__ = ["NemotronH_Omni_Reasoning_V3ImageProcessor"] | ||
model-00001-of-00088.safetensors
Added
model-00001-of-00088.safetensors
Large (LFS-tracked) file content changed — 2.7 GB
model-00002-of-00088.safetensors
Added
model-00002-of-00088.safetensors
Large (LFS-tracked) file content changed — 1.5 GB
model-00003-of-00088.safetensors
Added
model-00003-of-00088.safetensors
Large (LFS-tracked) file content changed — 105 MB
model-00004-of-00088.safetensors
Added
model-00004-of-00088.safetensors
Large (LFS-tracked) file content changed — 1.5 GB
model-00005-of-00088.safetensors
Added
model-00005-of-00088.safetensors
Large (LFS-tracked) file content changed — 105 MB
model-00006-of-00088.safetensors
Added
model-00006-of-00088.safetensors
Large (LFS-tracked) file content changed — 1.5 GB
model-00008-of-00088.safetensors
Added
model-00008-of-00088.safetensors
Large (LFS-tracked) file content changed — 34 MB
model-00009-of-00088.safetensors
Added
model-00009-of-00088.safetensors
Large (LFS-tracked) file content changed — 1.5 GB
model-00010-of-00088.safetensors
Added
model-00010-of-00088.safetensors
Large (LFS-tracked) file content changed — 105 MB
model-00011-of-00088.safetensors
Added
model-00011-of-00088.safetensors
Large (LFS-tracked) file content changed — 1.5 GB
model-00012-of-00088.safetensors
Added
model-00012-of-00088.safetensors
Large (LFS-tracked) file content changed — 105 MB
model-00013-of-00088.safetensors
Added
model-00013-of-00088.safetensors
Large (LFS-tracked) file content changed — 1.5 GB
model-00015-of-00088.safetensors
Added
model-00015-of-00088.safetensors
Large (LFS-tracked) file content changed — 1.5 GB
model-00016-of-00088.safetensors
Added
model-00016-of-00088.safetensors
Large (LFS-tracked) file content changed — 105 MB
model-00018-of-00088.safetensors
Added
model-00018-of-00088.safetensors
Large (LFS-tracked) file content changed — 1.5 GB
model-00019-of-00088.safetensors
Added
model-00019-of-00088.safetensors
Large (LFS-tracked) file content changed — 105 MB
model-00020-of-00088.safetensors
Added
model-00020-of-00088.safetensors
Large (LFS-tracked) file content changed — 1.5 GB
model-00022-of-00088.safetensors
Added
model-00022-of-00088.safetensors
Large (LFS-tracked) file content changed — 1.5 GB
model-00023-of-00088.safetensors
Added
model-00023-of-00088.safetensors
Large (LFS-tracked) file content changed — 105 MB
model-00024-of-00088.safetensors
Added
model-00024-of-00088.safetensors
Large (LFS-tracked) file content changed — 1.5 GB
model-00025-of-00088.safetensors
Added
model-00025-of-00088.safetensors
Large (LFS-tracked) file content changed — 105 MB
model-00026-of-00088.safetensors
Added
model-00026-of-00088.safetensors
Large (LFS-tracked) file content changed — 34 MB
model-00027-of-00088.safetensors
Added
model-00027-of-00088.safetensors
Large (LFS-tracked) file content changed — 1.5 GB
model-00028-of-00088.safetensors
Added
model-00028-of-00088.safetensors
Large (LFS-tracked) file content changed — 105 MB
model-00029-of-00088.safetensors
Added
model-00029-of-00088.safetensors
Large (LFS-tracked) file content changed — 1.5 GB
model-00030-of-00088.safetensors
Added
model-00030-of-00088.safetensors
Large (LFS-tracked) file content changed — 105 MB
model-00031-of-00088.safetensors
Added
model-00031-of-00088.safetensors
Large (LFS-tracked) file content changed — 1.5 GB
model-00032-of-00088.safetensors
Added
model-00032-of-00088.safetensors
Large (LFS-tracked) file content changed — 105 MB
model-00034-of-00088.safetensors
Added
model-00034-of-00088.safetensors
Large (LFS-tracked) file content changed — 105 MB
model-00035-of-00088.safetensors
Added
model-00035-of-00088.safetensors
Large (LFS-tracked) file content changed — 1.5 GB
model-00036-of-00088.safetensors
Added
model-00036-of-00088.safetensors
Large (LFS-tracked) file content changed — 105 MB
model-00037-of-00088.safetensors
Added
model-00037-of-00088.safetensors
Large (LFS-tracked) file content changed — 34 MB
model-00038-of-00088.safetensors
Added
model-00038-of-00088.safetensors
Large (LFS-tracked) file content changed — 1.5 GB
model-00040-of-00088.safetensors
Added
model-00040-of-00088.safetensors
Large (LFS-tracked) file content changed — 1.5 GB
model-00041-of-00088.safetensors
Added
model-00041-of-00088.safetensors
Large (LFS-tracked) file content changed — 105 MB
model-00042-of-00088.safetensors
Added
model-00042-of-00088.safetensors
Large (LFS-tracked) file content changed — 1.5 GB
model-00043-of-00088.safetensors
Added
model-00043-of-00088.safetensors
Large (LFS-tracked) file content changed — 105 MB
model-00044-of-00088.safetensors
Added
model-00044-of-00088.safetensors
Large (LFS-tracked) file content changed — 1.5 GB