mlboydaisuke commited on
Commit
e5f9bbf
·
verified ·
1 Parent(s): 58fd8b3

MiniCPM-V-4.6 Core AI card

Browse files
Files changed (1) hide show
  1. README.md +74 -0
README.md ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: openbmb/MiniCPM-V-4.6
4
+ tags:
5
+ - core-ai
6
+ - coreai
7
+ - vision-language
8
+ - vlm
9
+ - on-device
10
+ - iphone
11
+ - apple
12
+ pipeline_tag: image-text-to-text
13
+ language:
14
+ - en
15
+ - zh
16
+ ---
17
+
18
+ # MiniCPM-V-4.6 — Core AI
19
+
20
+ **On-device vision-language model for iPhone / Apple Silicon.** A Core AI port of
21
+ [`openbmb/MiniCPM-V-4.6`](https://huggingface.co/openbmb/MiniCPM-V-4.6) — the strongest
22
+ sub-2B open VLM — running fully local on the GPU via the Core AI **pipelined engine**:
23
+ pick a photo, ask about it, stream the answer.
24
+
25
+ Verified on **iPhone 17 Pro**: image → grounded answer at **~51.5 tok/s** decode, all local.
26
+
27
+ ## Architecture
28
+
29
+ MiniCPM-V-4.6 (1.3B) = a **SigLIP So400m vision tower** (980px / patch 14 / 27 layers, with a
30
+ window-attention insert-merger @ layer 6 + a downsample-MLP merger → ÷16 = 64 visual tokens per
31
+ 448px slice) + a **Qwen3.5-hybrid text backbone** (`qwen3_5_text`: 0.8B, 24 layers, GatedDeltaNet
32
+ linear attention ×3 : full attention ×1, head_dim 256, vocab 248094, tied head). Connector =
33
+ 2×2 spatial merges + MLP, spliced into the text embeddings at `<image>` positions (`masked_scatter`).
34
+
35
+ ## Bundles
36
+
37
+ | path | what | dtype | size |
38
+ |---|---|---|---|
39
+ | `gpu-pipelined/minicpmv46_vlm_decode_int8lin/` | VLM text decoder (`input_ids → logits` + a static `image_embeds[64,1024]` buffer; in-graph gather `ids ≥ V ? image_embeds[ids-V] : embed[ids]`) | int8 (per-block-32 linear) | ~1.0 GB |
40
+ | `gpu-pipelined/minicpmv46_vision/` | fixed-grid SigLIP vision encoder (`pixel_values[1,3,448,448] → image_features[64,1024]`) | fp16 | ~1.0 GB |
41
+
42
+ The decoder is a complete qwen3.5-hybrid text LLM when `image_embeds` is zero — same bundle, no image needed.
43
+
44
+ ## How a VLM rides the text-only engine
45
+
46
+ The pipelined engine knows nothing about images. The whole multimodal state rides the
47
+ **static-input hook** (`image_embeds` buffer) + an id-space trick — the graph stays `ids + positions → logits`:
48
+
49
+ - The host runs the vision encoder **once per image** (resize 448, normalize `x/127.5−1`) and writes
50
+ `image_embeds [64,1024]` into one owned MTLBuffer the engine binds on every step.
51
+ - The prompt's `<|image_pad|>` ids are rewritten to **extension ids** `V + slot` (slot 0..63).
52
+ In-graph: `embed = ids < V ? table[ids] : image_embeds[ids − V]`.
53
+ - Positions are **plain 1D** (no M-RoPE / no rope-shift), the qwen3.5-hybrid KV + conv + recurrent
54
+ states are the engine's; nothing else changes.
55
+
56
+ Simpler than the [Qwen3-VL port](https://huggingface.co/mlboydaisuke/Qwen3-VL-2B-CoreAI) (no deepstack, no M-RoPE).
57
+
58
+ ## Measured (iPhone 17 Pro, iOS 27 beta, release)
59
+
60
+ - **decode ~51.5 tok/s** (text core 53.4), engine cold-spec ~3–5 s, ~1.5 GB resident (jetsam-safe).
61
+ - **Numerics**: fp32-torch parity bit-exact (vision cos 1.000000, full overlay logits cos 1.00004);
62
+ Core AI engine ≡ python ≡ HF (text 24/24; image path reproduces the HF description modulo one int8
63
+ near-tie token, then reconverges).
64
+ - Real-photo example (kakigōri): *"a bowl of shaved ice ... chunks of mango ... a dark blue saucer ...
65
+ a menu or a book, hinting at a café ... a wooden table"* — accurate, fully on-device.
66
+
67
+ ## Use it
68
+
69
+ `apps/CoreAIChat` and the standalone `MiniCPMVLM` app have a **MiniCPM-V 4.6 mode with a photo picker**:
70
+ pick an image, ask, stream. The vision tower runs once per image (~hundreds of ms); each turn re-prefills (S=1).
71
+
72
+ Conversion + gates: see [coreai-model-zoo / minicpm-v-4.6](https://github.com/john-rocky/coreai-model-zoo/blob/main/zoo/minicpm-v-4.6.md).
73
+
74
+ License: Apache-2.0 (inherited from `openbmb/MiniCPM-V-4.6`).