README.md CHANGED
@@ -7,16 +7,8 @@ tags:
7
  - text-to-image
8
  - image-to-image
9
  ---
 
10
 
11
- # Nemotron-Labs-Diffusion-Uni-8B
12
-
13
- ## Description
14
-
15
- NLD-Uni is a unified multimodal model for image understanding and image generation. It combines a diffusion language model with specialized visual components and a mixture-of-transformers design. Understanding and generation use distinct transformer parameter paths within a common multimodal framework.
16
-
17
- For image understanding, NLD-Uni encodes images into continuous visual features and generates text responses. For image generation, it models discrete visual tokens through iterative diffusion and decodes those tokens into RGB images. The architecture supports autoregressive and blockwise diffusion decoding for text, as well as image-conditioned generation and editing when enabled by the checkpoint and inference implementation.
18
-
19
- This card describes the NLD-Uni architecture generally.
20
 
21
  ## Environment
22
 
@@ -53,6 +45,23 @@ print(answer)
53
 
54
  Image inputs accept Pillow images or local file paths. Image methods return Pillow images; `generate` returns text by default. Token IDs can be supplied through `input_ids` for text prompts, and `return_token_ids=True` returns the generated token tensor. The `inference.py` command exposes each task.
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  ## Minimal command-line inference
57
 
58
  ```bash
@@ -62,168 +71,3 @@ python inference.py /path/to/hf_checkpoint --task understand --image blue.png --
62
  ```
63
 
64
  Replace the model argument with the published Hugging Face model ID for remote loading. The standalone script only uses Transformers and this repository's model code.
