Multimodal Models

Multimodal models connect text with images, audio and video. This page explains how each modality is turned into vectors, the main fusion strategies, contrastive training as in CLIP, how vision-language models bolt a vision encoder onto an LLM, and where they fail.


1. What Multimodal Models Are

A modality is a kind of data: text, images, audio, video, sensor readings, tables. A multimodal model takes in, or produces, more than one modality and relates them — answering a question about a photo, transcribing and summarising a meeting recording, generating an image from a description, or retrieving video clips with a text query.

The central difficulty is that modalities have very different raw forms: a sentence is a short sequence of discrete tokens, an image is a grid of millions of continuous values, audio is a long one-dimensional waveform. Multimodal architectures differ mainly in how they turn each modality into vectors and where they let those vectors interact, a choice called fusion.

2. Why It Matters

Most real information is multimodal: invoices are scanned images containing tables; medical records combine images, notes and lab values; customer support includes screenshots. Text-only models must rely on lossy conversion (OCR, captions) first. Multimodal models can read the original signal, which improves accuracy on charts, layouts and visual details, and they enable new products such as visual search, accessibility descriptions and voice assistants that respond in real time. Most frontier assistant models are now natively multimodal, accepting images and often audio alongside text.

3. How It Works

Encoding each modality

Text is split into tokens and embedded. Images are usually cut into fixed-size patches (for example 14x14 or 16x16 pixels), each flattened and projected into a vector, then processed by a Vision Transformer. Audio is converted to a log-mel spectrogram and encoded with a convolutional front end plus a Transformer, as in Whisper. Video is treated as a sequence of frames, often subsampled. After encoding, every modality becomes a sequence of vectors, which is what lets the Transformer act as a common backbone.

Fusion strategies

Fusion strategies image text Early fusion concat raw features one joint model image text Late fusion separate models combine predictions image text Intermediate fusion encoders + cross-attn modern VLMs The later the fusion, the more each modality is processed on its own first.

Early fusion combines raw or lightly processed inputs and lets one model learn everything jointly; it captures fine interactions but needs aligned data and lots of compute. Late fusion runs a separate model per modality and merges their predictions, for example by averaging scores; it is simple and robust to a missing modality but cannot learn cross-modal detail. Intermediate fusion encodes each modality separately and then mixes their representations with cross-attention or by interleaving tokens in one Transformer; this is the dominant design for vision-language models.

Contrastive alignment

CLIP: contrastive image-text training Images batch of N Captions batch of N Image encoder ViT / ResNet Text encoder Transformer N x N similarity: diagonal = true pairs Shared space zero-shot search

CLIP (Radford et al., 2021) trains an image encoder and a text encoder together on hundreds of millions of image-caption pairs. For a batch of N pairs it computes all NxN cosine similarities and applies a cross-entropy loss that pushes the N correct pairs (the diagonal) up and all others down. The result is a shared embedding space where "a photo of a dog" lies near dog photos, enabling zero-shot classification and text-to-image retrieval with no task-specific training.

Generative vision-language models

Typical vision-language model (LLaVA style) Image pixels Vision encoder ViT (often CLIP) Projector MLP to LLM dim LLM decoder image + text tokens Prompt tokens "What is shown?" Answer Often the encoder is frozen; the projector (and optionally the LLM) is trained.

Models such as LLaVA connect a pretrained vision encoder to a pretrained LLM through a small projector that maps image features into the LLM's token-embedding space. The image becomes a few hundred "visual tokens" placed in front of the text prompt, and the LLM generates the answer. Training usually has two stages: align the projector on image-caption data, then instruction-tune on visual question-answer conversations. Flamingo used gated cross-attention layers instead; some newer models are trained natively on interleaved image and text tokens from the start.

4. Worked Example: Zero-Shot Classification with CLIP

Using Hugging Face Transformers (pip install transformers torch pillow requests):

import requests, torch
from PIL import Image
from transformers import CLIPModel, CLIPProcessor

model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
proc = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")

url = "http://images.cocodataset.org/val2017/000000039769.jpg"   # two cats on a couch
image = Image.open(requests.get(url, stream=True).raw)

labels = ["a photo of a cat", "a photo of a dog", "a photo of a car"]
inputs = proc(text=labels, images=image, return_tensors="pt", padding=True)

with torch.no_grad():
    out = model(**inputs)
probs = out.logits_per_image.softmax(dim=1)[0]
for label, p in zip(labels, probs):
    print(f"{p:.3f}  {label}")

No training happened: the class names are the classifier. Prompt wording matters ("a photo of a ..." works better than a bare word), and averaging several templates per class usually helps. For retrieval, store model.get_image_features(...) vectors in a vector index and search with get_text_features(...).

5. Evaluating and Deploying Multimodal Models

Public benchmarks give a first filter: MMMU for expert-level multi-discipline questions, DocVQA and ChartQA for documents and charts, TextVQA for reading text in scenes, and retrieval recall on COCO or Flickr30k for embedding models. They rarely match your own data, so build a small labelled set from real inputs — your invoices, your product photos, your call recordings — and measure exact-match or rubric scores on it before choosing a model.

Deployment adds its own constraints. Images inflate prompt size and latency, so resize to the smallest resolution that keeps the needed detail and cache embeddings for anything you search repeatedly. For document pipelines, compare a vision-language model reading page images against a classic OCR-plus-LLM pipeline on accuracy, cost and speed; each wins on different document types. Log the inputs that fail so you can grow the evaluation set over time.

6. Comparison of Approaches

ApproachExample modelsOutputStrengthsLimitations
Contrastive dual encoderCLIP, SigLIPEmbeddingsFast retrieval, zero-shot labels, index onceNo generation; weak at counting and spatial relations
Encoder + projector + LLMLLaVA familyTextReuses strong LLMs, cheap to trainFixed image resolution limits fine detail
Cross-attention into LMFlamingoTextInterleaved images and text, few-shotMore parameters to train
Native multimodalFrontier assistant modelsText, sometimes audio or imagesBest overall qualityClosed or very large
Speech modelsWhisperText from audioRobust transcription, many languagesAudio only; may hallucinate on silence
Text-to-image diffusionStable DiffusionImagesHigh-quality generationText understanding limited by text encoder

7. Pitfalls

9. Further Reading