← All posts

AI basics › How LLMs work

What is multimodal AI? How models read images and text

Multimodal AI handles more than one kind of data, like text and images. How images become tokens, how CLIP links pictures and words, and where it falls short.

Perhaps you’ve attached a photo to a chatbot and asked what was in it, or pasted a screenshot of an error message instead of typing it out. Announcements of new AI models also tend to mention, somewhere near the top, that the model is multimodal. That’s because so much of what people now hand to AI isn’t text at all: photos, scanned forms, charts, and screens. And now that AI agents operate computers by looking at screenshots, the word has become something developers need to think through as well.

Multimodal AI is AI that takes in, or produces, two or more kinds of data together, such as text, images, sound, and video. Each kind of data is called a modality. A 2017 survey by Tadas Baltrušaitis and colleagues describes a modality as the way in which something happens or is experienced, and calls a problem multimodal when it involves several of them. So a text-only LLM works with one modality, while a model that answers a question about a photo works with two.

How an image becomes tokens

A language model reads text as a sequence of tokens, small pieces of text that each become a vector of numbers inside the model. So the first problem for a model that sees is turning an image into something similar. The answer that many of today’s models build on goes back to the Vision Transformer (ViT), which Alexey Dosovitskiy and colleagues at Google introduced in 2020.

The method is simpler than you might expect. You cut the image into a grid of small squares called patches, flatten each patch into a row of pixel values, and pass it through a linear layer, and it becomes a vector just like a word token. Then you add a position embedding that tells the model where each patch sits, put one extra token in front to stand for the whole image, and feed the sequence to an ordinary transformer. The paper says image patches are treated the same way as tokens in language, and it adds that smaller patches make the sequence longer and the model more expensive to run.

Putting pictures and sentences in one space

Even with images turned into vectors, a photo of a dog and the word dog still have to meet somewhere before a model can connect them. CLIP, which Alec Radford and colleagues at OpenAI published in 2021, did this with 400 million image and text pairs collected from the internet. CLIP trains an image encoder and a text encoder together, raising the cosine similarity between each image and its own caption while lowering it for the other captions in the same batch. This is called contrastive learning, and once it’s done, an image and a sentence that describes it end up close together in a shared space.

That shared space makes zero-shot classification possible, which means sorting images into categories the model was never specifically trained on, using nothing but text. You write each category as a sentence and pick the sentence closest to the image. According to the paper, zero-shot CLIP matched the original ResNet-50 on ImageNet without using any of the 1.28 million labeled images that ResNet-50 was trained on.

Trying CLIP on a few drawn pictures

Let’s see this for ourselves. I used openai/clip-vit-base-patch32, a CLIP model from January 2021 whose image encoder is a ViT with 32×32-pixel patches. Its weights are about 600 MB. The code below draws a red circle, a blue square, and a sign that says OPEN with Pillow, then compares each picture with five sentences. All it needs is pip install torch transformers pillow, and the model downloads itself on the first run.

import torch
from PIL import Image, ImageDraw, ImageFont
from transformers import CLIPModel, CLIPProcessor

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

def blank():
    img = Image.new("RGB", (224, 224), "white")
    return img, ImageDraw.Draw(img)

circle, d = blank(); d.ellipse((42, 42, 182, 182), fill="red")
square, d = blank(); d.rectangle((52, 52, 172, 172), fill="blue")
sign, d = blank(); d.rectangle((20, 70, 204, 154), outline="black", width=4)
d.text((112, 112), "OPEN", fill="black", anchor="mm", font=ImageFont.load_default(size=56))

labels = ["a red circle", "a blue circle", "a blue square",
          "a sign that says OPEN", "a sign that says CLOSED"]
inputs = processor(text=labels, images=[circle, square, sign], return_tensors="pt", padding=True)
with torch.no_grad():
    out = model(**inputs)
probs = out.logits_per_image.softmax(dim=-1)  # each image's scores add up to 1

print(f"{'':24}{'circle':>8}{'square':>8}{'sign':>8}")
for i, label in enumerate(labels):
    print(f"{label:24}" + "".join(f"{p:8.3f}" for p in probs[:, i]))
                          circle  square    sign
a red circle               0.913   0.000   0.000
a blue circle              0.082   0.041   0.000
a blue square              0.004   0.959   0.000
a sign that says OPEN      0.000   0.000   0.999
a sign that says CLOSED    0.000   0.000   0.001

Each column is one picture, and its numbers add up to 1. The model was never trained specifically to sort circles from squares or to read signs, yet the right sentence won all three columns. Since “a blue circle”, which gets either the color or the shape wrong, still took 0.082 in the circle column and 0.041 in the square column, the model seems to weigh color and shape together. And as the sign shows, it reads printed words too. Next, let’s look at what an image turns into inside the model.

cfg = model.config.vision_config
side = cfg.image_size // cfg.patch_size
print(f"{cfg.image_size}px input, {cfg.patch_size}px patches: {side} x {side} = {side * side} patches")

screenshot = Image.new("RGB", (1920, 1080), "white")
pixels = processor(images=screenshot, return_tensors="pt")["pixel_values"]
print("after the processor:", tuple(pixels.shape))
with torch.no_grad():
    vision = model.vision_model(pixel_values=pixels).last_hidden_state
print("vision tokens:", tuple(vision.shape))
print("image vectors:", tuple(out.image_embeds.shape), "text vectors:", tuple(out.text_embeds.shape))
224px input, 32px patches: 7 x 7 = 49 patches
after the processor: (1, 3, 224, 224)
vision tokens: (1, 50, 768)
image vectors: (3, 512) text vectors: (5, 512)

