patrickamadeus commited on
Commit
9c06340
·
verified ·
1 Parent(s): 95bc996

Upload PrefixVLM checkpoint

Browse files
Files changed (3) hide show
  1. README.md +37 -0
  2. config.json +121 -0
  3. model.safetensors +3 -0
README.md ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: nanofresh
3
+ license: mit
4
+ pipeline_tag: image-text-to-text
5
+ tags:
6
+ - vision-language
7
+ - multimodal
8
+ - prefixvlm
9
+ - dual-tower
10
+ - kv-transport
11
+ ---
12
+
13
+ # PrefixVLM
14
+
15
+ **PrefixVLM** is a dual-language-model vision-language architecture with one-pass K/V transport:
16
+ - Left LM (`left_lm`) builds image-conditioned memory.
17
+ - Right LM (`right_lm`) performs continuation.
18
+ - Optional K/V bridge transforms left K/V before transport.
19
+ - `transport_mode` supports `image` (visual-token transport) and `full` (full-sequence transport).
20
+ - Optional gate (`use_gate=True`) applies feature-wise modulation: `sigmoid(Wx)` (no bias).
21
+
22
+ ## Load
23
+
24
+ ```python
25
+ from models.prefix_vlm import PrefixVLM
26
+ model = PrefixVLM.from_pretrained("patrickamadeus/dt-kvbridge-image-400")
27
+ ```
28
+
29
+ ## Build from backbone configs
30
+
31
+ ```python
32
+ from models.config import VLMConfig
33
+ from models.prefix_vlm import PrefixVLM
34
+
35
+ cfg = VLMConfig()
36
+ model = PrefixVLM(cfg=cfg, load_backbone=True, bridge_mode="linear", bridge_use_gate=True)
37
+ ```
config.json ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "vit_hidden_dim": 768,
3
+ "vit_inter_dim": 3072,
4
+ "vit_patch_size": 16,
5
+ "vit_img_size": 512,
6
+ "vit_n_heads": 12,
7
+ "vit_dropout": 0.0,
8
+ "vit_n_blocks": 12,
9
+ "vit_ln_eps": 1e-06,
10
+ "vit_cls_flag": false,
11
+ "vit_model_type": "google/siglip2-base-patch16-512",
12
+ "lm_hidden_dim": 576,
13
+ "lm_inter_dim": 1536,
14
+ "lm_rms_eps": 1e-05,
15
+ "lm_re_base": 100000,
16
+ "lm_max_position_embeddings": 8192,
17
+ "lm_base_vocab_size": 49152,
18
+ "extra_token_amount": 66,
19
+ "lm_vocab_size": 49218,
20
+ "lm_n_heads": 9,
21
+ "lm_n_kv_heads": 3,
22
+ "lm_dropout": 0.0,
23
+ "lm_n_blocks": 30,
24
+ "lm_attn_scaling": 1.0,
25
+ "lm_pad_aware_rope": false,
26
+ "lm_max_length": 2048,
27
+ "lm_use_tokens": false,
28
+ "lm_tie_weights": true,
29
+ "lm_model_type": "HuggingFaceTB/SmolLM2-135M-Instruct",
30
+ "lm_tokenizer": "HuggingFaceTB/SmolLM2-135M-Instruct",
31
+ "lm_chat_template": "{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
32
+ "mp_pixel_shuffle_factor": 4,
33
+ "mp_image_token_length": 64,
34
+ "max_img_size": 2048,
35
+ "resize_to_max_side_len": false,
36
+ "vlm_extra_tokens": {
37
+ "image_token": "<|image|>",
38
+ "global_image_token": "<|global_image|>",
39
+ "r1c1": "<row_1_col_1>",
40
+ "r1c2": "<row_1_col_2>",
41
+ "r1c3": "<row_1_col_3>",
42
+ "r1c4": "<row_1_col_4>",
43
+ "r1c5": "<row_1_col_5>",
44
+ "r1c6": "<row_1_col_6>",
45
+ "r1c7": "<row_1_col_7>",
46
+ "r1c8": "<row_1_col_8>",
47
+ "r2c1": "<row_2_col_1>",
48
+ "r2c2": "<row_2_col_2>",
49
+ "r2c3": "<row_2_col_3>",
50
+ "r2c4": "<row_2_col_4>",
51
+ "r2c5": "<row_2_col_5>",
52
+ "r2c6": "<row_2_col_6>",
53
+ "r2c7": "<row_2_col_7>",
54
+ "r2c8": "<row_2_col_8>",
55
+ "r3c1": "<row_3_col_1>",
56
+ "r3c2": "<row_3_col_2>",
57
+ "r3c3": "<row_3_col_3>",
58
+ "r3c4": "<row_3_col_4>",
59
+ "r3c5": "<row_3_col_5>",
60
+ "r3c6": "<row_3_col_6>",
61
+ "r3c7": "<row_3_col_7>",
62
+ "r3c8": "<row_3_col_8>",
63
+ "r4c1": "<row_4_col_1>",
64
+ "r4c2": "<row_4_col_2>",
65
+ "r4c3": "<row_4_col_3>",
66
+ "r4c4": "<row_4_col_4>",
67
+ "r4c5": "<row_4_col_5>",
68
+ "r4c6": "<row_4_col_6>",
69
+ "r4c7": "<row_4_col_7>",
70
+ "r4c8": "<row_4_col_8>",
71
+ "r5c1": "<row_5_col_1>",
72
+ "r5c2": "<row_5_col_2>",
73
+ "r5c3": "<row_5_col_3>",
74
+ "r5c4": "<row_5_col_4>",
75
+ "r5c5": "<row_5_col_5>",
76
+ "r5c6": "<row_5_col_6>",
77
+ "r5c7": "<row_5_col_7>",
78
+ "r5c8": "<row_5_col_8>",
79
+ "r6c1": "<row_6_col_1>",
80
+ "r6c2": "<row_6_col_2>",
81
+ "r6c3": "<row_6_col_3>",
82
+ "r6c4": "<row_6_col_4>",
83
+ "r6c5": "<row_6_col_5>",
84
+ "r6c6": "<row_6_col_6>",
85
+ "r6c7": "<row_6_col_7>",
86
+ "r6c8": "<row_6_col_8>",
87
+ "r7c1": "<row_7_col_1>",
88
+ "r7c2": "<row_7_col_2>",
89
+ "r7c3": "<row_7_col_3>",
90
+ "r7c4": "<row_7_col_4>",
91
+ "r7c5": "<row_7_col_5>",
92
+ "r7c6": "<row_7_col_6>",
93
+ "r7c7": "<row_7_col_7>",
94
+ "r7c8": "<row_7_col_8>",
95
+ "r8c1": "<row_8_col_1>",
96
+ "r8c2": "<row_8_col_2>",
97
+ "r8c3": "<row_8_col_3>",
98
+ "r8c4": "<row_8_col_4>",
99
+ "r8c5": "<row_8_col_5>",
100
+ "r8c6": "<row_8_col_6>",
101
+ "r8c7": "<row_8_col_7>",
102
+ "r8c8": "<row_8_col_8>"
103
+ },
104
+ "vlm_load_backbone_weights": true,
105
+ "vlm_checkpoint_path": "lusxvr/nanoVLM-230M-8k",
106
+ "hf_repo_name": "nanoVLM",
107
+ "left_mask_scope": "full",
108
+ "right_prefill_mode": "full",
109
+ "use_right_kv_cache_gates": false,
110
+ "right_kv_gate_normalize": false,
111
+ "right_kv_gate_init_offdiag": 0.001,
112
+ "use_kv_bridge": true,
113
+ "kv_bridge_type": "mlp",
114
+ "kv_bridge_mlp_ratio": 4.0,
115
+ "kv_bridge_use_rmsnorm": true,
116
+ "kv_bridge_residual": true,
117
+ "kv_bridge_init_mode": "default",
118
+ "kv_bridge_linear_depth": 1,
119
+ "kv_bridge_adapter_depth": 2,
120
+ "kv_bridge_adapter_expansion": 1.0
121
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bc32ed87e0e2bb78b869eeca63209bad57ba1b76caea51b83d2a6dee93853156
3
+ size 1450677688