65
-
66
-
67
- ### License/Terms of Use
68
-
69
- GOVERNING TERMS: Use of this model is governed by the [NVIDIA Open Source License Agreement](https://huggingface.co/nvidia/NL-Diffusion-Image/raw/main/LICENSE).
70
-
71
- ## Deployment Geography
72
-
73
- Global, subject to the governing release terms.
74
-
75
- ## Use Case
76
-
77
- NLD-Uni is intended for research and evaluation of unified multimodal systems, including:
78
-
79
- - Visual question answering and image-grounded reasoning.
80
- - Document, chart, and scene-text understanding.
81
- - Visual grounding and interface localization using task-specific prompts and output formats.
82
- - Text-to-image generation.
83
- - Image-conditioned generation and editing for checkpoints trained for these tasks.
84
-
85
- ## Release Date
86
-
87
- 10/27/2026
88
-
89
- ## Model Architecture
90
-
91
- **Architecture Type:** Transformer
92
-
93
- **Network Architecture:** Diffusion language model with understanding and generation transformer paths, a continuous visual encoder for understanding, and a discrete image tokenizer for generation.
94
-
95
- **Language-model foundation:** Nemotron diffusion language model.
96
-
97
- ## Input
98
-
99
- **Input Type(s):** Text and images.
100
-
101
- **Input Format(s):** Text strings and image objects or tensors accepted by the supplied processor.
102
-
103
- **Input Parameters:** One-dimensional text-token sequences and two-dimensional image content, represented internally as visual features or discrete image tokens according to the task.
104
-
105
- **Other Properties Related to Input:** Context length, image resolution, visual-token budget, and preprocessing are checkpoint- and task-dependent. The released inference configuration defines the supported limits; a universal 900-token prompt limit is not specified for the architecture.
106
-
107
- ## Output
108
-
109
- **Output Type(s):**
110
-
111
- - Text
112
- - Image
113
-
114
- **Output Format(s):**
115
-
116
- - **Text:** `.json` (UTF-8 JSON records containing generated text).
117
- - **Image:** `.png` (RGB images).
118
-
119
- These serialized formats are implemented by `validate.py`. The inference API returns text strings or token IDs for understanding and decoded image objects or tensors for generation. Grounding outputs follow the requested coordinate or location-token format.
120
-
121
- **Output Parameters:** One-dimensional token sequences or images with height, width, and three color channels. Tensor layout and pixel range are defined by the inference API.
122
-
123
- **Other Properties Related to Output:** Text output length and generated image resolution depend on the checkpoint and inference settings. Configurations for 1,024 × 1,024 image generation are implemented; the release should list its validated resolutions.
124
-
125
- ## Software Integration
126
-
127
- NLD-Uni’s native implementation uses PyTorch with CUDA-accelerated execution. The codebase also includes a dedicated SGLang integration for the image-understanding and text-generation path. This does not establish SGLang support for the image-generation path.
128
-
129
- **Runtime Engine(s):**
130
-
131
- - PyTorch for native multimodal inference.
132
- - SGLang with the NLD-Uni/LaVida RADIO-H adapter for supported understanding configurations.
133
-
134
- **Reference Platform:** Linux with NVIDIA CUDA GPUs.
135
-
136
- **Reference Evaluation Hardware:** NVIDIA H100 (Hopper).
137
-
138
- ## Model Version(s)
139
-
140
- - **NLD-Uni:** Unified image-understanding and image-generation architecture based on LaVida-O.
141
-
142
- Training stage, checkpoint revision, tokenizer revision, and inference configuration are part of the identity of an evaluated model. Results from earlier LaVida-O or image-only diffusion models should retain their original model names.
143
-
144
- # Training and Evaluation Datasets
145
-
146
- ## Training Dataset
147
-
148
- More than 100M image-text pairs.
149
-
150
- **Data Collection Method by dataset**
151
-
152
- - Hybrid: Automated, Manually-Collected, Synthetic
153
-
154
- **Labeling Method by dataset**
155
-
156
- - Hybrid: Automated, Manually-Labeled, Synthetic
157
-
158
- ## Evaluation Datasets
159
-
160
- ### Documented Functional Validation Dataset
161
-
162
- - **Modalities:** Text and RGB images.
163
- - **Nature of content:** Synthetic everyday-object, animal, and landscape scenes; text-to-image prompts, edit instructions, and image-understanding questions. The generated images are used as inputs to subsequent editing and understanding tasks.
164
- - **Linguistic characteristics:** English prompts, edit instructions, questions, and recorded answers.
165
- - **Collection and labeling:** Three scripted scene cases in `validate.py`; model-generated images and answers were manually inspected for prompt alignment and editing fidelity.
166
-
167
- Counts and results are recorded in [VALIDATION.md](VALIDATION.md), [validation.json](validation.json), and [examples/results.json](examples/results.json). These are functional smoke tests, not measurements of benchmark accuracy.
168
-
169
- ### Benchmark Evaluation Properties
170
-
171
- The benchmark suite below covers image and text inputs, including mathematical and scientific questions, documents, charts, scene text, interfaces, referring expressions, and image-generation prompts. OCRBenchV2-EN identifies an English subset; the exact language coverage of the other evaluated splits must be documented from the evaluation records.
172
-
173
- ### Image Understanding
174
-
175
- The evaluation suite should identify the following benchmarks and splits explicitly:
176
-
177
- | Benchmark | Evaluation target | Primary reporting requirement |
178
- |---|---|---|
179
- | MathVista_MINI | Visual mathematical reasoning | Full 1,000-example accuracy; identify answer-extraction judge |
180
- | MMMU_DEV_VAL | Multidisciplinary visual reasoning | Report development and validation splits separately |
181
- | AI2D_TEST | Diagram understanding | Accuracy and image/prompt protocol |
182
- | ChartQA_TEST | Chart question answering | Relaxed accuracy and subset aggregation |
183
- | DocVQA_VAL | Document question answering | ANLS |
184
- | TextVQA_VAL | Scene-text question answering | VQA accuracy with specified normalization |
185
- | RealWorldQA | Real-world visual understanding | Accuracy |
186
- | InfoVQA_VAL | Infographic question answering | ANLS |
187
- | ScienceQA_TEST | Science question answering | Identify the image-containing subset when used |
188
- | ScreenSpot-Pro | Interface grounding | Point-localization accuracy; separate first-pass and crop-refined results |
189
- | RefCOCO | Referring-expression grounding | IoU ≥ 0.5 accuracy for val, testA, and testB; disclose the native LOC protocol |
190
- | OCRBenchV2-EN | OCR and document understanding | Official English category aggregation |
191
-
192
- ### Image Generation
193
-
194
- | Benchmark | Evaluation target | Primary metric |
195
- |---|---|---|
196
- | GenEval | Object presence, counts, colors, positions, and attribute binding | Overall and category scores |
197
- | DPG-Bench | Alignment with detailed compositional prompts | Overall and category scores |
198
- | MJHQ-30K | Generated-image distribution and quality | FID; any additional preference metric must identify its model and version |
199
-
200
- Evaluation should identify the exact checkpoint, prompt processing, image preprocessing, decoding parameters, seed policy, sample count, and evaluator version. Report reasoning and non-reasoning results separately. Tokenizer reconstruction evaluation, if performed, should be identified separately from end-to-end image-generation quality.
201
-
202
- ## Key Considerations
203
-
204
- NLD-Uni can produce incorrect text, inaccurate grounding coordinates, and synthetic images that do not fully follow the prompt. Generated content may reflect biases in training data or contain inappropriate material. Image-conditioned outputs may change details that users intended to preserve.
205
-
206
- Applications should be evaluated on their intended tasks and data, with appropriate input and output controls. Model outputs should not be treated as verified factual evidence solely because they are fluent or visually plausible.
207
-
208
- ## Inference
209
-
210
- **Native Engine:** PyTorch.
211
-
212
- **Understanding Serving Integration:** SGLang with the model-specific adapter, for validated configurations.
213
-
214
- **Reference Precision:** BF16 where supported by the selected implementation.
215
-
216
- **Reference Hardware:** NVIDIA H100.
217
-
218
- Use the model-specific tokenizer, processor, chat template, and task interface. Image understanding uses the continuous visual encoder; image generation uses the discrete image-token pipeline. Runtime optimizations, including CUDA graphs, should be evaluated with the exact checkpoint and decode configuration before publishing accuracy or speed claims.
219
-
220
- ## Ethical Considerations
221
-
222
- NVIDIA believes trustworthy AI is a shared responsibility. Developers should evaluate NLD-Uni for the intended application, including potential errors, bias, privacy concerns, and misuse of generated content.
223
-
224
- Users should have appropriate rights and permissions for input images and other supplied content. Generated or edited images may alter identities, text, object proportions, or scene details. Applications should communicate the synthetic nature of generated content where appropriate.
225
-
226
- Users are responsible for model inputs and outputs and for implementing appropriate safeguards before deployment.
227
-
228
- Report model quality concerns, security vulnerabilities, or NVIDIA AI concerns through [NVIDIA’s reporting channel](https://www.nvidia.com/en-us/support/submit-security-vulnerability/).
229
-
 
7
  - text-to-image
8
  - image-to-image
9
  ---
10
+ # NLD-Uni
11
 
 
 
 
 
 
 
 
 
 
12
 
13
  ## Environment
14
 
 
45
 
46
  Image inputs accept Pillow images or local file paths. Image methods return Pillow images; `generate` returns text by default. Token IDs can be supplied through `input_ids` for text prompts, and `return_token_ids=True` returns the generated token tensor. The `inference.py` command exposes each task.
47
 
48
+ ## Default inference recipes
49
+
50
+ | Parameter | Text-to-image | Image editing | Understanding |
51
+ |---|---|---|---|
52
+ | Resolution | 1024 × 1024 | 1024 × 1024 internally | Native aspect ratio with RADIO resizing |
53
+ | Activation steps | 64 | 64 | 32 steps per 32-token block |
54
+ | Semantic refinement stages | 4 | 4 | — |
55
+ | Guidance | 3.0 | Text 1.6, image 2.0, edit mode 1 | — |
56
+ | Temperature | 0.8 | 0.8 | 0.0 |
57
+ | Confidence policy | Stratified | Stratified | Threshold 0.9 |
58
+ | Schedule | Shift 5 | Shift 5 | Block diffusion |
59
+ | Maximum new tokens | — | — | 16000 |
60
+
61
+ Image sampling uses dynamic ranking temperature (5.0 down to 0.5, cosine-squared schedule), full-attention approximation, prompt caching, and checkpoint-native logit alignment. Four refinement stages add three trailing model calls to the 64 activation rounds. `refinement_steps` accepts 1, 4, 8, or 16; 1 is the direct root-to-token inference control.
62
+
63
+ The public image methods expose `resolution`, `steps`, `refinement_steps`, `guidance_scale`, `temperature`, `seed`, `top_k`, `top_p`, `shift`, and `show_progress`. Editing additionally exposes `image_guidance_scale` and `crop_to_source`; source-padding VQ codes are preserved. The default crops away square padding and restores the source dimensions. Understanding exposes `max_new_tokens`, `block_length`, `steps_per_block`, `threshold`, and `temperature`. No thinking prefix is added. Rotary phase calculations stay in FP32 even inside an external autocast context.
64
+
65
  ## Minimal command-line inference
66
 
67
  ```bash
 
71
  ```
72
 
73
  Replace the model argument with the published Hugging Face model ID for remote loading. The standalone script only uses Transformers and this repository's model code.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
attention.py CHANGED
@@ -75,9 +75,9 @@ class MinistralFlexAttention(Ministral3Attention):
75
  query_states = query_states * _get_llama_4_attn_scale(cache_position, self.config.rope_parameters.get('llama_4_scaling_beta'), self.config.rope_parameters.get('original_max_position_embeddings')).to(query_states.dtype)
76
  current_key_states = key_states
77
  current_value_states = value_states
78
- cached_routing_metadata = getattr(past_key_values, '_nlduni_dual_tower_routing', None)
79
  isolate_generation_flash = overwrite_attn_impl == 'flash_attn' and self.split_tower and (routing is not None or cached_routing_metadata is not None)
80
- cached_has_generation = bool(getattr(past_key_values, '_nlduni_dual_tower_has_generation', False))
81
  drop_cached_understanding = isolate_generation_flash and routing is True and (not cached_has_generation)
82
  if past_key_values is not None:
83
  if use_cache:
 
75
  query_states = query_states * _get_llama_4_attn_scale(cache_position, self.config.rope_parameters.get('llama_4_scaling_beta'), self.config.rope_parameters.get('original_max_position_embeddings')).to(query_states.dtype)
76
  current_key_states = key_states
77
  current_value_states = value_states
78
+ cached_routing_metadata = getattr(past_key_values, '_lavida_dual_tower_routing', None)
79
  isolate_generation_flash = overwrite_attn_impl == 'flash_attn' and self.split_tower and (routing is not None or cached_routing_metadata is not None)
80
+ cached_has_generation = bool(getattr(past_key_values, '_lavida_dual_tower_has_generation', False))
81
  drop_cached_understanding = isolate_generation_flash and routing is True and (not cached_has_generation)
82
  if past_key_values is not None:
83
  if use_cache:
chat_utils.py CHANGED
@@ -17,7 +17,7 @@ class SimpleOutputWithPast(ModelOutput):
17
  hidden_states: tuple[torch.FloatTensor, ...] | None = None
18
  attentions: tuple[torch.FloatTensor, ...] | None = None
19
  from .utils import maybe_truncate_last_dim, pad_along_last_dim
20
- from .configuration_nlduni import get_ministral_shift_sbd_logits
21
  from .sbd_attention import build_image_attention_doc_ids
22
 
23
  def _resolve_shift_sbd_logits(model, shift_logits):
 
17
  hidden_states: tuple[torch.FloatTensor, ...] | None = None
18
  attentions: tuple[torch.FloatTensor, ...] | None = None
19
  from .utils import maybe_truncate_last_dim, pad_along_last_dim
20
+ from .configuration_lavida import get_ministral_shift_sbd_logits
21
  from .sbd_attention import build_image_attention_doc_ids
22
 
23
  def _resolve_shift_sbd_logits(model, shift_logits):
config.json CHANGED
@@ -23,14 +23,14 @@
23
  "eos_token_id": 11,
24
  "pad_token_id": 11,
25
  "tie_word_embeddings": false,
26
- "model_type": "nlduni",
27
  "architectures": [
28
- "NLDUniForCausalLM"
29
  ],
30
  "torch_dtype": "bfloat16",
31
  "auto_map": {
32
- "AutoConfig": "configuration_nlduni.NLDUniConfig",
33
- "AutoModel": "modeling_nlduni.NLDUniForCausalLM",
34
- "AutoModelForCausalLM": "modeling_nlduni.NLDUniForCausalLM"
35
  }
36
  }
 
23
  "eos_token_id": 11,
24
  "pad_token_id": 11,
25
  "tie_word_embeddings": false,
26
+ "model_type": "lavida_semantic_tree",
27
  "architectures": [
28
+ "LaVidaForCausalLM"
29
  ],
30
  "torch_dtype": "bfloat16",
31
  "auto_map": {
32
+ "AutoConfig": "configuration_lavida.LaVidaConfig",
33
+ "AutoModel": "modeling_lavida.LaVidaForCausalLM",
34
+ "AutoModelForCausalLM": "modeling_lavida.LaVidaForCausalLM"
35
  }
36
  }
