Teaching an autoregressive language model to see requires solving a fundamental representation mismatch: language is discrete, sequential, and symbolic, whereas images are continuous, high-dimensional spatial grids packed with redundant pixel correlations. Modern Vision-Language Models (VLMs) — from LLaVA-OneVision, Qwen2.5-VL, and InternVL 2.5 to proprietary frontier systems like GPT-4o and Gemini 1.5 Pro — bridge this gap by turning images into sequences of continuous visual tokens that live directly inside the language model's embedding manifold. Understanding how pixels become reasoning tokens explains both why current multimodal models excel at complex chart synthesis and why they still stumble on sub-patch spatial counting.
Vision Transformers: Patch Embedding and Position Encoding
Nearly every production VLM begins its visual pipeline with a Vision Transformer (ViT, Dosovitskiy et al., 2020) pretrained via contrastive image-text alignment such as CLIP (Radford et al., 2021) or sigmoid-loss SigLIP (Zhai et al., 2023). Given an input RGB image tensor $I \in \mathbb{R}^{H \times W \times C}$ and a patch size $P$ (canonically $P = 14$ for CLIP-ViT-L/14 and SigLIP-So400m/14), the image is partitioned into a non-overlapping grid of $N$ patches:
$$N = \frac{H \times W}{P^2}$$
For a standard $336 \times 336$ input image with $P = 14$, the grid measures $24 \times 24$, yielding $N = 576$ spatial patches. Each $14 \times 14 \times 3 = 588$-element patch is flattened and projected through a learned linear convolution (kernel size $14 \times 14$, stride $14$) into a $D_v$-dimensional visual hidden state ($D_v = 1024$ for ViT-L, $1152$ for SigLIP-So400m).
Fixed-resolution $336 \times 336$ resizing is fatal for OCR, dense PDF tables, and mobile UI screenshots: downsampling a $1920 \times 1080$ terminal screenshot to $336 \times 336$ blurs 8-point monospace fonts into illegible gray smudges. Contemporary VLMs overcome this via two architectural mechanisms:
- Dynamic High-Resolution Tiling (AnyRes): Introduced in LLaVA-NeXT and refined in InternVL 2, the input image is matched to an aspect-ratio-preserving grid (e.g., $2 \times 2$, $1 \times 3$, or $3 \times 4$ tiles of $336 \times 336$ or $448 \times 448$ each), alongside a downsampled global thumbnail that preserves holistic layout context.
- Native Variable Resolution with 2D-RoPE: Pioneered by NaViT and deployed in Qwen2-VL, the vision encoder eliminates fixed absolute 1D positional embeddings altogether. Instead, images of arbitrary resolution and aspect ratio are packed into variable-length patch sequences using 2D Rotary Position Embeddings (2D-RoPE), encoding explicit $(x, y)$ row and column frequencies directly into self-attention queries and keys.
Image-Text Fusion: Projection Layers vs. Cross-Attention
Once the ViT backbone produces $N$ visual patch features $Z_v \in \mathbb{R}^{N \times D_v}$, the architecture must align those features with the language decoder's token embedding space $\mathbb{R}^{D_{\text{llm}}}$ (for instance, $D_{\text{llm}} = 4096$ in an 8B decoder). Across frontier VLMs, two competing fusion paradigms dominate:
1. Decoder-Only Token Concatenation (MLP / Pixel-Shuffle Connector): Used by LLaVA, Qwen-VL, InternVL, and Pixtral. A lightweight 2-layer Multi-Layer Perceptron with a GELU activation maps each visual feature vector directly into the LLM token space:
$$H_v = W_2 \cdot \text{GELU}(W_1 \cdot Z_v + b_1) + b_2, \quad H_v \in \mathbb{R}^{N \times D_{\text{llm}}}$$
The projected visual tokens $H_v$ are spliced directly into the text token sequence at the <image> placeholder position. To prevent high-resolution images (which can generate $4,096+$ patches) from exhausting the KV cache, models apply 2×2 Pixel Unshuffle (grouping $2 \times 2$ adjacent spatial patches along the channel dimension before the MLP) to compress token counts by $4\times$—turning 576 patches into 144 dense visual tokens per tile.
2. Gated Cross-Attention & Perceiver Resamplers: Used by Flamingo, IDEFICS, and Llama 3.2 Vision (Mllama). Instead of lengthening the causal decoder sequence with thousands of image tokens, a Perceiver Resampler uses a small set of learned latent queries (e.g., 64 queries) to pool visual features, or inserts gated cross-attention layers between frozen LLM self-attention blocks where text tokens act as Queries ($Q$) and ViT patch features act as Keys and Values ($K, V$). Cross-attention keeps the LLM's autoregressive sequence length short during multi-image video streams, though direct token concatenation consistently outperforms resamplers on fine-grained OCR and spatial localization benchmarks because no spatial tokens are bottlenecked prior to causal reasoning.
import torch
import torch.nn as nn
class PixelShuffleMultimodalProjector(nn.Module):
"""
2x2 Spatial Pixel-Unshuffle + 2-Layer MLP Connector (InternVL / Qwen-VL style).
Compresses N=576 (24x24) ViT patches -> 144 visual tokens in LLM embedding space.
"""
def __init__(self, vit_hidden_dim: int = 1024, llm_hidden_dim: int = 4096, scale_factor: int = 2):
super().__init__()
self.scale = scale_factor
compressed_dim = vit_hidden_dim * (scale_factor ** 2)
self.mlp = nn.Sequential(
nn.LayerNorm(compressed_dim),
nn.Linear(compressed_dim, llm_hidden_dim, bias=True),
nn.GELU(),
nn.Linear(llm_hidden_dim, llm_hidden_dim, bias=True),
)
def pixel_unshuffle_2d(self, x: torch.Tensor, h: int, w: int) -> torch.Tensor:
# x: (batch, h*w, C) -> (batch, (h/s)*(w/s), C * s^2)
b, _, c = x.shape
s = self.scale
x = x.view(b, h, w, c)
x = x.view(b, h // s, s, w // s, s, c)
x = x.permute(0, 1, 3, 2, 4, 5).contiguous()
return x.view(b, (h // s) * (w // s), c * (s * s))
def forward(self, vit_patch_embeddings: torch.Tensor, grid_h: int = 24, grid_w: int = 24) -> torch.Tensor:
# vit_patch_embeddings: (batch, 576, 1024)
compressed = self.pixel_unshuffle_2d(vit_patch_embeddings, grid_h, grid_w) # (batch, 144, 4096)
visual_tokens = self.mlp(compressed) # (batch, 144, 4096)
return visual_tokens
Visual Instruction Tuning and Alignment Data
Connecting a pretrained ViT to a pretrained LLM yields gibberish until the connector's weights align the two representation manifolds. Modern VLM training follows a three-stage curriculum:
- Stage 1 — Projector Warmup (Modality Alignment): Both the ViT encoder and the LLM backbone are frozen; only the MLP projector weights ($\sim 20\text{M–}50\text{M}$ parameters) are trained on $558\text{K–}2\text{M}$ image-caption pairs (LAION-CCS, ShareGPT4V-PT). This stage teaches the MLP to translate visual patch vectors into "visual words" the frozen LLM embedding layer already understands.
- Stage 2 — High-Resolution Visual Knowledge Pretraining: The ViT (or its top layers), projector, and LLM are unfrozen jointly on $5\text{M–}50\text{M}$ interleaved image-text web documents, synthetic OCR transcriptions, LaTeX equations, and bounding-box grounding annotations. Unfreezing the ViT during this phase is critical when scaling input resolution from $336\text{px}$ to $1344+\text{px}$ or teaching dense document parsing.
- Stage 3 — Visual Instruction Tuning (SFT + Multimodal DPO): Pioneered by LLaVA (Liu et al., 2023), the full model is fine-tuned on multi-turn conversational question-answering datasets covering chart reasoning, UI navigation, code generation from wireframes, and STEM diagrams, followed by Direct Preference Optimization (DPO) on hallucination-contrastive pairs to penalize inventing objects not present in the image.
Architecture Comparison: LLaVA, Qwen-VL, InternVL, Gemini
While open-weights models converge on ViT + MLP + Decoder pipelines, their scaling choices differ sharply in how much parameter budget they allocate to the vision encoder versus the language backbone:
| Model Family | Vision Encoder | Fusion Connector | Resolution Strategy | MMMU (Val) | DocVQA (Test) |
|---|---|---|---|---|---|
| LLaVA-OneVision-72B | SigLIP-So400M/14 | 2-Layer MLP + Bilinear Pool | AnyRes (up to 2304×2304) | 56.8% | 91.3% |
| Qwen2.5-VL-72B | Custom 675M ViT (2D-RoPE) | 2×2 MLP Merger | Native Dynamic Resolution | 64.5% | 95.7% |
| InternVL 2.5-78B | InternViT-6B (448px) | 2×2 Pixel Unshuffle + MLP | Dynamic 1–12 Tiles + Thumb | 64.2% | 95.1% |
| Gemini 1.5 Pro | Native Early-Fusion MoE | Unified Multimodal Tokens | Multi-Scale Native Tiling | 65.9% | 93.1% |
Notice the divergence between LLaVA-OneVision (which pairs a lightweight 400M-parameter SigLIP encoder with a 72B LLM) and InternVL 2.5 (which scales the vision encoder itself to a massive 6-billion-parameter InternViT-6B). Scaling the vision encoder to 6B parameters offloads complex OCR, rotated text recognition, and dense chart extraction from the language layers into the visual representation itself. Conversely, Gemini 1.5 Pro abandons post-hoc adapter stitching altogether, training a sparse Mixture-of-Experts (MoE) transformer natively across interleaved text, image, audio, and video tokens from initialization.
Benchmarks: MMMU, DocVQA, ChartQA, and Real-World Failure Modes
Evaluating VLMs requires separating perception from reasoning. DocVQA and ChartQA primarily stress high-resolution patch fidelity and layout alignment: models with native dynamic resolution (Qwen2.5-VL) or high-tile AnyRes (InternVL 2.5) now exceed 95% accuracy on DocVQA, matching human annotators on scanned invoices and engineering schematics. MMMU (Massive Multi-discipline Multimodal Understanding) tests college-level reasoning across 30 subjects (organic chemistry structures, circuit diagrams, musical scores, medical pathology), where scores remain bounded in the 62–68% range primarily due to domain reasoning bottlenecks rather than visual blur.
Despite these gains, three architectural blind spots persist in production deployments:
- Sub-Patch Spatial Blindness and Counting Errors: Because a $14 \times 14$ patch is collapsed into a single vector in layer 1 of the ViT, fine geometric relationships smaller than $14\text{px}$ — such as whether two thin lines in a CAD blueprint intersect or merely touch, or counting 40 densely packed pills in a tray — regularly fail unless the image is cropped and zoomed before encoding.
- Tile-Boundary Fracturing: In AnyRes tiling systems, when a table row or a street sign is sliced horizontally across the boundary between Tile $(0,0)$ and Tile $(1,0)$, lack of cross-tile self-attention inside the frozen ViT (which encodes each tile independently) can cause the LLM to misread or duplicate characters along the seam.
- Language Prior Hallucination: When an image contradicts strong statistical priors in the LLM backbone — for example, an analog clock face deliberately drawn with 13 hours, or a modified corporate flowchart where an arrow points backward — the language decoder's causal prior often overrides the visual tokens unless the temperature is set near zero and prompt instructions explicitly force step-by-step visual coordinate grounding first.