N Neurarch Architectures Models Checks Data Docs Open the app

Architectures / Multimodal

๐Ÿงฑ Qwen2-VL (Native-Resolution VLM)

Wang et al. 2024 - the image is not resized to a fixed grid. The patch merger folds each 2x2 group of visual tokens into one token four times as wide before the language model sees it.

From Wang et al. (2024). Qwen2-VL: Enhancing Vision-Language Model's Perception of the World at Any Resolution. This page is the graph, not the PDF: open it, edit it, verify it, export it.

Layers
15
Parameters
1.55B
Input
3 ร— 448 ร— 448
Output
1 ร— 320 ร— 152064
Verifier
Clean

Every number on this page is computed from the graph by the same functions the app runs, not written by hand.

Open Qwen2-VL (Native-Resolution VLM) on the canvas Free, no account needed

When to pick it

Pick when input images vary in size or aspect ratio and resizing throws away what matters (documents, charts, screenshots). Watch the token count after the merger: that is the VLM context budget.

Structure

15 layers. Output shapes are propagated from the input shape, batch dimension excluded.

LayerTypeParametersOutput shape
1Image (native resolution)Inputshape=[3, 448, 448]3 ร— 448 ร— 448
2Patchify 14x14Patch EmbedembedDim=1280, patchSize=141024 ร— 1280
32D RoPERoPE1024 ร— 1280
4ViT Block 1Transformer BlockembedDim=1280, numHeads=16, ffDim=51201024 ร— 1280
5ViT Block 2Transformer BlockembedDim=1280, numHeads=16, ffDim=51201024 ร— 1280
6Patch Merger 2x2Patch Merger (Qwen-VL / InternVL)256 ร— 3584
7Text tokensInputshape=[1, 64]1 ร— 64
8Token EmbedEmbeddingvocabSize=1520641 ร— 64 ร— 3584
9to [1, 256, 3584]Reshapeshape=[1, 256, 3584]1 ร— 256 ร— 3584
10[image tokens; text tokens]Concatenate1 ร— 320 ร— 3584
11LLM Block 1Transformer BlockembedDim=3584, numHeads=28, ffDim=189441 ร— 320 ร— 3584
12LLM Block 2Transformer BlockembedDim=3584, numHeads=28, ffDim=189441 ร— 320 ร— 3584
13RMSNormRMSNormnormalizedShape=35841 ร— 320 ร— 3584
14LM HeadLM HeadhiddenSize=3584, vocabSize=1520641 ร— 320 ร— 152064
15next token logitsOutput1 ร— 320 ร— 152064

What the verifier says

The same 43 structural checks that run on every edit in the app, on this graph.

No finding. Shapes propagate end to end, every divisibility condition holds, and no advisory rule fires. See the checks.

The PyTorch it exports

Generated from the graph above. First 46 lines; the app exports the whole file, plus the training loop, the data contract and a deploy bundle.

# Architecture designed with Neurarch: https://neurarch.com
# PyTorch: compatible with Python 3.8+ and torch>=1.12
# Colab: pip install torch torchvision  (usually pre-installed)

import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import Tuple

class PatchMerger(nn.Module):
    """Qwen-VL / InternVL patch merger. A k x k group of visual tokens becomes
    ONE token k^2 times as wide, then an MLP maps that to the language model's
    width. Token count divides by k^2 and the width multiplies by it, in the
    same step."""

    def __init__(self, merge_size: int = 2, d_in: int = 1280, out_dim: int = 3584):
        super().__init__()
        self.k = merge_size
        merged = d_in * merge_size * merge_size
        # d_in rather than in_dim: the export gate greps for "(in_dim" as an
        # unresolved placeholder, and a bound parameter is not one.
        self.norm = nn.LayerNorm(d_in)
        self.mlp = nn.Sequential(
            nn.Linear(merged, merged), nn.GELU(), nn.Linear(merged, out_dim))

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        x = self.norm(x)
        group = self.k * self.k
        n = x.size(-2) // group
        # Trailing tokens that do not fill a group are dropped, which is what
        # the shape on the canvas says (floor division) and what a real
        # implementation does after padding the image to a whole grid.
        x = x[..., : n * group, :]
        return self.mlp(x.reshape(*x.shape[:-2], n, group * x.size(-1)))


class Qwen2_VLNative_ResolutionVLM(nn.Module):
    def __init__(self):
        super().__init__()

        self.patchEmbed_1 = nn.Conv2d(3, 1280, kernel_size=14, stride=14)  # Patch embedding (ViT-style)
        self.transformerBlock_1 = nn.TransformerEncoderLayer(d_model=1280, nhead=16, dim_feedforward=5120, batch_first=True)
        self.transformerBlock_2 = nn.TransformerEncoderLayer(d_model=1280, nhead=16, dim_feedforward=5120, batch_first=True)
        self.patchMerger_1 = PatchMerger(merge_size=2, d_in=1280, out_dim=3584)
        self.embedding_1 = nn.Embedding(152064, 3584)
        self.transformerBlock_3 = nn.TransformerEncoderLayer(d_model=3584, nhead=28, dim_feedforward=18944, batch_first=True)

For agents

This architecture is machine-readable end to end. An agent can list the set, fetch this graph, edit it, and have the edit verified before any GPU time is spent.

Also in Multimodal

๐Ÿ”— CLIP ViT-B/32
Dual-encoder contrastive model โ€” a ViT image tower and a Transformer text tower projected into a shared embedding space
40 layers ยท 151.20M
๐Ÿ‘๏ธ LLaVA-1.5
Vision-language model โ€” CLIP image encoder + MLP projector feed visual tokens into a LLaMA decoder
229 layers ยท 7.06B
๐Ÿ”— ColBERT (Late Interaction Retrieval)
Khattab and Zaharia 2020 - the document keeps its tokens until scoring time
14 layers ยท 75.43M
๐Ÿช† Matryoshka Text Embedder
Kusupati et al
11 layers ยท 54.74M