configuration_nlduni.py → configuration_lavida.py RENAMED
@@ -1,7 +1,7 @@
1
  from transformers import PretrainedConfig
2
 
3
- class NLDUniConfig(PretrainedConfig):
4
- model_type = 'nlduni'
5
  # Architecture invariants; deliberately absent from serialized configuration.
6
  d_model_gen = 4096
7
  d_model = 4096
@@ -53,7 +53,7 @@ class NLDUniConfig(PretrainedConfig):
53
  values.pop('_name_or_path', None)
54
  return values
55
 
56
- MinistralDLMConfig = NLDUniConfig
57
 
58
  def get_ministral_shift_sbd_logits(config):
59
  return True
 
1
  from transformers import PretrainedConfig
2
 
3
+ class LaVidaConfig(PretrainedConfig):
4
+ model_type = 'lavida_semantic_tree'
5
  # Architecture invariants; deliberately absent from serialized configuration.
6
  d_model_gen = 4096
7
  d_model = 4096
 
53
  values.pop('_name_or_path', None)
54
  return values
55
 
56
+ MinistralDLMConfig = LaVidaConfig
57
 
58
  def get_ministral_shift_sbd_logits(config):
59
  return True
core.py CHANGED
@@ -17,7 +17,7 @@ from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_u
17
  from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
18
  from transformers.processing_utils import Unpack
19
  from transformers.utils import TransformersKwargs, auto_docstring
20
- from .configuration_nlduni import MinistralDLMConfig
21
 
22
  def rotate_half(x):
