Skip to content

feat(models): add Jina VLM (jina_vlm) VLM support #849

Closed

Description

@inureyes

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

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_vlm is 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 in src/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: use src/vision/molmo_vl.rs + src/vision/encoders/molmo.rs + src/models/molmo.rs as 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: 151940 placeholder 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_vlm summary if applicable.
  • _tests.rs unit tests.
  • docs/supported-models.md updated.
  • 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 and mlxcel-server. Follow docs/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

  1. added
    type:enhancement
    priority:medium
    status:ready
    area:models
    on Jul 21, 2026
  2. added
    status:in-progress
    status:review
    and removed
    status:ready
    status:in-progress
    on Aug 7, 2026
  3. added
    status:done
    and removed
    status:review
    on Aug 7, 2026
  4. added 2 commits that reference this issue on Aug 7, 2026
    6026fe8
    0f72757
  5. self-assigned this
    on Aug 31, 2026
  6. added 2 commits that reference this issue on Oct 27, 2026
    650768c
    c9f4217
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:modelspriority:mediumstatus:donetype:enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions