Modern multimodal artificial intelligence has converged on a unified computational paradigm: mapping continuous visual signals—spanning natural photographs, high-density PDF documents, scientific diagrams, user interfaces, and multi-hour video streams—directly into the token embedding space of autoregressive Large Language Models (LLMs). Achieving human-level visual perception and reasoning inside a Transformer (arXiv:2010.11929, arXiv:2409.12191, arXiv:2410.07073) requires solving four fundamental systems and mathematical bottlenecks that do not exist in text-only language modeling:
- Quadratic Self-Attention Complexity Over 2D Pixel Grids: Because self-attention scales quadratically ($O(N^2)$) with sequence length $N$, computing pairwise pixel-to-pixel attention across even a modest $224 \times 224$ RGB image ($50,176$ pixels) would require $2.52 \times 10^9$ attention weight evaluations per layer. The Vision Transformer (ViT) (
arXiv:2010.11929) resolves this by partitioning images into non-overlapping $P \times P$ patches (typically $14 \times 14$ or $16 \times 16$ pixels), projecting each patch into a $D$-dimensional vector token. - Global Softmax Normalization Bottlenecks in Contrastive Vision-Language Alignment: First-generation dual-encoder vision backbones such as CLIP (
arXiv:2103.00020) align image and text embeddings across $400\text{ million}$ web pairs using a symmetric multi-class $N$-pair InfoNCE cross-entropy objective. However, computing the denominator of a softmax loss over a global mini-batch of size $|B|$ requires all-to-all cross-device similarity gather collectives and $O(|B|^2)$ memory normalization. SigLIP (arXiv:2303.15343) and SigLIP 2 (arXiv:2502.14786) eliminate global batch normalization entirely by reformulating image-text alignment as independent pairwise logistic regression (negative log-sigmoid loss), enabling 84.5% ImageNet zero-shot accuracy in just two days on four TPUv4 chips and scaling up to $10\text{ billion}$ images and $12\text{ billion}$ alt-texts across 109 languages. - Cross-Modal Fusion and Visual Token Explosion: A high-resolution $4\text{K}$ document or multi-page chart generates thousands of patch tokens, rapidly exhausting LLM context windows and inflating prefill floating-point operations (FLOPs). Controlled design-space ablations in Idefics2 (
arXiv:2405.02246), LLaVA-1.5 (arXiv:2310.03744), InternVL 1.5 (arXiv:2404.16821), and PaliGemma (arXiv:2407.07726) reveal exactly when fully autoregressive sequence concatenation with 2-layer MLP connectors, Pixel Shuffle ($2 \times 2 \to 1$ spatial downsampling), or Perceiver Resamplers (729tokens compressed to64latents) outperforms interleaved gated cross-attention (Flamingo,arXiv:2204.14198) and Q-Former bottlenecks (BLIP-2,arXiv:2301.12597). - Fixed-Resolution Aspect-Ratio Distortion and 3D Spatio-Temporal Positioning: Traditional vision encoders trained at fixed square resolutions ($224 \times 224$ or $336 \times 336$) distort widescreen screenshots and blur fine-grained OCR text. Next-generation Vision-Language Models (VLMs) overcome fixed-grid limitations via three distinct architectural mechanisms: Dynamic High-Resolution Tiling up to $40$ tiles of $448 \times 448$ pixels ($4\text{K}$ resolution) in InternVL 1.5 (
arXiv:2404.16821); native variable-resolution 2D Rotary Position Embeddings (RoPE-2D) with[IMAGE BREAK]row delimiters and block-diagonal sequence packing in Pixtral 12B (arXiv:2410.07073); and 3D Multimodal Rotary Position Embedding (M-RoPE) decomposing rotary angles into explicit temporal, height, and width axes $(t, h, w)$ in Qwen2-VL (arXiv:2409.12191).
Vision Transformer Architecture Showing Image Decomposition into Fixed-Size Patches, Linear Patch Projection, Position Embeddings, and Multi-Head Self-Attention Encoder Blocks
This architectural deep dive examines the exact tensor transformations, contrastive and sigmoid loss formulations, cross-modal projection topologies, dynamic resolution tiling algorithms, 2D/3D rotary position matrices, and empirical benchmark results across primary peer-reviewed VLM systems in 2026.
Executive Summary: Verified Architectural & Empirical Benchmarks Across ViT, CLIP, SigLIP 2, LLaVA-1.5, InternVL 1.5, Qwen2-VL & Pixtral 12B
- Vision Transformer (ViT) Patch Tokenization vs. CNNs: In Dosovitskiy et al. (
arXiv:2010.11929), splitting an image $\mathbf{x} \in \mathbb{R}^{H \times W \times C}$ into $N = HW/P^2$ flattened patches of size $P \times P$ (such as $16 \times 16$ or $14 \times 14$ pixels) reduces self-attention complexity from $O((HW)^2)$ to $O((HW/P^2)^2)$. While lacking the translation equivariance and local 2D neighborhood inductive biases of Convolutional Neural Networks (CNNs), ViTs scale to 22 billion parameters (arXiv:2302.05442), 7B parameters on 1.7B images in DINOv3 (arXiv:2508.10104), and 113 billion parameters at 1.6 exaFLOPs on the Frontier supercomputer. - CLIP InfoNCE vs. SigLIP & SigLIP 2 Pairwise Sigmoid Pre-Training: OpenAI CLIP (
arXiv:2103.00020) trains dual image-text encoders over 400 million WebImageText pairs for 32 epochs (taking 12 days on 256 V100 GPUs for ViT-L/14), matching supervised ResNet-50 zero-shot on ImageNet without using any of its 1.28 million labeled training examples. SigLIP (arXiv:2303.15343) replaces global softmax normalization with a pairwise sigmoid loss, achieving 84.5% ImageNet zero-shot accuracy in 2 days on 4 TPUv4 chips with Locked-image Tuning (SigLiT) and finding an optimal global batch size of 32k. SigLIP 2 (arXiv:2502.14786) unifies sigmoid loss, LocCa captioning/grounding decoder pre-training, and SILC/TIPS local-to-global self-distillation + 50% masked patch prediction over 40B examples from WebLI (10B images, 12B alt-texts, 109 languages), boosting ADE20k dense segmentation mIoU from 40.8 to 45.4 and NYUv2 depth RMSE from 0.563 down to 0.466 at 384px on So400m/14. - Cross-Modal Connectors & Autoregressive vs. Cross-Attention Ablations: Controlled ablations in Idefics2 (
arXiv:2405.02246) prove that while cross-attention beats fully autoregressive concatenation when unimodal backbones are frozen (66.7 vs. 60.3 average 4-benchmark score), unfreezing backbones via LoRA reverses the ranking: fully autoregressive concatenation jumps +12.9 points (from 51.8/60.3 to 69.5), outperforming LoRA cross-attention (67.3) while using 10% fewer inference FLOPs. Adding a Perceiver Resampler compresses visual tokens per image by 11.4× (from 729 to 64 tokens) while improving average score to 71.7. Meanwhile, LLaVA-1.5 (arXiv:2310.03744) demonstrates that a 2-layer MLP connector withCLIP-ViT-L-336pxtrained on just 1.2M public samples (~1 day on a single 8-A100 node) achieves state-of-the-art across 11 benchmarks (1531.3 MME, 63.3 GQA, 36.1 MM-Vet). - Dynamic High-Resolution, RoPE-2D & 3D M-RoPE Scaling: InternVL 1.5 (
arXiv:2404.16821) pairs a continuous-pretrained InternViT-6B (45 layers at 448px) with dynamic aspect-ratio matching across up to 40 tiles of $448 \times 448$ pixels (4K resolution, 256 to 10,496 tokens via $4\times$ pixel shuffle). Pixtral 12B (arXiv:2410.07073) trains a 400M-parameter Pixtral-ViT from scratch with RoPE-2D,[IMAGE BREAK]row tokens, and 128K context window, outperforming Llama-3.2 90B despite being 7.5× smaller. Qwen2-VL-72B (arXiv:2409.12191) introduces Naive Dynamic Resolution ($2 \times 2$ MLP token compression reducing a $224 \times 224$ patch-14 image to 66 tokens) and 3D M-RoPE, achieving 77.8 on RealWorldQA (vs. 75.4 GPT-4o), 74.0 on MMVet (vs. 67.5 GPT-4V), 86.5 on MMBench-EN, 2482.7 on MME, and 70.5 on MathVista.
1. From Convolutional Inductive Biases to Vision Transformers (ViT): Patch Tokenization and Self-Attention Scaling
For nearly a decade between AlexNet (2012) and ResNet/EfficientNet (arXiv:1512.03385, arXiv:1905.11946), computer vision relied almost exclusively on Convolutional Neural Networks (CNNs). A 2D convolutional layer slides a compact kernel tensor $\mathbf{K} \in \mathbb{R}^{k_h \times k_w \times C_{\text{in}} \times C_{\text{out}}}$ (typically $3 \times 3$ to $7 \times 7$) across an input feature map, hard-coding two powerful geometric inductive biases directly into the network topology:
- Local 2D Neighborhood Structure (Spatial Locality): Pixels at adjacent spatial coordinates $(i, j)$ and $(i \pm 1, j \pm 1)$ are assumed to be highly correlated, so early layers aggregate strictly local receptive fields.
- Translation Equivariance (Weight Sharing): Because the exact same kernel weights $\mathbf{K}$ are applied at every spatial coordinate $(i, j)$ across the entire image plane, a shift in the input image produces an identical spatial shift in the output feature activation map.
Comparison of Information Flow and Receptive Field Dependencies Across Convolutional Neural Networks (CNNs), Recurrent Neural Networks (RNNs), and Global Self-Attention
While these hard-coded convolutional biases provide high sample efficiency on small-to-medium datasets, they also impose a structural ceiling at web scale: a convolutional layer cannot model long-range global dependencies between distant image regions until signals have propagated through many sequential downsampling stages. Conversely, applying standard Transformer self-attention directly to raw pixels is computationally intractable. An input image of resolution $H \times W$ contains $N_{\text{pix}} = H \cdot W$ pixels; at $224 \times 224$ resolution, $N_{\text{pix}} = 50,176$, and at $1024 \times 1024$ resolution, $N_{\text{pix}} = 1,048,576$. Because dense dot-product self-attention computes an $N \times N$ pairwise affinity matrix, pixel-level self-attention requires $O(H^2 W^2)$ memory and FLOPs.
1. Mathematical Formulation of ViT Patch Embeddings and 1D Positional Encoding
In "An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale" (Dosovitskiy et al., ICLR 2021, arXiv:2010.11929), the Vision Transformer (ViT) eliminates convolutional backbones altogether by treating an image as an ordered sequence of flattened 2D patches.
Given a 2D RGB input image tensor $\mathbf{x} \in \mathbb{R}^{H \times W \times C}$ (where $H$ is height, $W$ is width, and $C = 3$ color channels), ViT partitions $\mathbf{x}$ into a regular grid of non-overlapping square patches of resolution $(P, P)$ pixels. Flattening each patch across its spatial and channel dimensions yields a sequence of $N$ flattened patch vectors: $$\mathbf{x}_p \in \mathbb{R}^{N \times (P^2 \cdot C)}, \quad \text{where} \quad N = \frac{H \cdot W}{P^2}$$
For a standard $224 \times 224 \times 3$ image:
- With patch size $P = 16$ (ViT-B/16 or ViT-L/16), the image is divided into a $14 \times 14$ grid of patches, producing only $N = \frac{224 \times 224}{16^2} = 196$ tokens, where each raw patch vector has dimension $16^2 \times 3 = 768$. Compared to $50,176$ raw pixels, patching reduces sequence length $N$ by a factor of $256\times$ and reduces the quadratic attention matrix size $N^2$ by $65,536\times$ (from $2.52 \times 10^9$ entries down to $38,416$ entries)!
- With patch size $P = 14$ (ViT-L/14 or ViT-H/14), a $224 \times 224$ image yields a $16 \times 16$ grid of $N = 256$ tokens (each of raw dimension $14^2 \times 3 = 588$), while a $336 \times 336$ image (ViT-L/14@336px) yields a $24 \times 24$ grid of $N = 576$ tokens.
Because the Transformer encoder uses a constant latent hidden dimension $D$ across all layers, each flattened patch $\mathbf{x}p^i \in \mathbb{R}^{P^2 C}$ (for $i = 1, \dots, N$) is linearly projected into $\mathbb{R}^D$ via a trainable patch embedding matrix $\mathbf{E} \in \mathbb{R}^{(P^2 C) \times D}$ (which is mathematically equivalent to a 2D convolution with kernel size $P \times P$, stride $P$, and $D$ output channels). In the original BERT-style ViT design (arXiv:2010.11929), a learnable classification token $\mathbf{x}{\text{class}} = \mathbf{z}0^0 \in \mathbb{R}^D$ is prepended to the patch sequence, and learnable 1D positional embeddings $\mathbf{E}{\text{pos}} \in \mathbb{R}^{(N + 1) \times D}$ are added element-wise to preserve spatial order: $$\mathbf{z}0 = \left[\mathbf{x}{\text{class}};\; \mathbf{x}p^1 \mathbf{E};\; \mathbf{x}_p^2 \mathbf{E};\; \dots;\; \mathbf{x}_p^N \mathbf{E}\right] + \mathbf{E}{\text{pos}}, \qquad \mathbf{E} \in \mathbb{R}^{(P^2 C) \times D},\; \mathbf{E}_{\text{pos}} \in \mathbb{R}^{(N+1) \times D}$$
Remarkably, Dosovitskiy et al. (arXiv:2010.11929, Appendix D.4) systematically ablated four positional encoding strategies—no positional embedding, 1D learnable positional embedding, 2D-aware learnable positional embedding (separately embedding $x$ and $y$ grid coordinates each of size $D/2$), and relative positional embeddings—and discovered that while any positional embedding massively outperforms no positional embedding, 1D learnable embeddings perform slightly better than or equal to 2D-aware embeddings because at the patch level ($14 \times 14$ grid), the self-attention layers trivially learn to reconstruct 2D spatial distances from 1D raster-scan indices.
The initial sequence $\mathbf{z}0 \in \mathbb{R}^{(N+1) \times D}$ is then processed through $L$ pre-norm Transformer encoder blocks (arXiv:2010.11929, Equations 2–4), each consisting of Layer Normalization (LN), Multi-Head Self-Attention (MSA), residual connections, and a 2-layer Multilayer Perceptron (MLP) with a Gaussian Error Linear Unit (GELU) non-linearity: $$\mathbf{z}'\ell = \text{MSA}\left(\text{LN}(\mathbf{z}{\ell-1})\right) + \mathbf{z}{\ell-1}, \qquad \ell = 1, \dots, L$$ $$\mathbf{z}\ell = \text{MLP}\left(\text{LN}(\mathbf{z}'\ell)\right) + \mathbf{z}'_\ell, \qquad \ell = 1, \dots, L$$ $$\mathbf{y} = \text{LN}\left(\mathbf{z}_L^0\right)$$
DetailedVision Transformer (ViT) Schematic Showing Input Patch Splitting, Linear Projection, Pre-Norm Transformer Encoder Stack with Multi-Head Attention and MLP, and Classification Head
2. Pooling Evolution: [CLS] Token vs. Global Average Pooling (GAP) vs. Multi-Head Attention Pooling (MAP)
When a ViT is used as a standalone classifier or as the vision tower inside a contrastive dual-encoder, its sequence of output patch vectors $\mathbf{z}_L^1, \dots, \mathbf{z}_L^N \in \mathbb{R}^D$ must be aggregated into a single global vector representation. Three distinct pooling architectures govern modern ViT backbones:
- Special
[CLS]Token Pooling (Original ViT & CLIP): Emulating BERT, the output state $\mathbf{z}_L^0$ corresponding to the prepended<CLS>token is passed through LayerNorm and a linear projection. In OpenAI CLIP (arXiv:2103.00020),Rep<CLS>serves directly as the global image embedding. - Global Average Pooling (GAP): Discards the dummy
<CLS>token and computes the arithmetic mean across all $N$ patch output vectors: $\bar{\mathbf{z}}L = \frac{1}{N} \sum{i=1}^N \mathbf{z}_L^i$. - Multi-Head Attention Pooling (MAP Head — Scaling ViTs, SigLIP & SigLIP 2): Introduced in Set Transformers (
arXiv:1810.00825) and standardized for vision encoders in Scaling Vision Transformers (arXiv:2106.04560), SigLIP (arXiv:2303.15343), and SigLIP 2 (arXiv:2502.14786), MAP applies a single cross-attention block where the query $\mathbf{q} \in \mathbb{R}^{1 \times D}$ is a single trainable probe vector and the keys and values are the matrix of $N$ patch output embeddings $\mathbf{V} = [\mathbf{z}_L^1; \dots; \mathbf{z}_L^N] \in \mathbb{R}^{N \times D}$:
$$\text{MAP}(\mathbf{z}_L^{1:N}) = \text{MultiHeadAttention}\left(\mathbf{Q}=\mathbf{q},\; \mathbf{K}=\mathbf{V},\; \mathbf{V}=\mathbf{V}\right)$$ Empirical scaling studies (arXiv:2106.04560, arXiv:2302.05442) demonstrate that both GAP and MAP consistently outperform BERT-like [CLS] token pooling, and SigLIP/SigLIP 2 adopt a MAP head with no [CLS] token (N = 256 pure patch tokens for a $256 \times 256$ image with $P = 16$).
3. Self-Supervised ViT Frontiers: Masked Autoencoders (MAE) and DINOv2 / DINOv3 Gram Anchoring
Beyond supervised classification, Vision Transformers unlocked two major self-supervised visual representation paradigms documented in the literature:
- Masked Autoencoders (MAE, He et al.,
arXiv:2111.06377): Inspired by BERT masked language modeling, an asymmetric encoder-decoder ViT masks out 75% of input image patches ($224 \times 224$) and passes only the remaining 25% unmasked patches through the heavy ViT encoder, slashing encoder training compute and memory by over $3\times$. Learnable mask tokens are re-inserted after the encoder and processed by a lightweight ViT decoder trained via mean-squared error (MSE) to reconstruct the raw pixel values of the masked patches. - DINO, DINOv2 (
arXiv:2304.07193), and DINOv3 (arXiv:2508.10104, August 2025): DINO (self-distillation with no labels,arXiv:2104.14294) trains a student ViT $f_{\theta_t}$ on local and global crops $T'(x)$ to match the softmax distribution of an exponential moving average (EMA) teacher network $f_{\theta't}(T(x))$ where $\theta'_t = \alpha \theta_t + (1 - \alpha)\theta'{t-1}$, preventing representation collapse via teacher output sharpening (low softmax temperature) and centering (subtracting the running mean of teacher outputs). In August 2025, Meta AI Research scaled DINOv3 (arXiv:2508.10104) to 7 billion parameters trained on 1.7 billion images (diversity-sampled from a 17B-image pool) by introducing Axial RoPE with jittering and Gram anchoring—applying teacher-student self-distillation directly to the pairwise Gram matrix of patch feature vectors within an image so that dense feature maps (for semantic segmentation and depth estimation) never degrade during multi-billion-image training.
2. Contrastive Language-Image Pre-Training (CLIP): Symmetric InfoNCE Loss, Dual Encoders, and Zero-Shot Transfer
While supervised ViTs and self-supervised MAEs learn rich visual features, they remain closed-set models unless connected to natural language semantics. In "Learning Transferable Visual Models From Natural Language Supervision" (Radford et al., ICML 2021, arXiv:2103.00020), OpenAI introduced CLIP (Contrastive Language-Image Pre-Training), training an image encoder $f_{\text{img}}(\cdot)$ and a text encoder $f_{\text{txt}}(\cdot)$ jointly from scratch on 400 million (image, text) pairs (WebImageText / WIT, constructed from 500,000 text queries with up to 20,000 pairs per query, totaling a word count comparable to GPT-2's 40 GB WebText corpus).
1. Symmetric Multi-Class N-Pair InfoNCE Contrastive Objective
Given a mini-batch of $N$ aligned image-text pairs $\{(I_1, T_1), (I_2, T_2), \dots, (I_N, T_N)\}$ (with global batch size $N = 32,768$ in OpenAI CLIP), the image encoder and text encoder project their respective inputs into a shared $d_e$-dimensional multimodal embedding space and apply $\ell_2$ normalization: $$\mathbf{w}i = \frac{f{\text{img}}(I_i)}{\left\|f_{\text{img}}(I_i)\right\|2} \in \mathbb{R}^{d_e}, \qquad \mathbf{v}_j = \frac{f{\text{txt}}(T_j)}{\left\|f_{\text{txt}}(T_j)\right\|_2} \in \mathbb{R}^{d_e}$$
Across all $N \times N$ possible pairings in the mini-batch, there are $N$ positive (matching) pairs along the diagonal $(i = j)$ and $N^2 - N$ negative (non-matching) pairs off the diagonal $(i \neq j)$. For a batch size of $N = 32,768$, every training step evaluates $32,768$ positive pairs against $1,073,709,056$ (over 1.07 billion) negative pairs. CLIP minimizes the symmetric multi-class $N$-pair cross-entropy loss (InfoNCE) across both the image-to-text and text-to-image directions: $$\mathcal{L}{\text{CLIP}} = -\frac{1}{2N} \sum{i=1}^{N} \ln \frac{\exp\left(\mathbf{v}i \cdot \mathbf{w}_i / T\right)}{\sum{j=1}^{N} \exp\left(\mathbf{v}i \cdot \mathbf{w}_j / T\right)} - \frac{1}{2N} \sum{j=1}^{N} \ln \frac{\exp\left(\mathbf{v}j \cdot \mathbf{w}_j / T\right)}{\sum{i=1}^{N} \exp\left(\mathbf{v}_i \cdot \mathbf{w}_j / T\right)}$$ where $T > 0$ is a learnable softmax temperature scalar parameterized as $T = e^{-\tau}$ ($\tau \in \mathbb{R}$ initialized to $\ln(1/0.07)$ and clipped to prevent scaling logits above $100$).
2. Complete Architectural Registry of OpenAI CLIP Models
In the official CLIP release (arXiv:2103.00020, Tables 19 & 20; Wikipedia Contrastive Language-Image Pre-training registry), OpenAI trained 5 modified ResNet models (incorporating a 3-layer $3 \times 3$ stem, anti-aliased rect-2 blur pooling of stride 2, and a final Multi-Head Attention Pooling layer) and 4 Vision Transformer models (ViT-B/32, ViT-B/16, ViT-L/14, and ViT-L/14@336px fine-tuned for one additional FixRes epoch at $336 \times 336$ pixels). Every CLIP text encoder is a causally-masked decoder-only GPT-2 style Transformer with context length capped at 77 tokens (bracketed by [SOS] and [EOS], where the highest-layer activation at [EOS] is layer-normalized and linearly projected to the shared embedding dimension) and a lower-cased Byte-Pair Encoding (BPE) vocabulary of 49,408 (49,152 base merges). Input RGB images are normalized using the exact WebImageText channel means [0.48145466, 0.4578275, 0.40821073] and standard deviations [0.26862954, 0.26130258, 0.27577711].
| CLIP Model Variant | Input Resolution | Total Params (M) | Vision Params (M) | Text Params (M) | Shared Embedding Dim | Checkpoint Size (MB) |
|---|---|---|---|---|---|---|
RN50 |
224 × 224 |
102 M |
38.3 M |
63.1 M |
1024 |
244 MB |
RN101 |
224 × 224 |
120 M |
56.3 M |
63.1 M |
512 |
278 MB |
RN50x4 |
288 × 288 |
178 M |
87.1 M |
90.7 M |
640 |
402 MB |
RN50x16 |
384 × 384 |
291 M |
167.3 M |
123.0 M |
768 |
630 MB |
RN50x64 |
448 × 448 |
623 M |
420.4 M |
201.8 M |
1024 |
1260 MB |
ViT-B/32 |
224 × 224 |
151 M |
87.8 M |
63.1 M |
512 |
338 MB |
ViT-B/16 |
224 × 224 |
150 M |
86.2 M |
63.1 M |
512 |
335 MB |
ViT-L/14 |
224 × 224 |
428 M |
304.0 M |
123.0 M |
768 |
890 MB |
ViT-L/14@336px |
336 × 336 |
428 M |
304.3 M |
123.0 M |
768 |
891 MB |
While the largest ResNet model (RN50x64) required 18 days on 592 V100 GPUs for 32 epochs, the largest Vision Transformer (ViT-L/14) required 12 days on 256 V100 GPUs—and subsequent OpenCLIP (ViT-L/14 on LAION-2B) scaled training to 384 A100 GPUs for 160 epochs (32 billion samples seen).
3. Pairwise Sigmoid Loss (SigLIP & SigLIP 2): Decoupling Global Batch Normalization, LocCa Captioning, and Dense Self-Distillation
Despite CLIP's landmark success, its softmax-based InfoNCE objective suffers from two severe distributed-systems and optimization pathologies identified by Zhai, Mustafa, Kolesnikov, and Beyer in "Sigmoid Loss for Language Image Pre-Training" (ICCV 2023 Oral, arXiv:2303.15343):
- Global Normalization Communication Overhead: Evaluating the row-wise and column-wise softmax partition functions $\sum_{j=1}^{|B|} \exp(\mathbf{v}i \cdot \mathbf{w}_j / T)$ and $\sum{i=1}^{|B|} \exp(\mathbf{v}_i \cdot \mathbf{w}_j / T)$ requires gathering the entire $|B| \times |B|$ pairwise similarity matrix across all distributed accelerators, creating numerical instability and memory bottlenecks as $|B|$ scales.
- Asymmetric Positive-to-Negative Gradient Coupling at Small Batch Sizes: Under softmax cross-entropy, a single positive pair $(i, i)$ is coupled tightly with $|B| - 1$ negative pairs through the shared normalization denominator, degrading representation quality at smaller batch sizes.
Detailed Encoder Self-Attention Tensor Flow Diagram Illustrating Query, Key, and Value Projections, Scaled Dot-Product Similarity Matrix, and Weighted Value Aggregation
1. Pairwise Logistic Regression Formulation of SigLIP
SigLIP (arXiv:2303.15343) replaces the multi-class softmax cross-entropy with independent binary logistic regression across every image-text pair $(i, j)$ in the mini-batch $B$: $$\mathcal{L}{\text{SigLIP}} = \frac{1}{|B|} \sum{i=1}^{|B|} \sum_{j=1}^{|B|} \ln\left(1 + \exp\left(z_{i,j} \left(-e^{\tau} \mathbf{w}i \cdot \mathbf{v}_j + b\right)\right)\right)$$ Equivalently, using the Dirac delta $\delta{i,j} \in \{0, 1\}$ where $z_{i,j} = 2\delta_{i,j} - 1 \in \{-1, +1\}$ equals $+1$ for matching positive pairs $(i = j)$ and $-1$ for non-matching negative pairs $(i \neq j)$, and $f(x) = \ln(1 + e^{-x})$ denotes the negative log-sigmoid loss: $$\mathcal{L}{\text{SigLIP}} = \frac{1}{|B|} \sum{i,j \in 1:|B|} f\left((2\delta_{i,j} - 1)\left(e^{\tau} \mathbf{w}_i \cdot \mathbf{v}_j + b\right)\right)$$
Here, $\tau$ is a learnable log-temperature scalar and $b$ is a learnable scalar bias initialized to a large negative value (e.g., $b = -10$). Initializing $b = -10$ is critical: at step 0 of training, the $|B|^2 - |B|$ negative pairs vastly outnumber the $|B|$ positive pairs; a negative bias $b$ ensures that the initial predicted probability for random pairs starts near zero, preventing a massive initial gradient spike from the quadratic pool of negatives!
Because $\mathcal{L}_{\text{SigLIP}}$ is a pure sum of independent pairwise terms with zero global denominator, distributed training across $D$ devices can be executed using a chunked ring-pass algorithm: each device holds $|B|/D$ image embeddings and $|B|/D$ text embeddings, computes the local $(|B|/D) \times (|B|/D)$ loss chunk, and shifts text embeddings to its neighbor in a ring $D$ times, reducing peak memory per accelerator from $O(|B|^2)$ to $O((|B|/D)^2)$. Using this formulation:
- Combined with Locked-image Tuning (SigLiT), training on just 4 TPUv4 chips for 2 days achieves 84.5% ImageNet zero-shot accuracy (
arXiv:2303.15343). - Scaling the batch size all the way to 1,000,000 (one million) examples reveals that contrastive scaling gains saturate around a batch size of 32,768 (32k).
- Pairing SigLIP with the Shape-Optimized 400M Vision Transformer (
ViT-So400m) producesSigLIP-So400m/14, achieving 83.2% zero-shot ImageNet accuracy at $384 \times 384$ resolution—outperforming OpenAI'sCLIP-ViT-H(78.0% ImageNet) and matching the $10\times$ largerEVA-CLIP-5B(arXiv:2405.02246, Table 2).
2. SigLIP 2 (arXiv:2502.14786): Unifying Sigmoid Alignment, LocCa Parallel Decoder, and DINO/SILC/TIPS Dense Self-Distillation
While vanilla CLIP and SigLIP excel at global image-level tasks (zero-shot classification and retrieval), their un-pooled patch representations often underperform on dense spatial tasks (semantic segmentation, monocular depth estimation, surface normal estimation) and fine-grained localization (referring expression comprehension and OCR). In February 2025, Google DeepMind introduced SigLIP 2 (Tschannen et al., arXiv:2502.14786), unifying four synergistic objectives over 40 billion training examples drawn from the WebLI dataset (10 billion images and 12 billion alt-texts across 109 languages, mixed at 90% English / 10% non-English with a 256k-vocabulary multilingual Gemma tokenizer and text context length 64 on up to 2,048 TPUv5e chips at batch size 32k):
- Equal-Weight Sigmoid Loss + LocCa Decoder Pre-Training: Before the MAP attention-pooling head, an auxiliary Transformer language decoder (with half the layers of the text encoder plus cross-attention layers, discarded after pre-training) is attached to the un-pooled patch tokens ($N = 256$ tokens for $256 \times 256$ resolution at patch size $P = 16$). Following LocCa, each example runs three decoder forward passes: (a) image captioning (with 50% parallel prediction from mask tokens without causal masking), (b) referring expression prediction (predicting bounding box coordinates
[ymin, xmin, ymax, xmax]from region captions), and (c) grounded captioning (predicting region text given bounding box coordinates). - Local-to-Global Self-Distillation (SILC) + 50% Masked Patch Prediction (TIPS) in the Final 20% of Training: At 80% of training completion, an exponential moving average (EMA) teacher network is initialized from the student vision encoder. Two dense self-supervised losses are activated: * Local-to-Global Consistency Loss: The teacher processes 1 global view of the image while the student processes 8 partial local views, matching high-dimensional MLP representations. * Masked Patch Prediction Loss: 50% of embedded image patches in the global view fed to the student are replaced by learnable mask tokens, and the student is trained to predict the teacher's unmasked per-patch latent features at all masked locations.
- NaFlex (Native Aspect Ratio + FlexiViT Variable Sequence Length): Alongside fixed-resolution checkpoints at ViT-B (86M), ViT-L (303M), ViT-So400m (400M), and ViT-g (1B), SigLIP 2 trains a single NaFlex checkpoint supporting variable sequence lengths and preserving native image aspect ratios for OCR, UI screens (
Screen2Words), and scientific diagrams (SciCap,HierText). - Implicit Distillation via Active Data Curation for Compact Encoders: The smaller
ViT-B/16(86M) andViT-B/32models are fine-tuned with active sample selection scored by a high-capacity teacher.
| Frozen Vision Encoder | ViT Scale & Patch | Input Res. | PASCAL Seg (mIoU ↑) | ADE20k Seg (mIoU ↑) | NYUv2 Depth (RMSE ↓) | NAVI Depth (RMSE ↓) | NYUv2 Normals (Ang. RMSE ↓) |
|---|---|---|---|---|---|---|---|
| OpenAI CLIP | ViT-L/14 (304M) |
224 px |
74.5 |
39.0 |
0.553 |
0.073 |
24.3 |
| OpenCLIP | ViT-G/14 |
224 px |
71.4 |
39.3 |
0.541 |
— |
— |
| SigLIP v1 | So400m/14 (400M) |
224 px |
72.0 |
37.6 |
0.576 |
0.083 |
25.9 |
| SigLIP 2 | So400m/14 (400M) |
224 px |
77.1 |
41.8 |
0.493 |
0.067 |
24.9 |
| SigLIP v1 | So400m/14 (400M) |
384 px |
73.8 |
40.8 |
0.563 |
0.069 |
24.1 |
| SigLIP 2 | So400m/14 (400M) |
384 px |
78.1 |
45.4 |
0.466 |
0.064 |
23.0 |
As documented in arXiv:2502.14786 (Tables 2 and 3), adding the LocCa decoder and SILC/TIPS self-distillation transforms SigLIP 2's dense spatial features: at 384px, SigLIP 2 So400m/14 improves ADE20k semantic segmentation by +4.6 mIoU (45.4 vs. 40.8) and cuts NYUv2 monocular depth estimation RMSE by 17.2% (0.466 vs. 0.563), while in Cat-Seg open-vocabulary segmentation (Table 3), SigLIP 2 ViT-L/16 (38.8 mIoU on A-150, 62.4 on PC-59, 82.3 on VOC-21) outperforms even the much larger OpenCLIP ViT-G/14 (36.2 on A-150, 61.5 on PC-59, 81.4 on VOC-21).
4. Bridging the Modality Gap: Gated Cross-Attention (Flamingo) vs. Q-Former (BLIP-2) vs. Autoregressive MLP Connectors (LLaVA-1.5 & Idefics2)
Once a pretrained vision encoder extracts patch embeddings $\mathbf{Z}v \in \mathbb{R}^{N_v \times d_v}$ from an image, how should those visual representations be injected into a pretrained autoregressive Large Language Model of hidden dimension $d{\text{LLM}}$? Across the VLM literature, two competing architectural families emerged—and were decisively resolved through controlled experimental ablations in Idefics2 (arXiv:2405.02246) and LLaVA-1.5 (arXiv:2310.03744).
1. Paradigm A: Gated Cross-Attention (Flamingo) and Querying Transformers (BLIP-2 Q-Former)
When early VLMs attempted to fuse frozen unimodal vision encoders with frozen 70B+ parameter LLMs without disturbing the LLM's language generation weights, researchers designed specialized adapter bottlenecks:
- Flamingo (
arXiv:2204.14198, DeepMind, NeurIPS 2022): Freezes both a Normalizer-Free ResNet (NFNet-F6) vision encoder and a 70B Chinchilla language model (Flamingo-80B). Variable-length spatial-temporal visual feature maps are first compressed into a fixed budget of 64 visual latent tokens by a Perceiver Resampler (a Transformer cross-attention block where 64 learned latent query vectors attend to the flattened visual feature map). Those 64 visual latents are then injected between every frozen LLM layer via newly inserted Gated Cross-Attention Dense (GATED XATTN-DENSE) blocks gated by $\tanh(\alpha) \cdot \text{XAttn}(h_{\text{txt}}, z_{\text{vis}})$, where the learnable scalar parameter $\alpha$ is initialized to $0$ so that at step 0 of training, the multimodal network is mathematically identical to the original frozen LLM. - BLIP-2 (
arXiv:2301.12597, Li et al., ICML 2023): Bridges a frozen ViT (ViT-L/14orViT-g/14) and a frozen LLM (OPT or Flan-T5) using a lightweight Q-Former (Querying Transformer) initialized from BERT-base with 32 learnable query tokens ($\mathbf{Q} \in \mathbb{R}^{32 \times 768}$). Trained in two stages—first learning vision-language representation alignment (Image-Text Contrastive, Image-Text Matching, and Image-Grounded Text Generation losses) against the frozen ViT, and second projecting the 32 output queries into the frozen LLM—BLIP-2 outperforms Flamingo-80B by +8.7% on zero-shot VQAv2 while training 54× fewer parameters.
2. Paradigm B: Fully Autoregressive Concatenation via Linear/MLP Connectors (LLaVA & LLaVA-1.5)
In "Visual Instruction Tuning" (LLaVA, Liu et al., NeurIPS 2023 Oral, arXiv:2304.08485) and "Improved Baselines with Visual Instruction Tuning" (LLaVA-1.5, CVPR 2024 Highlight, arXiv:2310.03744), the authors stripped away cross-attention layers and Q-Formers entirely. Instead, visual patch tokens $\mathbf{Z}v \in \mathbb{R}^{N_v \times d_v}$ from the vision encoder (CLIP-ViT-L/14@336px, yielding $N_v = (336/14)^2 = 576$ tokens of dimension $d_v = 1024$) are mapped directly into the LLM's word embedding space $\mathbb{R}^{d{\text{LLM}}}$ via a lightweight projection connector $f_{\text{proj}}$, and concatenated directly with the text token embeddings as a single unified autoregressive sequence: $$\mathbf{H}{\text{input}} = \left[f{\text{proj}}(\mathbf{Z}v^1),\; \dots,\; f{\text{proj}}(\mathbf{Z}v^{N_v}),\; \mathbf{E}{\text{txt}}(w_1),\; \dots,\; \mathbf{E}{\text{txt}}(w_M)\right] \in \mathbb{R}^{(N_v + M) \times d{\text{LLM}}}$$
In LLaVA-1.5 (arXiv:2310.03744, Section 3.3 & Table 2), replacing LLaVA's single linear projection matrix $\mathbf{W} \in \mathbb{R}^{d_v \times d_{\text{LLM}}}$ with a 2-layer MLP connector with GELU activation: $$f_{\text{MLP}}(\mathbf{z}_v) = \mathbf{W}_2 \, \text{GELU}\left(\mathbf{W}_1 \mathbf{z}_v + \mathbf{b}_1\right) + \mathbf{b}_2$$ combined with $336 \times 336$ input resolution and explicit response-format prompting ("Answer the question using a single word or phrase."), produced dramatic gains while training on just 1.2M publicly available samples (~558K stage-1 alignment pairs + ~665K stage-2 instruction-tuning conversations) in ~1 day on a single 8×A100 node:
- Starting from base LLaVA-7B at
224px(809.6 MME, 25.5 MM-Vet), adding VQAv2 (+387.4 MME to1197.0), response-format prompts (1323.8 MME), and the 2-layer MLP connector (1355.2 MME,47.3 GQA,27.8 MM-Vet), then scaling resolution to336px(1450.0 MME,51.4 GQA), adding GQA/ShareGPT (1510.7 MME,62.0 GQA,31.1 MM-Vet), and scaling the LLM to 13B yielded 1531.3 on MME, 63.3 on GQA, and 36.1 on MM-Vet—outperforming InstructBLIP-14B (1212.8 MME,49.5 GQA,25.6 MM-Vet) and 80B IDEFICS across 11 benchmarks! - Furthermore, on VizWiz unanswerable visual questions, LLaVA-1.5's response-format prompt generalization boosted unanswerable detection accuracy by 6.1×, from 11.1% to 67.8% (
arXiv:2310.03744, Section 4.3).
3. The Definitive Controlled Ablation: Why Autoregressive + LoRA Beats Cross-Attention (Idefics2, arXiv:2405.02246)
Why did Flamingo and IDEFICS-1 favor cross-attention while LLaVA-1.5, Qwen2-VL, InternVL 1.5, PaliGemma, and Pixtral 12B all converged on the fully autoregressive concatenation architecture? In "What matters when building vision-language models?" (Laurençon, Tronchon, Cord, & Sanh, Hugging Face, arXiv:2405.02246, Section 3.2 & Table 3), the authors ran a strictly controlled ablation across both architectures under identical data and step budgets (evaluating 4-shot average performance across VQAv2, TextVQA, OKVQA, and COCO):
VLM Fusion Architecture (arXiv:2405.02246) |
Unimodal Backbone Training Mode | Trainable Params Share | Relative Inference FLOPs | 4-Benchmark Avg. Score (VQAv2/TextVQA/OKVQA/COCO) |
|---|---|---|---|---|
| Fully Autoregressive (No Perceiver Pooling) | Frozen Backbones | Connector Only | 1.00× (High seq. len) |
51.8 |
| Fully Autoregressive (With Perceiver Resampler) | Frozen Backbones | ~15% (0.7B trainable) |
1.00× (Baseline) |
60.3 |
| Interleaved Gated Cross-Attention (Flamingo-style) | Frozen Backbones | ~25% (2.0B trainable, +1.3B) |
1.10× (+10% FLOPs) |
66.7 (+6.4 vs. frozen FA) |
| Interleaved Gated Cross-Attention (Flamingo-style) | LoRA Adapted Backbones | Cross-Attn + LoRA | 1.10× (+10% FLOPs) |
67.3 (+0.6 gain from LoRA) |
| Fully Autoregressive (With Perceiver Resampler) | LoRA Adapted Backbones | Connector + Perceiver + LoRA | 1.00× (Zero LoRA merge cost) |
69.5 (+9.2 / +17.7 gain) |
Look closely at the insight revealed by Table 3 of arXiv:2405.02246:
- When the vision and language backbones are strictly frozen, cross-attention outperforms fully autoregressive concatenation (66.7 vs. 60.3) because interleaved cross-attention blocks introduce 1.3B additional trainable parameters (
2.0Btotal trainable vs.0.7B), giving the frozen system more capacity to adapt—at the cost of 10% higher inference FLOPs. - When backbones are naively unfrozen for full fine-tuning, the fully autoregressive architecture suffers severe training loss divergences that cannot be stabilized even by aggressively lowering the learning rate.
- When unimodal backbones are adapted via Low-Rank Adaptation (LoRA) while newly initialized connector/pooling layers are fully trained, training becomes completely stable—and the fully autoregressive architecture surges to 69.5 (a +9.2 point jump over frozen autoregressive with Perceiver and +17.7 points over frozen without Perceiver), surpassing LoRA cross-attention (67.3) while eliminating the 1.3B extra cross-attention parameters and merging LoRA weights into the base linear layers for zero inference latency overhead!
Furthermore, Idefics2 (arXiv:2405.02246, Tables 1 & 2) proved that unimodal backbone quality directly dictates VLM ceiling: upgrading the LLM backbone from LLaMA-1-7B (35.1% MMLU) to Mistral-7B (60.1% MMLU) boosted VLM score by +5.1 points (62.5 → 67.6), and upgrading the vision backbone from CLIP-ViT-H (224px, 78.0% ImageNet) to SigLIP-So400m (384px, 83.2% ImageNet) boosted VLM score by +3.3 points (57.4 → 60.7).
5. Overcoming Fixed-Resolution Blindness: Dynamic High-Resolution Tiling (InternVL 1.5), Pixel Shuffle, and Perceiver Resampling
A critical failure mode of first-generation VLMs is fixed-resolution downsampling blindness. If a user uploads a $1920 \times 1080$ desktop UI screenshot, a multi-column financial statement PDF, or an infusion-pump clinical chart, resizing that image into a single $224 \times 224$ or $336 \times 336$ square distorts the aspect ratio and collapses 8-point typography into unreadable sub-pixel blur. As demonstrated in the Idefics2 OCR ablation (arXiv:2405.02246, Table 7), simply doubling maximum image resolution from 384px to 768px (even before adding dedicated PDF OCR pre-training data) nearly doubles DocVQA accuracy from 22.6% to 42.9%, and adding PDF OCR data at 768px pushes it to 49.9% (and 74.0%+ after full instruction tuning).
Worked Numerical Example of 2D Spatial Convolution and Local Receptive Field Aggregation Over a Pixel Matrix
1. Grid Splitting + Global Context Thumbnail (LLaVA-1.5-HD)
To scale a fixed-resolution vision encoder (CLIP-ViT-L-336px or 224px) to higher resolutions without interpolating positional embeddings, LLaVA-1.5-HD (arXiv:2310.03744, Section 3.4 & Section 4.2) divides the high-resolution image into a grid of native-resolution patch crops, encodes each crop independently through the ViT, and concatenates the features of a downsampled global context thumbnail ($224^2$) alongside the high-resolution grid tokens. On LLaVA-1.5-7B (448 × 448), adding the global context thumbnail recovers the model from grid split-and-merge seam artifacts, improving GQA from 62.9 to 63.8 (+0.9), MME from 1425.8 to 1497.5 (+71.7), and MM-Vet from 31.9 to 35.1 (+3.2).
2. Dynamic Aspect-Ratio Matching Across Up to 40 Tiles (4K Resolution) and $4\times$ Pixel Shuffle (InternVL 1.5)
In "How Far Are We to GPT-4V? Closing the Gap to Commercial Multimodal Models with Open-Source Suites" (Chen et al., Shanghai AI Lab / OpenGVLab, arXiv:2404.16821), InternVL 1.5 pairs a continuously pretrained 6-billion-parameter vision foundation model (InternViT-6B-448px-V1.5, pruned from 48 layers to its top-performing 45 layers by discarding the final 3 layers) with InternLM2-20B using three core high-resolution engineering mechanisms:
- 35 Pre-Defined Aspect-Ratio Grids (1 to 12 Training Tiles, Zero-Shot Scaling to 40 Testing Tiles / 4K Resolution): Given an input image of dimensions $(W_{\text{in}}, H_{\text{in}})$, InternVL 1.5 evaluates all 35 valid grid combinations $\{(w_t, h_t) \mid 1 \le w_t \cdot h_t \le 12\}$ of $448 \times 448$ pixel tiles (such as
1:1,1:2,2:1,3:1, ...,2:6) and selects the grid ratio minimizing absolute aspect-ratio distortion $|W_{\text{in}}/H_{\text{in}} - w_t/h_t|$. If multiple grids match the aspect ratio (e.g.,1:1vs.2:2), it selects the highest resolution grid whose total area does not exceed $2 \times W_{\text{in}} H_{\text{in}}$, preventing artificial blow-up of low-resolution images. For example, an $800 \times 1300$ document is matched to a $2 \times 3$ grid and resized to $896 \times 1344$ ($6$ tiles of $448 \times 448$). During inference, the tile budget scales dynamically up to 40 tiles (4K resolution). - Global Thumbnail Concatenation: Alongside the $N_{\text{tiles}} \in [1, 40]$ high-resolution local tiles, InternVL 1.5 appends a single $448 \times 448$ downsampled thumbnail of the full image to anchor global scene layout.
- Pixel Shuffle $4\times$ Visual Token Compression: At patch size $P = 14$, a single $448 \times 448$ tile produces $(448/14)^2 = 32 \times 32 = 1,024$ patch tokens. Feeding 40 tiles plus 1 thumbnail directly into an LLM would inject $41 \times 1,024 = 41,984$ visual tokens for a single image! To make 4K document reading computationally tractable, InternVL 1.5 applies a pixel-shuffle spatial-to-channel operation that merges each $2 \times 2$ neighborhood of spatial tokens into a single token of $4\times$ channel depth before the MLP projector, cutting token count per $448 \times 448$ tile by $4\times$ (from 1,024 down to 256 visual tokens):
$$N_{\text{tokens, InternVL-1.5}} = 256 \times \left(N_{\text{tiles}} + \mathbb{I}{N{\text{tiles}} > 1}\right) \in \begin{cases} [256,\; 3,328] & \text{during training } (1 \le N_{\text{tiles}} \le 12) \\ [256,\; 10,496] & \text{during 4K inference } (1 \le N_{\text{tiles}} \le 40) \end{cases}$$
3. Perceiver Resampler Learned Pooling: 729 Tokens to 64 Latents (Idefics2)
While InternVL 1.5 and Qwen2-VL use $2 \times 2$ spatial token merging ($4\times$ reduction), Idefics2 (arXiv:2405.02246, Section 3.3 & Table 4) uses a 6-layer Perceiver Resampler with learned latent queries to pool the output of SigLIP-So400m. When an image is encoded at up to $378 \times 378$ (or tiled up to $980 \times 980$ in Stage 2 PDF training), a single image tile produces $27 \times 27 = 729$ SigLIP patch tokens. Passing those 729 tokens through a Perceiver Resampler with $N_{\text{latents}} = 64$ learned query vectors reduces the per-image token footprint by 11.39× (729 → 64 tokens) while actually increasing the 4-benchmark average score by +8.5 points (and outperforming 128 Perceiver tokens: 71.7 at 64 tokens vs. 71.2 at 128 tokens, arXiv:2405.02246, Table 4). Trained on 1.5 billion images and 225 billion text tokens across OBELICS interleaved web documents (350M images, 115B text tokens), LAION-COCO synthetic captions (+3.1 points over noisy alt-text: 52.9 vs. 49.8, Table 6), and 37M OCR-IDL/PDFA document pages, Idefics2-base (8B) with just 64 tokens/image outperforms MM1-7B (144 tokens/image) and Flamingo-9B across VQAv2 (70.3 vs. 63.6 / 58.0), TextVQA (57.9 vs. 46.3 / 33.6), and OKVQA (54.6 vs. 51.4 / 50.0) (arXiv:2405.02246, Table 8).
6. Native Variable-Resolution Vision Encoders: 2D Rotary Position Embeddings (RoPE-2D in Pixtral 12B) and NaFlex Sequence Packing
Although dynamic tiling (LLaVA-1.5-HD, InternVL 1.5, Idefics2-chatty) unlocks 4K document reading on top of fixed-resolution ViTs, slicing an image into independent $448 \times 448$ square crops introduces artificial boundary seams across continuous lines of text and forces padding when aspect ratios do not evenly divide the tile grid.
To eliminate tiling altogether, Mistral AI's Pixtral 12B (arXiv:2410.07073) and Alibaba's Qwen2-VL (arXiv:2409.12191) redesigned the Vision Transformer itself to ingest images at their exact native resolution and aspect ratio without cropping or fixed grids.
1. Pixtral-ViT (400M) and the Mathematical Formulation of RoPE-2D (arXiv:2410.07073)
In Pixtral 12B (arXiv:2410.07073, Table 1 & Section 2.2), Mistral pairs the 12-billion-parameter Mistral Nemo 12B multimodal decoder (dim = 5120, 40 layers, 32 query heads, 8 KV heads via GQA, head_dim = 128, hidden_dim = 14336, 131,072 context length, 131,072 vocabulary size) with a custom 400-million-parameter vision encoder trained from scratch—Pixtral-ViT (dim = 1024, 24 layers, 16 query/KV heads, head_dim = 64, hidden_dim = 4096, patch_size = 16, connected via a 2-layer GELU MLP).
Pixtral-ViT introduces four architectural modifications over standard CLIP/SigLIP ViTs:
[IMAGE BREAK]and[IMAGE END]Structural Tokens: Two images of dimensions $1024 \times 512$ and $512 \times 1024$ contain the exact same number of $16 \times 16$ patches ($64 \times 32 = 32 \times 64 = 2,048$ patches). To allow the causal multimodal decoder to unambiguously distinguish row boundaries and aspect ratios after flattening, Pixtral inserts a learned[IMAGE BREAK]token at the end of every patch row and an[IMAGE END]token at the end of the final row.- SwiGLU Gated Feed-Forward Network: Replaces the standard 2-layer ViT MLP with a gated hidden layer.
- Block-Diagonal Attention Masking for Sequence Packing: To batch variable-resolution images without spatial padding waste, multiple images of different dimensions are flattened along the sequence dimension and concatenated into a single packed sequence, isolated by a block-diagonal self-attention mask so zero attention leaks across distinct images.
- 2D Rotary Position Embeddings (RoPE-2D): Replaces learned 1D absolute positional embeddings (which degrade when bicubically interpolated to unseen aspect ratios) with relative 2D rotary embeddings inside every ViT self-attention layer.
Let $\mathbf{x}^{(i,j)} \in \mathbb{R}^d$ denote a $d$-dimensional query or key head vector ($d = 64$ in Pixtral-ViT) for the image patch located at row index $i$ (height coordinate) and column index $j$ (width coordinate). As defined in Equation 1 of arXiv:2410.07073, the RoPE-2D transformation splits the $d$ feature dimensions into alternating $2 \times 2$ rotation planes—applying row-coordinate rotations $\cos(i\theta_m), \sin(i\theta_m)$ to odd 2D sub-blocks and column-coordinate rotations $\cos(j\theta_m), \sin(j\theta_m)$ to even 2D sub-blocks: $$\text{RoPE-2D}\left(\mathbf{x}^{(i,j)}, \Theta\right) = \mathbf{M}{\Theta}^{(i,j)} \mathbf{x}^{(i,j)}$$ where the block-diagonal orthogonal rotation matrix $\mathbf{M}{\Theta}^{(i,j)} \in \mathbb{R}^{d \times d}$ is given by: $$\mathbf{M}{\Theta}^{(i,j)} = \begin{pmatrix} \cos i\theta_1 & -\sin i\theta_1 & 0 & 0 & \cdots & 0 & 0 \\ \sin i\theta_1 & \cos i\theta_1 & 0 & 0 & \cdots & 0 & 0 \\ 0 & 0 & \cos j\theta_2 & -\sin j\theta_2 & \cdots & 0 & 0 \\ 0 & 0 & \sin j\theta_2 & \cos j\theta_2 & \cdots & 0 & 0 \\ \vdots & \vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\ 0 & 0 & 0 & 0 & \cdots & \cos j\theta{d/2} & -\sin j\theta_{d/2} \\ 0 & 0 & 0 & 0 & \cdots & \sin j\theta_{d/2} & \cos j\theta_{d/2} \end{pmatrix}$$
Crucially, because orthogonal rotation matrices satisfy $\left(\mathbf{M}{\Theta}^{(i_1, j_1)}\right)^\top \mathbf{M}{\Theta}^{(i_2, j_2)} = \mathbf{M}_{\Theta}^{(i_2 - i_1,\; j_2 - j_1)}$, the self-attention inner product between query patch $(i_1, j_1)$ and key patch $(i_2, j_2)$ depends strictly on their relative 2D spatial displacement $(\Delta i, \Delta j) = (i_2 - i_1, j_2 - j_1)$ rather than their absolute coordinates! In controlled ablations (arXiv:2410.07073, Section 4.4 & Figure 6) comparing Pixtral-ViT against a CLIPA baseline evaluated both at 224 × 224 and across $25$ tiled crops (1120 × 1120), native RoPE-2D in Pixtral-ViT substantially outperforms tiled CLIPA on chart and document understanding while maintaining full parity on natural images, enabling Pixtral 12B to outperform Llama-3.2 11B, Qwen2-VL 7B, and even the 7.5× larger Llama-3.2 90B across MMMU, MathVista, ChartQA, DocVQA, and MM-MT-Bench without degrading text-only MATH or HumanEval performance.
7. Unified Image-Video Spatio-Temporal Modeling: 3D Tubelet Convolutions and Multimodal Rotary Position Embedding (M-RoPE in Qwen2-VL)
While RoPE-2D resolves 2D spatial resolution invariance for static images, real-world multimodal agents must also process continuous video streams—where visual tokens occupy a 3D spatio-temporal lattice $(t, h, w)$ interleaved with 1D textual dialogue tokens.
In "Qwen2-VL: Enhancing Vision-Language Model's Perception of the World at Any Resolution" (Wang et al., Alibaba Qwen Team, arXiv:2409.12191), the Qwen2-VL series (2B, 7B, and 72B) unifies static image perception, multi-page document OCR, and hour-long video comprehension through a 675-million-parameter dynamic-resolution ViT paired with two foundational innovations: 3D Tubelet Patch Compression and Multimodal Rotary Position Embedding (M-RoPE).
Full Transformer Architecture Diagram Showing Positional Encoding Addition, Multi-Head Attention Blocks, Add & Norm Residuals, and Feed-Forward Sub-Layers
1. Naive Dynamic Resolution, 3D Tubelet Convolutions, and $2 \times 2$ MLP Token Merging
In Qwen2-VL (arXiv:2409.12191, Section 2.1):
- Video Sampling & 3D Tubelet Embedding: Video streams are sampled at 2 frames per second (2 FPS). Instead of applying a 2D patch projection independently to each frame, Qwen2-VL applies a 3D convolution with temporal depth $2$ and spatial patch size $14 \times 14$ (
tubelet size = 2 × 14 × 14), fusing pairs of consecutive video frames into 3D spatio-temporal tubelets and halving the temporal sequence length before the ViT encoder even runs! For architectural consistency, every single static image is treated as a 2-frame identical video pair during 3D tubelet embedding. For long videos (up to 1+ hour), per-frame resolution is dynamically scaled so that the total visual token budget per video never exceeds 16,384 tokens. - ViT 2D-RoPE + Adjacent $2 \times 2$ MLP Compression: Inside the 675M ViT, absolute positional embeddings are removed in favor of 2D-RoPE. Immediately after the ViT outputs patch features on an $(H/14) \times (W/14)$ grid, a lightweight MLP layer compresses every adjacent $2 \times 2$ block of spatial ViT tokens into a single LLM token, bracketed by
<|vision_start|>and<|vision_end|>special tokens. - Exact Token Count Arithmetic: Because the ViT uses
patch_size = 14and the post-ViT MLP compresses $2 \times 2$ tokens into $1$ (an effective spatial stride of $28 \times 28$ pixels per LLM visual token), a standard $224 \times 224$ image produces:
$$N_{\text{ViT}}(224 \times 224) = \frac{224}{14} \times \frac{224}{14} = 16 \times 16 = 256\;\text{ViT tokens} \xrightarrow{2\times 2\text{ MLP}} \frac{16}{2} \times \frac{16}{2} = 64\;\text{visual tokens}$$ Adding the two delimiter tokens <|vision_start|> and <|vision_end|> yields exactly 66 tokens entering the Qwen2 LLM (arXiv:2409.12191, Section 2.1)!
2. Decomposing Rotary Embeddings into 3D $(t, h, w)$ Axes: M-RoPE
In standard autoregressive LLMs, 1D-RoPE assigns a single scalar position index $p \in \mathbb{N}$ to every token, rotating all frequency channels $\theta_k$ by $p \theta_k$. When hundreds of visual tokens from a 2D image or 3D video are flattened into a 1D sequence, 1D-RoPE destroys vertical adjacency relationships and inflates position IDs $p$ by thousands per frame, hurting length extrapolation.
M-RoPE (arXiv:2409.12191, Figure 3 & Section 2.1) partitions the channel dimensions of the LLM's query and key rotary vectors into three disjoint frequency sub-vectors: $$\mathbf{p}_n = \left(p_n^{(\text{temporal})},\; p_n^{(\text{height})},\; p_n^{(\text{width})}\right) = (t_n, h_n, w_n)$$
- For Text Tokens: All three components receive the exact same scalar position ID $(t_n, h_n, w_n) = (p, p, p)$, making M-RoPE 100% mathematically identical to standard 1D-RoPE on text!
- For Static Image Tokens: Every visual token across an $H' \times W'$ compressed patch grid shares a constant temporal ID $t_n = t_0$, while $h_n \in \{t_0, \dots, t_0 + H' - 1\}$ and $w_n \in \{t_0, \dots, t_0 + W' - 1\}$ encode the token's 2D row and column coordinates.
- For Video Tokens: Across $T'$ tubelet frames of resolution $H' \times W'$, the temporal ID $t_n$ increments by $+1$ for each successive frame ($t_n = t_0 + f$ for frame $f \in \{0, \dots, T'-1\}$), while $(h_n, w_n)$ encode the 2D spatial grid within each frame.
- Cross-Modal Position Chaining & Extrapolation Compression: Whenever a new modality segment begins (e.g., text following an image or video), its starting position ID is initialized to $\max(t, h, w)_{\text{prev}} + 1$. Consequently, an $H' \times W' = 16 \times 16$ image (256 compressed tokens) advances the LLM's maximum position ID by only $\max(16, 16) = 16$ instead of $256$—compressing positional index growth by $16\times$ and enabling zero-shot length extrapolation to massive multi-image and long-video contexts!
| Multimodal Benchmark / Capability | Evaluation Domain | Qwen2-VL-72B Score (arXiv:2409.12191) |
Comparison Baseline / Prior SoTA |
|---|---|---|---|
RealWorldQA |
Physical environment & spatial comprehension | 77.8 |
75.4 (GPT-4o) / 72.2 (Prior SoTA) |
MMVet |
16 complex integrated vision-language tasks | 74.0 |
67.5 (GPT-4V) / 36.1 (LLaVA-1.5-13B) |
MMT-Bench |
32 core meta-tasks & 162 multimodal subtasks | 71.7 |
63.4 (Prior SoTA) |
MMStar |
Visually indispensable multimodal samples | 68.3 |
67.1 (Prior SoTA) |
MMBench (EN / CN) |
20 fine-grained perception & reasoning dimensions | 86.5 (EN) / 86.6 (CN) |
Matches EN SoTA / New CN SoTA |
MME (Cumulative) |
14 perception & high-level cognition subtasks | 2482.7 |
2414.7 (Prior SoTA) / 1531.3 (LLaVA-1.5-13B) |
MathVista / MathVision |
6,141 visual math tasks / 3,040 competition problems | 70.5 / 25.9 |
New open-source LVLM benchmark records |
RefCOCO (val / test-A / test-B) |
Referring expression bounding-box localization | 93.2 / 95.3 / 90.7 |
90.6 / 93.2 / 88.2 (Specialist G-DINO-L) |
Even at smaller scales, Qwen2-VL-7B achieves 91.7 / 93.6 / 87.3 on RefCOCO (val / test-A / test-B), and Qwen2-VL-2B achieves 87.6 / 90.6 / 82.3 (arXiv:2409.12191, Table 6), proving that Naive Dynamic Resolution and M-RoPE allow a generalist VLM to beat dedicated bounding-box detection specialists like G-DINO-L (90.6 / 93.2 / 88.2) and ONE-PEACE (92.6 / 94.2 / 89.3).
8. Compute-Optimal Multimodal Pre-Training, Prefix-LM Attention Masking (PaliGemma), and Visual Token Compression Physics
When designing a compact, high-throughput Vision-Language Model for edge deployment or task-specific transfer (such as sub-3B or 7B models running on local GPUs or Apple Silicon Unified Memory), three final architectural design principles determine accuracy per FLOP.
1. Prefix-LM Bidirectional Image-Prompt Attention vs. Pure Causal Masking (PaliGemma, arXiv:2407.07726)
In most decoder-only VLMs (such as LLaVA-1.5 and Pixtral 12B), the multimodal decoder applies a strictly causal lower-triangular self-attention mask across all tokens—meaning that early visual patch tokens at the top-left of an image cannot attend to visual patch tokens at the bottom-right of the image or to the user's text prompt inside the LLM layers!
In "PaliGemma: A versatile 3B VLM for transfer" (Beyer et al., Google DeepMind, arXiv:2407.07726), the authors combine SigLIP-So400m/14 (400M vision encoder) with Gemma-2B (2B decoder LLM) via a single linear projection layer across three fixed square resolution tiers:
224 × 224pixels $\to (224/14)^2 = \mathbf{256}\text{ image tokens}$448 × 448pixels $\to (448/14)^2 = \mathbf{1,024}\text{ image tokens}$896 × 896pixels $\to (896/14)^2 = \mathbf{4,096}\text{ image tokens}$
To maximize the representational capacity of a sub-3B model, PaliGemma formats every input sequence as: $$\texttt{tokens} = \left[\text{image tokens } (N_{\text{img}}),\; \texttt{BOS},\; \text{prefix prompt tokens},\; \texttt{SEP } (\texttt{\textbackslash n}),\; \text{suffix target tokens},\; \texttt{EOS},\; \texttt{PAD}\right]$$ and applies Prefix-LM Block-Bidirectional Attention Masking (arXiv:2407.07726, Section 3.1 & Figure 2):
- Full Unmasked Bidirectional Attention Across Image + Prefix Prompt: Every image token and every user prompt (
prefix) token attends bidirectionally to all other image and prefix tokens ($A_{i,j} = 1$ for all $i, j \in \text{Image} \cup \text{Prefix}$). This allows the visual patch representations inside the Gemma-2B layers to look ahead at the task instructions in the prompt and attend globally across all $N_{\text{img}}$ spatial locations! - Causal Autoregressive Masking Strictly on the Output Suffix: Only the generated target response (
suffixthroughEOS) uses a lower-triangular causal mask ($A_{i,j} = 1 \iff j \le i$).
Combined with a 4-stage curriculum (Stage 0: unimodal pre-training of SigLIP-So400m and Gemma-2B; Stage 1: multimodal pre-training at 224px where neither the image encoder nor the LLM is frozen; Stage 2: staged resolution increase to 448px and 896px; Stage 3: downstream task transfer across ~40 tasks including Remote-Sensing VQA, TallyQA counting, RefCOCO_seg segmentation, and Screen2Words mobile UI summarization), the 3B PaliGemma model matches the 10× larger PaLI-X (55B) and 100× larger PaLM-E (562B)!
2. Master Architectural Comparison of 2026 Vision-Language Models
The table below synthesizes the verified architectural parameters, vision backbones, token compression ratios, positional encoding mechanisms, and training regimes across leading open-weights Vision-Language Models:
| VLM System | Vision Encoder | Language Decoder | Cross-Modal Connector & Compression | Resolution & Positional Encoding | Visual Tokens per Image |
|---|---|---|---|---|---|
Flamingo-80B (arXiv:2204.14198) |
Frozen NFNet-F6 |
Frozen Chinchilla 70B |
Perceiver Resampler + Interleaved tanh Gated Cross-Attn |
Fixed square crop + 2D spatial / 1D time embeddings | 64 latent queries |
BLIP-2 (arXiv:2301.12597) |
Frozen CLIP-ViT-L/14 or EVA-ViT-g/14 |
Frozen OPT or Flan-T5 |
2-Stage Q-Former (BERT-base) + Linear projection |
Fixed 224 × 224 learned 1D pos embeddings |
32 learned queries |
LLaVA-1.5 (7B / 13B) (arXiv:2310.03744) |
Frozen CLIP-ViT-L/14@336px (304M) |
Full-FT Vicuna-7B / 13B |
2-Layer GELU MLP (no token pooling) | 336 × 336 (or 448² grids + 224² global thumbnail in HD) |
576 tokens (336px) |
Idefics2 (8B) (arXiv:2405.02246) |
LoRA SigLIP-So400m/14 (400M) |
LoRA Mistral-7B-v0.1 |
MLP + 6-Layer Perceiver Resampler (11.4× compression) |
Aspect-ratio preserving up to 980 × 980 + 2D pos interp. |
64 tokens / sub-image (320 w/ 4 tiles) |
InternVL 1.5 (26B) (arXiv:2404.16821) |
Full-FT InternViT-6B-448px-V1.5 (45 layers) |
InternLM2-20B |
2×2 Pixel Shuffle (4× reduction) + MLP Projector |
Dynamic 1–12 train / 1–40 test tiles of 448×448 (up to 4K) + thumbnail |
256 per tile (256 to 10,496 total) |
PaliGemma (3B) (arXiv:2407.07726) |
Unfrozen SigLIP-So400m/14 (400M) |
Prefix-LM Gemma-2B |
Single Linear Projection (Bidirectional Image+Prefix mask) | Fixed square tiers: 224², 448², or 896² pixels |
256, 1024, or 4096 tokens |
Qwen2-VL (2B / 7B / 72B) (arXiv:2409.12191) |
Dynamic 675M ViT (patch 14, 3D depth-2 conv) |
Qwen2-1.5B / 7B / 72B |
Adjacent 2×2 → 1 MLP token compression + <|vision_start/end|> |
Naive Dynamic Resolution + ViT 2D-RoPE + LLM 3D M-RoPE (t,h,w) |
Variable (66 at 224²; max 16,384/video) |
Pixtral 12B (arXiv:2410.07073) |
Scratch Pixtral-ViT 400M (24L, dim 1024, patch 16) |
Mistral Nemo 12B (40L, dim 5120, 128K ctx) |
2-Layer GELU MLP + [IMAGE BREAK] & [IMAGE END] tokens |
Native variable resolution/aspect ratio + RoPE-2D + block-diag packing |
Variable up to 4096/image in 128K ctx |
3. Production Python Reference: Computing Visual Token Budgets, RoPE-2D Matrices, and 3D M-RoPE Position Indices
The following self-contained Python reference implements the exact visual token budget equations across ViT/LLaVA-1.5, InternVL 1.5 (Dynamic Aspect-Ratio Tiling + $2 \times 2$ Pixel Shuffle), Qwen2-VL (3D Tubelet + $2 \times 2$ MLP + 3D M-RoPE $(t, h, w)$ position ID generation), and Pixtral 12B (RoPE-2D orthogonal rotation verification):
#!/usr/bin/env python3
"""Exact visual token budget, dynamic tiling, RoPE-2D, and 3D M-RoPE calculators
derived from arXiv:2010.11929, arXiv:2404.16821, arXiv:2409.12191, and arXiv:2410.07073.
"""
from dataclasses import dataclass
import math
from typing import List, Tuple
@dataclass(frozen=True)
class VlmTokenBudget:
"""Immutable report of visual token counts across VLM architectures."""
architecture: str
input_size: Tuple[int, int]
processed_size: Tuple[int, int]
num_tiles: int
vit_raw_tokens: int
llm_visual_tokens: int
def qwen2_vl_token_budget(width: int, height: int, patch_size: int = 14) -> VlmTokenBudget:
"""Compute Qwen2-VL Naive Dynamic Resolution token count (arXiv:2409.12191, Sec. 2.1).
Rounds spatial dimensions to multiples of 2 * patch_size (28 px), applies ViT patch_size=14,
compresses adjacent 2x2 tokens via MLP, and adds <|vision_start|> and <|vision_end|>.
"""
stride = 2 * patch_size # 28 pixels
w_proc = max(stride, round(width / stride) * stride)
h_proc = max(stride, round(height / stride) * stride)
vit_grid_w, vit_grid_h = w_proc // patch_size, h_proc // patch_size
vit_tokens = vit_grid_w * vit_grid_h
compressed_tokens = (vit_grid_w // 2) * (vit_grid_h // 2)
llm_tokens = compressed_tokens + 2 # +2 for <|vision_start|> and <|vision_end|>
return VlmTokenBudget(
architecture="Qwen2-VL",
input_size=(width, height),
processed_size=(w_proc, h_proc),
num_tiles=1,
vit_raw_tokens=vit_tokens,
llm_visual_tokens=llm_tokens,
)
def internvl_1_5_dynamic_tiling(
width: int,
height: int,
tile_size: int = 448,
patch_size: int = 14,
max_tiles: int = 12,
) -> VlmTokenBudget:
"""Compute InternVL 1.5 dynamic aspect-ratio matching & 4x pixel shuffle (arXiv:2404.16821, Sec. 3.3)."""
aspect_ratio = width / height
candidate_ratios: List[Tuple[int, int]] = [
(i, j)
for n in range(1, max_tiles + 1)
for i in range(1, n + 1)
for j in range(1, n + 1)
if i * j == n
]
best_grid = (1, 1)
min_diff = float("inf")
area = width * height
for w_t, h_t in candidate_ratios:
diff = abs(aspect_ratio - (w_t / h_t))
if diff < min_diff:
min_diff = diff
best_grid = (w_t, h_t)
elif math.isclose(diff, min_diff):
if area > 0.5 * tile_size * tile_size * w_t * h_t:
best_grid = (w_t, h_t)
num_tiles = best_grid[0] * best_grid[1]
total_views = num_tiles + (1 if num_tiles > 1 else 0) # +1 global 448x448 thumbnail
raw_per_tile = (tile_size // patch_size) ** 2 # 32 * 32 = 1024
shuffled_per_tile = raw_per_tile // 4 # 2x2 pixel shuffle -> 256
return VlmTokenBudget(
architecture=f"InternVL-1.5 (grid {best_grid[0]}x{best_grid[1]})",
input_size=(width, height),
processed_size=(best_grid[0] * tile_size, best_grid[1] * tile_size),
num_tiles=num_tiles,
vit_raw_tokens=total_views * raw_per_tile,
llm_visual_tokens=total_views * shuffled_per_tile,
)
def generate_m_rope_positions(
prefix_text_len: int,
img_grid_h: int,
img_grid_w: int,
num_video_frames: int = 1,
suffix_text_len: int = 0,
) -> List[Tuple[int, int, int]]:
"""Generate 3D M-RoPE (temporal, height, width) position IDs (arXiv:2409.12191, Fig. 3)."""
positions: List[Tuple[int, int, int]] = []
# 1. Prefix text tokens: t = h = w = idx (equivalent to 1D-RoPE)
for idx in range(prefix_text_len):
positions.append((idx, idx, idx))
# 2. Visual tokens: start at max_prev_id + 1
start_id = (max(max(p) for p in positions) + 1) if positions else 0
for f in range(num_video_frames):
t_id = start_id + f
for r in range(img_grid_h):
for c in range(img_grid_w):
positions.append((t_id, start_id + r, start_id + c))
# 3. Suffix text tokens: resume 1D-RoPE from max_visual_id + 1
next_id = (max(max(p) for p in positions) + 1) if positions else 0
for offset in range(suffix_text_len):
p = next_id + offset
positions.append((p, p, p))
return positions
if __name__ == "__main__":
print(qwen2_vl_token_budget(224, 224))
print(internvl_1_5_dynamic_tiling(800, 1300, max_tiles=12))
m_rope = generate_m_rope_positions(prefix_text_len=4, img_grid_h=8, img_grid_w=8, suffix_text_len=2)
print(f"Total tokens: {len(m_rope)} | Final M-RoPE ID: {m_rope[-1]} (vs 1D-RoPE ID: {len(m_rope) - 1})")9. Frequently Asked Questions (FAQ) on Vision-Language Model Architectures
Why did SigLIP and SigLIP 2 replace CLIP's softmax contrastive loss with a pairwise sigmoid loss? In OpenAI CLIP (arXiv:2103.00020), the symmetric multi-class InfoNCE objective normalizes dot-product similarities via a row-wise and column-wise softmax across the entire global batch $|B|$. Computing that global denominator $\sum_{j=1}^{|B|} \exp(\mathbf{v}i \cdot \mathbf{w}_j / T)$ requires all-to-all collective communication across distributed GPUs/TPUs and tightly couples the single positive pair with $|B|-1$ negative pairs. SigLIP (arXiv:2303.15343) replaces softmax normalization with independent binary logistic regression across every pair $(i, j)$: $\mathcal{L} = \frac{1}{|B|} \sum{i,j} \ln(1 + \exp(-(2\delta_{i,j}-1)(e^\tau \mathbf{w}_i \cdot \mathbf{v}_j + b)))$. Because there is zero global normalization denominator, similarity chunks can be evaluated in a memory-bounded ring pass ($O((|B|/D)^2)$ peak memory per device), performing strongly at small batch sizes (84.5% ImageNet zero-shot on 4 TPUv4 chips in 2 days with SigLiT) and scaling cleanly up to a 1M batch size (with 32k identified as optimal). SigLIP 2 (arXiv:2502.14786) extends this recipe with a LocCa parallel captioning/grounding decoder and DINO/SILC/TIPS local-to-global self-distillation + 50% masked patch prediction.
How do fully autoregressive MLP-connector VLMs compare against Flamingo-style gated cross-attention VLMs? Controlled ablations in Idefics2 (arXiv:2405.02246, Table 3) demonstrate that the optimal architecture depends on whether unimodal backbones are frozen or adapted. When both the vision encoder and LLM are strictly frozen, Flamingo-style interleaved cross-attention outperforms fully autoregressive concatenation (66.7 vs. 60.3 average 4-benchmark score) because cross-attention introduces 1.3B extra trainable parameters (2.0B vs. 0.7B), albeit at +10% higher inference FLOPs. However, when unimodal backbones are unlocked using Low-Rank Adaptation (LoRA) to prevent training divergence, fully autoregressive concatenation surges to 69.5, beating LoRA cross-attention (67.3) with 10% fewer inference FLOPs and zero runtime LoRA overhead after weight merging.
How do InternVL 1.5, Pixtral 12B, and Qwen2-VL read fine-grained text in 4K documents without fixed-resolution blur? They use two distinct strategies to overcome the $224 \times 224$ / $336 \times 336$ fixed-resolution bottleneck. InternVL 1.5 (arXiv:2404.16821) matches the input image's aspect ratio against 35 pre-defined grid layouts (1 to 12 tiles during training, scaling zero-shot up to 40 tiles of $448 \times 448$ pixels—4K resolution—during inference), appends a $448 \times 448$ global thumbnail, and applies a $2 \times 2$ pixel shuffle to compress each tile from 1,024 tokens down to 256 visual tokens (256 to 10,496 tokens total). Conversely, Pixtral 12B (arXiv:2410.07073) and Qwen2-VL (arXiv:2409.12191) eliminate square tiling altogether by replacing learned 1D ViT positional embeddings with 2D Rotary Position Embeddings (RoPE-2D) inside the vision encoder, allowing images of arbitrary native resolution and aspect ratio to be tokenized directly (with [IMAGE BREAK] row tokens in Pixtral 12B and $2 \times 2$ MLP compression + 3D M-RoPE in Qwen2-VL).
What is Multimodal Rotary Position Embedding (M-RoPE) in Qwen2-VL, and how does it improve video length extrapolation? Traditional 1D-RoPE in LLMs assigns a single monotonically increasing 1D index $p$ to every token, discarding 2D/3D spatial geometry and consuming thousands of position indices per video frame. M-RoPE (arXiv:2409.12191, Section 2.1) splits the rotary embedding frequency dimensions into three components: temporal, height, and width $(t, h, w)$. For text tokens, $t = h = w = p$, reducing exactly to 1D-RoPE. For an image of compressed patch grid $H' \times W'$, $t$ stays constant while $h \in [t_0, t_0 + H' - 1]$ and $w \in [t_0, t_0 + W' - 1]$ vary along rows and columns. For videos (sampled at 2 FPS and embedded via depth-2 3D tubelet convolutions), $t$ increments by $+1$ per tubelet frame. Because the subsequent modality starts at $\max(t, h, w) + 1$, a $16 \times 16$ image (256 tokens) advances the position counter by only 16 instead of 256, enabling superior long-context video extrapolation up to 16,384 tokens per video.
Why does PaliGemma use Prefix-LM bidirectional attention masking instead of standard causal decoder masking? In standard causal decoder-only LLMs, token $i$ can only attend to preceding tokens $j \le i$. When image tokens are placed at the start of the sequence [image tokens, BOS, prompt, SEP, answer], causal masking prevents top-left image patches from attending to bottom-right image patches inside the LLM layers and prevents image tokens from seeing the user's question in the prompt. PaliGemma (arXiv:2407.07726, Figure 2) applies unmasked bidirectional block attention across all image tokens ($256$, $1024$, or $4096$ tokens at $224^2$, $448^2$, or $896^2$ resolution) and all user prefix prompt tokens, while restricting causal autoregressive masking strictly to the generated answer suffix after the \n (SEP) token.
How many visual tokens per image are actually required before downstream VLM accuracy saturates? For general visual question answering on natural scenes (VQAv2, OKVQA, COCO), Idefics2 (arXiv:2405.02246, Table 4) found that compressing 729 SigLIP patch tokens down to 64 learned Perceiver Resampler latent tokens per image tile achieved an average score of 71.7, outperforming both un-pooled tokens (60.3 frozen) and 128 Perceiver tokens (71.2). Similarly, Qwen2-VL compresses a $224 \times 224$ image into 66 tokens (64 compressed $2 \times 2$ tokens + 2 delimiter tokens). However, for dense OCR, chart parsing, and multi-column PDF reading (DocVQA, InfoVQA, ChartQA, OCRBench), higher spatial token budgets are essential—scaling from 256 tokens (448 × 448) up to 3,328–10,496 tokens across high-resolution tiles or native dynamic resolution grids.
10. Primary Sources & Technical References
- Dosovitskiy, A., Beyer, L., Kolesnikov, A., Weissenborn, D., Zhai, X., et al. (ICLR 2021). An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale (Vision Transformer / ViT). https://arxiv.org/abs/2010.11929
- Radford, A., Kim, J. W., Hallacy, C., Ramesh, A., Goh, G., et al. (ICML 2021). Learning Transferable Visual Models From Natural Language Supervision (OpenAI CLIP). https://arxiv.org/abs/2103.00020
- Zhai, X., Mustafa, B., Kolesnikov, A., & Beyer, L. (ICCV 2023 Oral). Sigmoid Loss for Language Image Pre-Training (SigLIP). https://arxiv.org/abs/2303.15343
- Tschannen, M., Gritsenko, A., Wang, X., Naeem, M. F., Alabdulmohsin, I., Beyer, L., Zhai, X., et al. (Google DeepMind, 2025). SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features. https://arxiv.org/abs/2502.14786
- Alayrac, J.-B., Donahue, J., Luc, P., Miech, A., Barr, I., et al. (NeurIPS 2022). Flamingo: a Visual Language Model for Few-Shot Learning. https://arxiv.org/abs/2204.14198
- Li, J., Li, D., Savarese, S., & Hoi, S. (ICML 2023). BLIP-2: Bootstrapping Language-Image Pre-training with Frozen Image Encoders and Large Language Models. https://arxiv.org/abs/2301.12597
- Liu, H., Li, C., Wu, Q., & Lee, Y. J. (NeurIPS 2023 Oral). Visual Instruction Tuning (LLaVA). https://arxiv.org/abs/2304.08485
- Liu, H., Li, C., Li, Y., & Lee, Y. J. (CVPR 2024 Highlight). Improved Baselines with Visual Instruction Tuning (LLaVA-1.5 & LLaVA-1.5-HD). https://arxiv.org/abs/2310.03744
- Laurençon, H., Tronchon, L., Cord, M., & Sanh, V. (Hugging Face, 2024). What matters when building vision-language models? (Idefics2). https://arxiv.org/abs/2405.02246
- Chen, Z., Wang, W., Tian, H., Ye, S., Gao, Z., et al. (OpenGVLab / Shanghai AI Laboratory, 2024). How Far Are We to GPT-4V? Closing the Gap to Commercial Multimodal Models with Open-Source Suites (InternVL 1.5 & InternViT-6B). https://arxiv.org/abs/2404.16821
- Beyer, L., Steiner, A., Pinto, A. S., Kolesnikov, A., Wang, X., Zhai, X., et al. (Google DeepMind, 2024). PaliGemma: A versatile 3B VLM for transfer. https://arxiv.org/abs/2407.07726
- Wang, P., Bai, S., Tan, S., Wang, S., Fan, Z., Lin, J., et al. (Alibaba Qwen Team, 2024). Qwen2-VL: Enhancing Vision-Language Model's Perception of the World at Any Resolution (Naive Dynamic Resolution & M-RoPE). https://arxiv.org/abs/2409.12191
- Agrawal, P., Antoniak, S., Hanna, E. B., Bout, B., Chaplot, D., et al. (Mistral AI, 2024). Pixtral 12B (RoPE-2D Native Resolution Vision Encoder & MM-MT-Bench). https://arxiv.org/abs/2410.07073
- Wikipedia Technical Reference (2026). Vision transformer (ViT Architecture, Masked Autoencoders, DINOv2/DINOv3 Gram Anchoring, Swin Transformer, TimeSformer). https://en.wikipedia.org/wiki/Vision_transformer
- Wikipedia Technical Reference (2026). Contrastive Language-Image Pre-training (CLIP Algorithm, Model Registry, WebImageText Preprocessing, and OpenCLIP Scaling). https://en.wikipedia.org/wiki/Contrastive_Language-Image_Pre-training