23
  x1 = x[..., :x.shape[-1] // 2]
@@ -387,7 +387,7 @@ class Ministral3Model(Ministral3PreTrainedModel):
387
  if use_cache and past_key_values is None:
388
  past_key_values = DynamicCache()
389
  past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None and (partial_dual_tower or cache_position is None) else 0
390
- stored_cached_routing = getattr(past_key_values, '_nlduni_dual_tower_routing', None)
391
  track_dual_tower_routing = partial_dual_tower and (canonical_routing is not None or stored_cached_routing is not None)
392
  current_routing = _routing_mask(canonical_routing, inputs_embeds) if track_dual_tower_routing else None
393
  cached_routing = stored_cached_routing
@@ -398,8 +398,8 @@ class Ministral3Model(Ministral3PreTrainedModel):
398
  elif track_dual_tower_routing and cached_routing.device != current_routing.device:
399
  raise ValueError('cached dual-tower routing and inputs must share a device')
400
  if track_dual_tower_routing and past_key_values is not None:
401
- past_key_values._nlduni_dual_tower_routing = cached_routing
402
- past_key_values._nlduni_dual_tower_has_generation = bool(getattr(past_key_values, '_nlduni_dual_tower_has_generation', False))
403
  if cache_position is None:
404
  cache_position = torch.arange(past_seen_tokens, past_seen_tokens + inputs_embeds.shape[1], device=inputs_embeds.device)
405
  if position_ids is None:
@@ -420,7 +420,7 @@ class Ministral3Model(Ministral3PreTrainedModel):
420
  layer_kwargs = split_layer_kwargs if split_layer_kwargs is not None and layer_idx >= self.dual_tower_layers else kwargs
421
  hidden_states = decoder_layer(hidden_states, attention_mask=causal_mask, position_ids=position_ids, past_key_values=past_key_values, use_cache=use_cache, cache_position=cache_position, position_embeddings=position_embeddings, routing=canonical_routing, **layer_kwargs)
422
  if track_dual_tower_routing and use_cache and (past_key_values is not None):
423
- past_key_values._nlduni_dual_tower_routing = torch.cat((cached_routing, current_routing), dim=1)
424
- past_key_values._nlduni_dual_tower_has_generation = past_key_values._nlduni_dual_tower_has_generation or canonical_routing is not None
425
  hidden_states = _routed_module(hidden_states, canonical_routing, self.norm, getattr(self, 'norm_gen', None))
426
  return BaseModelOutputWithPast(last_hidden_state=hidden_states, past_key_values=past_key_values if use_cache else None)
 
17
  from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
18
  from transformers.processing_utils import Unpack
19
  from transformers.utils import TransformersKwargs, auto_docstring
20
+ from .configuration_lavida import MinistralDLMConfig
21
 
22
  def rotate_half(x):
23
  x1 = x[..., :x.shape[-1] // 2]
 
387
  if use_cache and past_key_values is None:
388
  past_key_values = DynamicCache()
389
  past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None and (partial_dual_tower or cache_position is None) else 0
390
+ stored_cached_routing = getattr(past_key_values, '_lavida_dual_tower_routing', None)
391
  track_dual_tower_routing = partial_dual_tower and (canonical_routing is not None or stored_cached_routing is not None)
392
  current_routing = _routing_mask(canonical_routing, inputs_embeds) if track_dual_tower_routing else None
393
  cached_routing = stored_cached_routing
 
398
  elif track_dual_tower_routing and cached_routing.device != current_routing.device:
399
  raise ValueError('cached dual-tower routing and inputs must share a device')
400
  if track_dual_tower_routing and past_key_values is not None:
401
+ past_key_values._lavida_dual_tower_routing = cached_routing
402
+ past_key_values._lavida_dual_tower_has_generation = bool(getattr(past_key_values, '_lavida_dual_tower_has_generation', False))
403
  if cache_position is None:
404
  cache_position = torch.arange(past_seen_tokens, past_seen_tokens + inputs_embeds.shape[1], device=inputs_embeds.device)
405
  if position_ids is None:
 
420
  layer_kwargs = split_layer_kwargs if split_layer_kwargs is not None and layer_idx >= self.dual_tower_layers else kwargs
421
  hidden_states = decoder_layer(hidden_states, attention_mask=causal_mask, position_ids=position_ids, past_key_values=past_key_values, use_cache=use_cache, cache_position=cache_position, position_embeddings=position_embeddings, routing=canonical_routing, **layer_kwargs)
422
  if track_dual_tower_routing and use_cache and (past_key_values is not None):
423
+ past_key_values._lavida_dual_tower_routing = torch.cat((cached_routing, current_routing), dim=1)
424
+ past_key_values._lavida_dual_tower_has_generation = past_key_values._lavida_dual_tower_has_generation or canonical_routing is not None
425
  hidden_states = _routed_module(hidden_states, canonical_routing, self.norm, getattr(self, 'norm_gen', None))
426
  return BaseModelOutputWithPast(last_hidden_state=hidden_states, past_key_values=past_key_values if use_cache else None)
model-00001-of-00008.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:c4d490e010475dde3e2b57de64261a56d6bf8e9ca7d077754913fd628f7de5f6
3
  size 4974634832
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3b36eb1336d3c0b9dae232de88c8ceb8c442eba5df92019a3cc788663b90e5c6
3
  size 4974634832
model-00002-of-00008.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:933c4b2f44f9cd7be30ac7a40efbb3c58485aa9fbd6396245d8e2337faf5c5b3
3
  size 4999819672
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:20c0142736a64977044ad720cb7f575b82d7a31c907b6b51ecb7ffa1e9628e11
3
  size 4999819672
model-00003-of-00008.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:6893a316ec6655eb3f518be0f3ae3dfc80621922741df7d14f12b3d9fd123bf6
3
  size 4949454016
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c44643654fae7c8bb4440f91d6c8ff707411552e53a9b290f42b9fa881b38234
3
  size 4949454016
model-00004-of-00008.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:858fab295f100b897634b72824d01e01f368dc1d500de03916854d7b2769986c
3
  size 4999819744
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b90c3460f3cb1580b6ca663d70ec840a8fac2ae6ed043d9ee4450107fb744c56
3
  size 4999819744
model-00005-of-00008.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:0d31608093622df48c2284fa310170f9a1bfd127d7108bdacbc8106fcf296691
3
  size 4999819776
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ce7b416181248e1516e40805f9cfdb6e001c064308250fb92094563ce3d6c507
3
  size 4999819776
model-00006-of-00008.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4356b837d798b2d3250cd067c15b7f5d56fd19a8b8605bb107fb9d727c1726d0
3
  size 4999819272
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34ddb4a6a1f67153e9ed34e23a5542a23c9032f0380c77c2c3b31caf8af5db89
3
  size 4999819272
model-00007-of-00008.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:003f5a6c4c727e5f560e16ad91ee2264ed138c7190108dfc9b68d1b8c8445545
3
  size 4456023446
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:01bd1ff8c8a8a687033b6f6c0ac51c959235ec748547b0364a98508e2e444f12
3
  size 4456023446
model-00008-of-00008.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:299783fae2f540dfd723abbb09f8661b57122210d44b23a4c65f24b254542550
3
  size 2155913464
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e163845d238de6fc71a9990a2aaf0dea8514de1891a244d6fae9c96016bca92d
3
  size 2155913464
modeling_nlduni.py → modeling_lavida.py RENAMED
@@ -7,7 +7,7 @@ from transformers import AutoTokenizer
7
  from transformers.generation import GenerationMixin
8
  from transformers.modeling_outputs import CausalLMOutputWithPast
9
  from transformers.utils.hub import cached_file
10
- from .configuration_nlduni import NLDUniConfig
11
  from .core import Ministral3Model, Ministral3PreTrainedModel
12
  from .attention import MinistralFlexAttention
13
  from .bridge import PackedLinearImageCodec
@@ -20,9 +20,8 @@ from .chat_utils import generate_with_prefix_cache_block_diff
20
  from .sampling import text_to_image as sample_image
21
  from .image_utils import process_images, fix_one_prompt, tokenizer_image_token
22
  from .conversation import Conversation
23
- from .tree import BalancedSemanticTree, production_semantic_tree_contract
24
 
25
- class NLDUniBackbone(Ministral3Model):
26
  def __init__(self, config):
27
  super().__init__(config)
28
  self.vision_tower=RadioVisionTower()
@@ -66,12 +65,12 @@ class NLDUniBackbone(Ministral3Model):
66
  states=self.packed_image_codec.expand_fixed_grid(hidden_states.reshape(-1,(h//2)*(w//2),4096),gen_shape)
67
  return self.gen_predictor(states.flatten(0,1))
68
 
69
- class NLDUniForCausalLM(Ministral3PreTrainedModel, GenerationMixin):
70
- config_class=NLDUniConfig
71
  base_model_prefix=''
72
  def __init__(self, config):
73
  super().__init__(config)
74
- self.encoder=NLDUniBackbone(config)
75
  self.diffusion_head=nn.Linear(config.hidden_size,config.vocab_size,bias=False)
76
  self.mask_token_id=100
77
  self.vocab_size=config.vocab_size
@@ -84,8 +83,7 @@ class NLDUniForCausalLM(Ministral3PreTrainedModel, GenerationMixin):
84
  target=model[0] if isinstance(model,tuple) else model
85
  options={k:kwargs[k] for k in ('revision','cache_dir','local_files_only','token','subfolder') if k in kwargs}
86
  target._tokenizer=AutoTokenizer.from_pretrained(pretrained_model_name_or_path,**options)
87
- tree=cached_file(pretrained_model_name_or_path,'pca_tree.pt',**options)
88
- BalancedSemanticTree.from_artifact(production_semantic_tree_contract(tree))
89
  target.config.image_token_tree_path=tree
90
  target.eval()
91
  return model
@@ -96,8 +94,8 @@ class NLDUniForCausalLM(Ministral3PreTrainedModel, GenerationMixin):
96
  super().save_pretrained(destination, **kwargs)
97
  self.tokenizer.save_pretrained(destination)
98
  asset = Path(self.config.image_token_tree_path)
99
- if asset.resolve() != (destination / 'pca_tree.pt').resolve():
100
- shutil.copyfile(asset, destination / 'pca_tree.pt')
101
  @property
102
  def model(self):return self.encoder
103
  def get_model(self):return self.encoder
@@ -209,8 +207,7 @@ from .core import rotate_half as _bundle_core
209
 
210
  from .refinement import _validate_refinement_steps as _bundle_refinement
211
 
212
- from .conversation import Conversation
213
- from .tree import BalancedSemanticTree, production_semantic_tree_contract as _bundle_conversation
214
 
215
  from .constants import NemotronMinistralDLMConstant as _bundle_constants
216
 
 
7
  from transformers.generation import GenerationMixin
8
  from transformers.modeling_outputs import CausalLMOutputWithPast
9
  from transformers.utils.hub import cached_file
10
+ from .configuration_lavida import LaVidaConfig
11
  from .core import Ministral3Model, Ministral3PreTrainedModel
12
  from .attention import MinistralFlexAttention
13
  from .bridge import PackedLinearImageCodec
 
20
  from .sampling import text_to_image as sample_image
21
  from .image_utils import process_images, fix_one_prompt, tokenizer_image_token
22
  from .conversation import Conversation
 
23
 
24
+ class LaVidaBackbone(Ministral3Model):
25
  def __init__(self, config):
26
  super().__init__(config)
27
  self.vision_tower=RadioVisionTower()
 
65
  states=self.packed_image_codec.expand_fixed_grid(hidden_states.reshape(-1,(h//2)*(w//2),4096),gen_shape)
66
  return self.gen_predictor(states.flatten(0,1))
67
 
68
+ class LaVidaForCausalLM(Ministral3PreTrainedModel, GenerationMixin):
69
+ config_class=LaVidaConfig
70
  base_model_prefix=''
71
  def __init__(self, config):
72
  super().__init__(config)
73
+ self.encoder=LaVidaBackbone(config)
74
  self.diffusion_head=nn.Linear(config.hidden_size,config.vocab_size,bias=False)
75
  self.mask_token_id=100
76
  self.vocab_size=config.vocab_size
 
83
  target=model[0] if isinstance(model,tuple) else model
84
  options={k:kwargs[k] for k in ('revision','cache_dir','local_files_only','token','subfolder') if k in kwargs}
85
  target._tokenizer=AutoTokenizer.from_pretrained(pretrained_model_name_or_path,**options)
86
+ tree=cached_file(pretrained_model_name_or_path,'semantic_tree.pt',**options)
 
87
  target.config.image_token_tree_path=tree
88
  target.eval()
89
  return model
 
94
  super().save_pretrained(destination, **kwargs)
95
  self.tokenizer.save_pretrained(destination)
96
  asset = Path(self.config.image_token_tree_path)
97
+ if asset.resolve() != (destination / 'semantic_tree.pt').resolve():
98
+ shutil.copyfile(asset, destination / 'semantic_tree.pt')
99
  @property
100
  def model(self):return self.encoder
101
  def get_model(self):return self.encoder
 
207
 
208
  from .refinement import _validate_refinement_steps as _bundle_refinement
209
 
210
+ from .conversation import Conversation as _bundle_conversation
 
211
 
212
  from .constants import NemotronMinistralDLMConstant as _bundle_constants
213
 
release_manifest.json CHANGED
@@ -1,34 +1,32 @@
1
  {
2
- "revision": "generation-only-step-10000",
3
  "sha256": {
4
- ".gitattributes": "50360a3ded843d95a2667395b3131f6d499b905d941331a4e84e7f0351769023",
5
  ".gitignore": "e1900f365321556fa39bfe45527be4e15a1de7fe96b71ca8d294b690a1026a8d",
6
- "README.md": "50038fb0e318e290c123382d4f6284ce80699bd60d7fabf0ee6db27419e12b07",
7
- "attention.py": "5617bdd53aaa0d6f0e79745c5e811f36335a0c1f458218ab1fc02c4606d79f37",
8
  "bridge.py": "0e20f9ad1c81912489dd7c5063507b7fb72ead7d1895467442277e06ee3bc846",
9
  "chat_template.jinja": "b80135b85225bef1a5129eb2068d0d5df4975edf4ffb102a50de1fb069c9e78a",
10
- "chat_utils.py": "0683087dbadea1ce510d77816eed8ccfba998aa6c64833fd93c4e46c6edbc734",
11
- "config.json": "9dd7b2514b477712b9e023dec3f0d3749e8ccd9e27869cb4bf70fe9a8097fff0",
12
- "configuration_nlduni.py": "fa6d15657c9fadeb1f2bc142ea33b73c225374d5646565a077b43d6fd3e25f38",
13
  "constants.py": "1149095b05a6da911aae371d4899edcaba154352dc30efd2d5b72bb8767f785f",
14
  "conversation.py": "5e11082e6f5201978a0eb99523120d1272a6e0b311bfa75b273fa02d927d1002",
15
- "core.py": "4dad9ea004daa31236fb1eb628d2ad1b46d310914114bd93c401fd41161d5c66",
16
  "generation_config.json": "35e13707e4e588edaa4d7c12dff1d9ccd49efe0e07c99e3392c42b88f9398faa",
17
  "image_utils.py": "62755735051898eb909937712e0badcf6614d30405ea51d7d33522f484a319d1",
18
  "inference.py": "37e0b19b3d003621a620b226d6a9d39725e9450a7a6431d992ceea49cb2b92b2",
19
  "markers.py": "17f69056ff9db548dc223971021a91444ecaef3257df5b5f30fd2e5230bbadc7",
20
- "model-00001-of-00008.safetensors": "c4d490e010475dde3e2b57de64261a56d6bf8e9ca7d077754913fd628f7de5f6",
21
- "model-00002-of-00008.safetensors": "933c4b2f44f9cd7be30ac7a40efbb3c58485aa9fbd6396245d8e2337faf5c5b3",
22
- "model-00003-of-00008.safetensors": "6893a316ec6655eb3f518be0f3ae3dfc80621922741df7d14f12b3d9fd123bf6",
23
- "model-00004-of-00008.safetensors": "858fab295f100b897634b72824d01e01f368dc1d500de03916854d7b2769986c",
24
- "model-00005-of-00008.safetensors": "0d31608093622df48c2284fa310170f9a1bfd127d7108bdacbc8106fcf296691",
25
- "model-00006-of-00008.safetensors": "4356b837d798b2d3250cd067c15b7f5d56fd19a8b8605bb107fb9d727c1726d0",
26
- "model-00007-of-00008.safetensors": "003f5a6c4c727e5f560e16ad91ee2264ed138c7190108dfc9b68d1b8c8445545",
27
- "model-00008-of-00008.safetensors": "299783fae2f540dfd723abbb09f8661b57122210d44b23a4c65f24b254542550",
28
  "model.safetensors.index.json": "f2c7c2353c2a2eb70e7f80889c4fca85caceba217f1ccd9aa6647a7c644f6e30",
29
- "modeling_nlduni.py": "d7a04c330d1cd14fc638297a61a674cfdc666d8eb5ee24c41625ff1875040021",
30
  "padding.py": "53ba2cc8b37eec837b4fd0a3932a5f2d55051bbe5796c848921ce95171336dce",
31
- "pca_tree.pt": "4b7ee94fbb10fd4146a4ad167b595b037e3f591eaa12ecf3f0b411c82384a714",
32
  "pmj.py": "33920c0bb48ab99bafb3dde99f0e44eff7e6004596777d2e09ec4d07e039bfa3",
33
  "positions.py": "3e0ee23d4bd59059690bc9962fa0948c18f52af13c1295d5322309ba6472f0c4",
34
  "projector.py": "b402ae3a9ca1d7867c139e3180f905411d4932901cd7ce19910865db8709691f",
@@ -39,16 +37,16 @@
39
  "sampling.py": "6111a83d7d737eab9c702af281f209316e7458a785d0102c4f2bf3fd4e315491",
40
  "sbd_attention.py": "828f02ae59d430485507b00c76d0b85158dfa10dfea7888519ec80522798a134",
41
  "schedules.py": "243d3fa6924f11397df422c9e50dc37bd4e85d882c518c3a4a75545a3b1a367e",
 
42
  "special_tokens_map.json": "57cc1f9b3ea2a038d1107bdf4f4b3c45b5ed9ce175e7410d70070e07a3f35a76",
43
  "token_constants.py": "6515bb3f128730edcd02907cf49334ac9cae2ed373611b0a260b3bdf4ff678f1",
44
  "tokenizer.json": "f9ad3482369ba91711ff939f9eeb761d618b3157fcbfc0715f18e34b918eca97",
45
  "tokenizer_config.json": "5eb18e9f9e0653added53a9200a8d38fdbc1d0cdb4602f8e354f30391f8cb1f3",
46
- "tree.py": "b22d647f4d6def2a8df6f1b336db0b03a9cf0131dccf124f949cfa704e227c81",
47
- "tree_metadata.json": "16ccc59386d2d73094ba9b2562feff45b7a171f4f37053f9b5ed756d5c44e3d5",
48
  "utils.py": "6a0036a6451918de85fcc9cc3a82f5c195227bda5df58103156dd9941f6da0bc",
49
  "vision.py": "375c9cd952135701b71b35581a72c46cc58bb9701392343f9817f9cf1e68bb72",
50
  "vq.py": "3029623e15687b8fe95594b25410cfa2c0a82eebaa821b6ab380d1dcc394e537",
51
  "vq_model.py": "0f28d77789671b9c05402de7dca7bfccaa57264336ba778a76f3b59966baced7",
52
- "weights_manifest.json": "fe3af69d1ff222d3de89efd6305fcb3d396204b3c208491866d4da1137bea6f9"
53
  }
54
  }
 
1
  {
 
2
  "sha256": {
3
+ ".gitattributes": "137fabec805869007ee08b090309aa47a8ce228d8e5caba83bebc5081efe82b8",
4
  ".gitignore": "e1900f365321556fa39bfe45527be4e15a1de7fe96b71ca8d294b690a1026a8d",
5
+ "README.md": "801688e7986cc673c14c65cfd86db420f528a2d189c547230e902cbf7ce0c227",
6
+ "attention.py": "73ba82226b434fec56dcaeb2268c794cae9a62a4ed2769c65a390e16a28ebc77",
7
  "bridge.py": "0e20f9ad1c81912489dd7c5063507b7fb72ead7d1895467442277e06ee3bc846",
8
  "chat_template.jinja": "b80135b85225bef1a5129eb2068d0d5df4975edf4ffb102a50de1fb069c9e78a",
9
+ "chat_utils.py": "22f57a7003165392eab509763e1d5e069056fb1b732e409c6db8fbfc3c57735e",
10
+ "config.json": "9f57cd590b2debd189cc802ed5eba420a034b9708e4e275727f9001d04488f6b",
11
+ "configuration_lavida.py": "705696dc266816cb187cf8c495c18e3f9956ff95c292cfedb2258dfadd9a2f30",
12
  "constants.py": "1149095b05a6da911aae371d4899edcaba154352dc30efd2d5b72bb8767f785f",
13
  "conversation.py": "5e11082e6f5201978a0eb99523120d1272a6e0b311bfa75b273fa02d927d1002",
14
+ "core.py": "f95eee180ec24ca1e0ac2ac026b7f9a28ecc96fb756d5d257a44d37eda66759b",
15
  "generation_config.json": "35e13707e4e588edaa4d7c12dff1d9ccd49efe0e07c99e3392c42b88f9398faa",
16
  "image_utils.py": "62755735051898eb909937712e0badcf6614d30405ea51d7d33522f484a319d1",
17
  "inference.py": "37e0b19b3d003621a620b226d6a9d39725e9450a7a6431d992ceea49cb2b92b2",
18
  "markers.py": "17f69056ff9db548dc223971021a91444ecaef3257df5b5f30fd2e5230bbadc7",
19
+ "model-00001-of-00008.safetensors": "3b36eb1336d3c0b9dae232de88c8ceb8c442eba5df92019a3cc788663b90e5c6",
20
+ "model-00002-of-00008.safetensors": "20c0142736a64977044ad720cb7f575b82d7a31c907b6b51ecb7ffa1e9628e11",
21
+ "model-00003-of-00008.safetensors": "c44643654fae7c8bb4440f91d6c8ff707411552e53a9b290f42b9fa881b38234",
22
+ "model-00004-of-00008.safetensors": "b90c3460f3cb1580b6ca663d70ec840a8fac2ae6ed043d9ee4450107fb744c56",
23
+ "model-00005-of-00008.safetensors": "ce7b416181248e1516e40805f9cfdb6e001c064308250fb92094563ce3d6c507",
24
+ "model-00006-of-00008.safetensors": "34ddb4a6a1f67153e9ed34e23a5542a23c9032f0380c77c2c3b31caf8af5db89",
25
+ "model-00007-of-00008.safetensors": "01bd1ff8c8a8a687033b6f6c0ac51c959235ec748547b0364a98508e2e444f12",
26
+ "model-00008-of-00008.safetensors": "e163845d238de6fc71a9990a2aaf0dea8514de1891a244d6fae9c96016bca92d",
27
  "model.safetensors.index.json": "f2c7c2353c2a2eb70e7f80889c4fca85caceba217f1ccd9aa6647a7c644f6e30",
28
+ "modeling_lavida.py": "ebd4e6876a77bc4d117786da484df7bbcec924c1a708c77df3c92d86cea93d15",
29
  "padding.py": "53ba2cc8b37eec837b4fd0a3932a5f2d55051bbe5796c848921ce95171336dce",
 
30
  "pmj.py": "33920c0bb48ab99bafb3dde99f0e44eff7e6004596777d2e09ec4d07e039bfa3",
31
  "positions.py": "3e0ee23d4bd59059690bc9962fa0948c18f52af13c1295d5322309ba6472f0c4",
32
  "projector.py": "b402ae3a9ca1d7867c139e3180f905411d4932901cd7ce19910865db8709691f",
 
37
  "sampling.py": "6111a83d7d737eab9c702af281f209316e7458a785d0102c4f2bf3fd4e315491",
38
  "sbd_attention.py": "828f02ae59d430485507b00c76d0b85158dfa10dfea7888519ec80522798a134",
39
  "schedules.py": "243d3fa6924f11397df422c9e50dc37bd4e85d882c518c3a4a75545a3b1a367e",
40
+ "semantic_tree.pt": "371bde0b74b7fd9c0c4dc43e095f516c797707dbeaf9594206acfcff4e2b02fb",
41
  "special_tokens_map.json": "57cc1f9b3ea2a038d1107bdf4f4b3c45b5ed9ce175e7410d70070e07a3f35a76",
42
  "token_constants.py": "6515bb3f128730edcd02907cf49334ac9cae2ed373611b0a260b3bdf4ff678f1",
43
  "tokenizer.json": "f9ad3482369ba91711ff939f9eeb761d618b3157fcbfc0715f18e34b918eca97",
44
  "tokenizer_config.json": "5eb18e9f9e0653added53a9200a8d38fdbc1d0cdb4602f8e354f30391f8cb1f3",
45
+ "tree.py": "ecb3d15ece7a5a3a19c47d269f941656a33e0956603559d108736a89955d19cd",
 
46
  "utils.py": "6a0036a6451918de85fcc9cc3a82f5c195227bda5df58103156dd9941f6da0bc",
47
  "vision.py": "375c9cd952135701b71b35581a72c46cc58bb9701392343f9817f9cf1e68bb72",
48
  "vq.py": "3029623e15687b8fe95594b25410cfa2c0a82eebaa821b6ab380d1dcc394e537",
49
  "vq_model.py": "0f28d77789671b9c05402de7dca7bfccaa57264336ba778a76f3b59966baced7",
50
+ "weights_manifest.json": "76d0c7664ab34a29d59a0444e6c4160acc13cc02810a1429c0afe21438a10973"
51
  }
52
  }
pca_tree.pt → semantic_tree.pt RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4b7ee94fbb10fd4146a4ad167b595b037e3f591eaa12ecf3f0b411c82384a714
3
- size 1052237
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:371bde0b74b7fd9c0c4dc43e095f516c797707dbeaf9594206acfcff4e2b02fb
3
+ size 1050709
tree.py CHANGED
@@ -10,7 +10,7 @@ from pathlib import Path
10
  import torch
11
  import torch.nn.functional as F
12
  PINNED_ARTIFACT_VERSION = 1
13
- PINNED_ARTIFACT_ALGORITHM = 'recursive_centered_pca_rank_median_v1'
14
  PINNED_ARTIFACT_METRIC = 'normalized_squared_l2_tree_ultrametric'
15
  PINNED_PRODUCTION_VOCAB_SIZE = 131072
16
  PINNED_PRODUCTION_DEPTH = 17
@@ -80,7 +80,7 @@ class SemanticTreeArtifactContract:
80
  raise ValueError(f'Unsupported semantic-tree algorithm: {self.algorithm!r}')
81
 
82
  def production_semantic_tree_contract(path: str | os.PathLike[str]) -> SemanticTreeArtifactContract:
83
- return SemanticTreeArtifactContract(path=path, sha256='4b7ee94fbb10fd4146a4ad167b595b037e3f591eaa12ecf3f0b411c82384a714', algorithm=PINNED_ARTIFACT_ALGORITHM)
84
 
85
  def _sha256_file(path: Path) -> str:
86
  digest = hashlib.sha256()
@@ -143,7 +143,7 @@ class BalancedSemanticTree:
143
  if not isinstance(artifact, Mapping):
144
  raise TypeError('semantic-tree artifact must contain a mapping')
145
  algorithm = artifact.get('algorithm')
146
- allowed_algorithms = (contract.algorithm,) if contract.algorithm is not None else (PINNED_ARTIFACT_ALGORITHM,)
147
  if algorithm not in allowed_algorithms:
148
  raise ValueError(f'semantic-tree artifact algorithm mismatch: expected one of {allowed_algorithms!r}, got {algorithm!r}')
149
  pinned_values = {'version': PINNED_ARTIFACT_VERSION, 'metric': PINNED_ARTIFACT_METRIC, 'vocab_size': expected_vocab_size, 'depth': int(math.log2(expected_vocab_size)), 'radii_monotone': True}
 
10
  import torch
11
  import torch.nn.functional as F
12
  PINNED_ARTIFACT_VERSION = 1
13
+ PINNED_ARTIFACT_ALGORITHM = 'divisive_exact_balanced_binary_kmeans'
14
  PINNED_ARTIFACT_METRIC = 'normalized_squared_l2_tree_ultrametric'
15
  PINNED_PRODUCTION_VOCAB_SIZE = 131072
16
  PINNED_PRODUCTION_DEPTH = 17
 
80
  raise ValueError(f'Unsupported semantic-tree algorithm: {self.algorithm!r}')
81
 
82
  def production_semantic_tree_contract(path: str | os.PathLike[str]) -> SemanticTreeArtifactContract:
83
+ return SemanticTreeArtifactContract(path=path, algorithm=None)
84
 
85
  def _sha256_file(path: Path) -> str:
86
  digest = hashlib.sha256()
 
143
  if not isinstance(artifact, Mapping):
144
  raise TypeError('semantic-tree artifact must contain a mapping')
145
  algorithm = artifact.get('algorithm')
146
+ allowed_algorithms = (contract.algorithm,) if contract.algorithm is not None else PINNED_ARTIFACT_ALGORITHM
147
  if algorithm not in allowed_algorithms:
148
  raise ValueError(f'semantic-tree artifact algorithm mismatch: expected one of {allowed_algorithms!r}, got {algorithm!r}')
149
  pinned_values = {'version': PINNED_ARTIFACT_VERSION, 'metric': PINNED_ARTIFACT_METRIC, 'vocab_size': expected_vocab_size, 'depth': int(math.log2(expected_vocab_size)), 'radii_monotone': True}
tree_metadata.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "filename": "pca_tree.pt",
3
- "algorithm": "recursive_centered_pca_rank_median_v1",
4
- "sha256": "4b7ee94fbb10fd4146a4ad167b595b037e3f591eaa12ecf3f0b411c82384a714",
5
- "vocab_size": 131072,
6
- "depth": 17
7
- }
 
 
 
 
 
 
 
 
weights_manifest.json CHANGED
@@ -4,49 +4,49 @@
4
  "shards": [
5
  {
6
  "file": "model-00001-of-00008.safetensors",
7
- "sha256": "c4d490e010475dde3e2b57de64261a56d6bf8e9ca7d077754913fd628f7de5f6",
8
  "bytes": 4974634832,
9
  "tensors": 84
10
  },
11
  {
12
  "file": "model-00002-of-00008.safetensors",
13
- "sha256": "933c4b2f44f9cd7be30ac7a40efbb3c58485aa9fbd6396245d8e2337faf5c5b3",
14
  "bytes": 4999819672,
15
  "tensors": 106
16
  },
17
  {
18
  "file": "model-00003-of-00008.safetensors",
19
- "sha256": "6893a316ec6655eb3f518be0f3ae3dfc80621922741df7d14f12b3d9fd123bf6",
20
  "bytes": 4949454016,
21
  "tensors": 95
22
  },
23
  {
24
  "file": "model-00004-of-00008.safetensors",
25
- "sha256": "858fab295f100b897634b72824d01e01f368dc1d500de03916854d7b2769986c",
26
  "bytes": 4999819744,
27
  "tensors": 106
28
  },
29
  {
30
  "file": "model-00005-of-00008.safetensors",
31
- "sha256": "0d31608093622df48c2284fa310170f9a1bfd127d7108bdacbc8106fcf296691",
32
  "bytes": 4999819776,
33
  "tensors": 106
34
  },
35
  {
36
  "file": "model-00006-of-00008.safetensors",
37
- "sha256": "4356b837d798b2d3250cd067c15b7f5d56fd19a8b8605bb107fb9d727c1726d0",
38
  "bytes": 4999819272,
39
  "tensors": 102
40
  },
41
  {
42
  "file": "model-00007-of-00008.safetensors",
43
- "sha256": "003f5a6c4c727e5f560e16ad91ee2264ed138c7190108dfc9b68d1b8c8445545",
44
  "bytes": 4456023446,
45
  "tensors": 956
46
  },
47
  {
48
  "file": "model-00008-of-00008.safetensors",
49
- "sha256": "299783fae2f540dfd723abbb09f8661b57122210d44b23a4c65f24b254542550",
50
  "bytes": 2155913464,
51
  "tensors": 2
52
  }
 
4
  "shards": [
5
  {
6
  "file": "model-00001-of-00008.safetensors",
7
+ "sha256": "3b36eb1336d3c0b9dae232de88c8ceb8c442eba5df92019a3cc788663b90e5c6",
8
  "bytes": 4974634832,
9
  "tensors": 84
10
  },
11
  {
12
  "file": "model-00002-of-00008.safetensors",
13
+ "sha256": "20c0142736a64977044ad720cb7f575b82d7a31c907b6b51ecb7ffa1e9628e11",
14
  "bytes": 4999819672,
15
  "tensors": 106
16
  },
17
  {
18
  "file": "model-00003-of-00008.safetensors",
19
+ "sha256": "c44643654fae7c8bb4440f91d6c8ff707411552e53a9b290f42b9fa881b38234",
20
  "bytes": 4949454016,
21
  "tensors": 95
22
  },
23
  {
24
  "file": "model-00004-of-00008.safetensors",
25
+ "sha256": "b90c3460f3cb1580b6ca663d70ec840a8fac2ae6ed043d9ee4450107fb744c56",
26
  "bytes": 4999819744,
27
  "tensors": 106
28
  },
29
  {
30
  "file": "model-00005-of-00008.safetensors",
31
+ "sha256": "ce7b416181248e1516e40805f9cfdb6e001c064308250fb92094563ce3d6c507",
32
  "bytes": 4999819776,
33
  "tensors": 106
34
  },
35
  {
36
  "file": "model-00006-of-00008.safetensors",
37
+ "sha256": "34ddb4a6a1f67153e9ed34e23a5542a23c9032f0380c77c2c3b31caf8af5db89",
38
  "bytes": 4999819272,
39
  "tensors": 102
40
  },
41
  {
42
  "file": "model-00007-of-00008.safetensors",
43
+ "sha256": "01bd1ff8c8a8a687033b6f6c0ac51c959235ec748547b0364a98508e2e444f12",
44
  "bytes": 4456023446,
45
  "tensors": 956
46
  },
47
  {
48
  "file": "model-00008-of-00008.safetensors",
49
+ "sha256": "e163845d238de6fc71a9990a2aaf0dea8514de1891a244d6fae9c96016bca92d",
50
  "bytes": 2155913464,
51
  "tensors": 2
52
  }