According to its settings, the image encoder cuts a 224×224-pixel image into 32-pixel patches, so every picture becomes a 7 by 7 grid of 49 patches. Add ViT’s class token and you get the 50 vision tokens on the third line, each a vector of 768 numbers. The 1920×1080 screenshot also came out at 224 by 224. The processor shrinks the short side to 224 pixels and then cuts out the square in the middle, so both sides of a wide image are dropped. And as the last line shows, pictures and sentences both become vectors of 512 numbers, which is why the two can be compared directly.

How today’s vision language models are built

CLIP can match images with sentences, but it can’t write an answer. Vision language models (VLMs), which can, are often built by attaching an image encoder to an LLM. A simple example is LLaVA, which Haotian Liu and colleagues presented at NeurIPS 2023. It joins CLIP’s ViT-L/14 image encoder and the Vicuna language model with a single trainable projection matrix. Since the matrix turns the encoder’s output into vectors the same size as the LLM’s word embeddings, the LLM receives the image as a sequence of visual tokens sitting next to the text. Training came in two stages: first only the projection was fitted, and then the LLM was fine-tuned along with it on instruction-following examples generated with GPT-4.

Some models, on the other hand, are described as trained on several modalities from the start. When Google announced Gemini on December 6, 2023, it said the standard approach until then had been to train separate components for different modalities and stitch them together, while Gemini was pre-trained from the start on different modalities. OpenAI’s GPT-4o system card, dated August 8, 2024, likewise says GPT-4o was trained end-to-end across text, vision, and audio, with all inputs and outputs processed by the same neural network. Not every detail of how this works has been published, so it’s safest to read these as the companies’ own descriptions.

Approach How images are handled Example
Shared embedding space Images and sentences become comparable vectors CLIP (2021)
Encoder joined to an LLM Encoder output goes into the LLM as tokens LLaVA (2023)
Trained together from the start One model is trained on several modalities Gemini (2023), GPT-4o (2024)

Multimodal output and generative AI

The word applies to the output side too. Image generators that turn a sentence into a picture and speech synthesis that reads text aloud are both examples, and according to its system card, GPT-4o also produces text, audio, and image outputs. That’s where it overlaps with generative AI, yet the two words point at different things. Generative is about whether a model makes new content, while multimodal is about how many kinds of data it handles. A text-only chatbot is generative without being multimodal, and CLIP is multimodal while making nothing at all.

Where it helps

One common use is reading documents. Scanned forms, tables, and charts mix text with layout, and a model that sees the page can handle the layout as well, which is easy to lose when you copy out only the text. Screens are another. Anthropic’s computer use tool gives Claude screenshot, mouse, and keyboard control, and repeats a loop of looking at a screenshot and choosing the next action until the task is done. And for people who are blind or have low vision, a model that describes a photo or a screen in words can pass on information they couldn’t see.

Where it falls short

The first problem is saying something is in an image when it isn’t. In an EMNLP 2023 study, Yifan Li and colleagues found that most of the vision language models they evaluated, LLaVA among them, suffered from severe object hallucination, naming objects that weren’t in the image. Objects that appear often in the training instructions, or that often show up together with what is in the image, were invented more easily.

The second is counting, which both the CLIP paper and the model card list as something CLIP struggles with. So, continuing from the code above, I tried pictures with one to eight black dots.

def dots(n):
    img, d = blank()
    for i in range(n):
        x, y = 30 + i % 4 * 50, 70 + i // 4 * 60
        d.ellipse((x, y, x + 34, y + 34), fill="black")
    return img

words = ["one", "two", "three", "four", "five", "six", "seven", "eight"]
images = [dots(n) for n in range(1, 9)]
print(f"{'true count':26}" + "".join(f"{w:>6}" for w in words))
for template in ["a photo of {} black dots", "{} black dots"]:
    labels = [template.format(w) for w in words]
    labels[0] = labels[0].replace("dots", "dot")  # "one black dot"
    inputs = processor(text=labels, images=images, return_tensors="pt", padding=True)
    with torch.no_grad():
        best = model(**inputs).logits_per_image.argmax(dim=-1)  # closest sentence per image
    print(f"{template:26}" + "".join(f"{words[i]:>6}" for i in best))
true count                   one   two three  four  five   six seven eight
a photo of {} black dots     one   two  four  four  five   six   six   six
{} black dots                one   one  four  four  four  four  four  four

With the “a photo of” template, CLIP got five of the eight counts right, but without those words it got only two and called every picture with three or more dots four. It’s a small model from 2021, but Anthropic’s vision guide also says Claude’s counts are approximate and may be off, especially with large numbers of small objects. The same guide warns that Claude may hallucinate or make mistakes with low-quality images or very small ones under 200 pixels, and that resizing can make text harder to read.

The last is cost. According to the same guide, which I checked on October 28, 2026, Claude counts each 28×28-pixel patch as one visual token. So an image costs its width divided by 28 times its height divided by 28, each rounded up. A 1000×1000 image comes to 1,296 tokens, and a 1920×1080 screenshot comes to 2,691 tokens on the high-resolution tier of Claude 4.7 and later models. These tokens take up the context window and the bill, so for an agent that sends screenshots often, it’s worth following the guide’s advice to downsample images when you don’t need the extra detail.

Where to start

If you’d like to try it yourself, run the three code blocks above in order, then swap the drawings for photos of your own and the sentences for your own labels. Keep in mind that the model card presents CLIP as a research model, says any deployed use is out of scope for now, and limits it to English. I ran these examples on October 28, 2026, on a Mac’s CPU with Python 3.13.12, PyTorch 2.14.1, Transformers 5.20.2, and Pillow 13.0.0.

AI tools helped with the research for this post.