Repository navigation
Description
Summary
Jina VLM (jinaai/jina-vlm) is an autoregressive VLM: a SigLIP-so400m-class ViT tower supplies features from two intermediate layers, concatenated, spatially pooled 2x2 through a latent cross-attention block, projected by a SwiGLU projector into the text stream, and scattered into the embedding sequence at image-token positions. The text decoder is Qwen2-class (fused QKV, GQA, per-head Q / K RMSNorm, SwiGLU, RoPE theta 1e6, no biases), with image_token_index: 151940 (<|image|>) and a separate 128-entry extension embedding table for added special tokens.
Concretizes the jina_vlm triage entry in #548.
Upstream reference
- Directory: https://github.com/Blaizzy/mlx-vlm/tree/main/mlx_vlm/models/jina_vlm
- Vision tower + connector: https://github.com/Blaizzy/mlx-vlm/blob/main/mlx_vlm/models/jina_vlm/vision.py
- Language (Qwen2-class decoder): https://github.com/Blaizzy/mlx-vlm/blob/main/mlx_vlm/models/jina_vlm/language.py
- Top-level model: https://github.com/Blaizzy/mlx-vlm/blob/main/mlx_vlm/models/jina_vlm/jina_vlm.py
- Image processor: https://github.com/Blaizzy/mlx-vlm/blob/main/mlx_vlm/models/jina_vlm/image_processor.py
- Processor: https://github.com/Blaizzy/mlx-vlm/blob/main/mlx_vlm/models/jina_vlm/processing_jinavlm.py
- Config: https://github.com/Blaizzy/mlx-vlm/blob/main/mlx_vlm/models/jina_vlm/config.py
Resolved during implementation: the mlx-vlm port is a reimplementation and disagrees with the checkpoint's own vendor code (modeling_jvlm.py, blocks_jvlm.py, image_processing_jvlm.py, processing_jvlm.py) on the ViT layer indexing, the token-grid arithmetic, and the coverage-mask padding. The vendor code is authoritative and is what this implementation follows; see PR #1076.
Public checkpoint
Confirmed available on HuggingFace:
jinaai/jina-vlm(original)jinaai/jina-vlm-mlx(MLX, primary validation target)
Architecture notes (upstream + #548)
model_type: jvlm(top level and both sub-configs;jina_vlmis only the upstream mlx-vlm module name and is accepted as an alias).image_token_index: 151940(<|image|>).- Vision: SigLIP-so400m-class ViT (hidden 1152, 27 layers, patch 14, image 378, tanh-GELU, no CLS token); features taken from two intermediate ViT layers, concatenated, spatially pooled 2x2 via a latent cross-attention block, then a SwiGLU projector.
- Text: Qwen2-class decoder (fused QKV, GQA 16 query / 8 KV heads, head_dim 128, per-head Q / K RMSNorm, SwiGLU fused gate-up, RoPE theta 1e6, no biases, vocab 151936 plus a 128-entry extension embedding table for im_start / im_end / im_patch / im_col markers).
- Config schema is nested (block_config with attn / ffn / lnorm sub-blocks, vl_connector_config, keys like n_layers / n_kv_heads / vit_layers / pooling_h) rather than flat HF-style keys; confirmed against the real
config.json.
Implementation plan
- Text: reuse the Qwen2-style decoder in
src/models/qwen2.rs; the per-head Q / K norm structure is available insrc/models/qwen3.rs. Handle the fused QKV and the split base-plus-extension (128-entry) embedding at the loader boundary. - Vision tower: reuse
src/vision/encoders/siglip.rs. The connector recipe (multi-layer ViT feature concat + pooling cross-attention + SwiGLU projector) matches the Molmo connector already in-tree: usesrc/vision/molmo_vl.rs+src/vision/encoders/molmo.rs+src/models/molmo.rsas the closest template, plus qwen2_vl-style ViT helpers where patch logic overlaps. - Add
src/vision/jina_vlm.rs+src/loading/vlm_jina_vlm.rs. - Image-token merge: expand
image_token_index: 151940(<|image|>) placeholders and scatter projected features via the generic VisionModule merge path (src/vision/merge.rs/src/models/multimodal_placeholders.rs). - Loader: the nested (non-flat) config schema needs a dedicated parse; map block_config / vl_connector_config into mlxcel's config structs.
Touchpoints & acceptance criteria
- Text config (nested block_config) + vision config parse from
config.json. - SigLIP ViT tower + two-layer feature concat + 2x2 pooling cross-attention + SwiGLU projector.
- Image-token splice / merge:
image_token_index: 151940placeholder expansion + feature scatter. -
from_weights+sanitize: fused QKV, split base-plus-extension embedding, mixed precision (vision plain bf16 vs quantized text). - Arch-string arm in
src/models/detection.rs(routes on"jvlm", the string every released checkpoint declares;"jina_vlm"kept as an alias). - Registration in
src/model_metadata.rs(for_each_model_registration!). - TP / distributed arch-string +
generate_vlmsummary if applicable. -
_tests.rsunit tests. -
docs/supported-models.mdupdated. - Real-checkpoint validation:
./target/release/mlxcel generate -m models/mlx/jina-vlm-mlx --image <img> -p "Describe the image."produces correct grounded output on both the CLI andmlxcel-server. Followdocs/adding-models.md.
Effort
MEDIUM. Both halves reuse existing modules (SigLIP tower, Molmo-style connector, Qwen2 decoder); the specific work is the nested config parse and the split-embedding + fused-QKV loader.
Activity
fix(models): render typed image content in the Jina VLM template
feat(models): add Jina VLM (jvlm) vision-language support (#1076)
docs(reports): add technical reports for the #847/#848/#849 VLM port …
feat(models): add Jina VLM (jvlm) vision-language support (lablup#1076)
docs(reports): add technical reports for the lablup#847/lablup#848/la…