Mayank SaxenaExplainers

How models work · explainer

How One AI Model Reads, Sees and Hears

You can hand the same chatbot a paragraph, a photo, a voice note or a video clip, and it answers about all of them. There is no separate “eye” or “ear” bolted on at the end. Instead, every kind of input is turned into the same thing, a list of numbers, and one model reads them all together. This post shows how, step by step.

Mayank SaxenaExplainer

In short

01The trick: turn everything into vectors

A language model is built on the transformer (Vaswani et al. 2017). Its input is not text. It is a sequence of vectors: lists of numbers, a few thousand long. For text, a tokenizer cuts the words into pieces and each piece is swapped for its own learned vector. The transformer then lets each vector look at the ones before it, layer after layer, and predicts what comes next.

Nothing in that machinery says the vectors must come from words. If you can turn a photo or a sound into vectors of the right length, you can put them in the same sequence. That is the whole idea of a multimodal model. The rest of this post is about how each kind of input becomes vectors, and how the model learns to make sense of them together.

Four kinds of input, one sequence, one model

Each input has its own front end. What comes out of each is the same kind of thing: vectors, shown as coloured blocks.

Figure 1: The front ends differ; the model behind them does not. Once the clip, the audio and the question sit in one sequence, answering “what’s happening?” is the same task as continuing any other text.

02Images: cut into patches

The standard way to feed an image to a transformer is to cut it into a grid of small squares, called patches, and treat each patch like a word. The paper that made this work was titled “An image is worth 16×16 words” (Dosovitskiy et al. 2021). Each patch’s pixels are flattened into one long list of numbers and multiplied by a learned matrix, which squeezes it into one vector. Try it:

An image becomes a grid of patches; each patch becomes one vector

Change the patch size and click a square to follow it from pixels to a vector.

Figure 2: Smaller patches mean more detail and more tokens: halving the patch size quadruples the count. A typical setup, 336-pixel images in 14-pixel patches, gives 24 × 24 = 576 image tokens (Liu et al. 2024).

Those raw patch vectors are not yet very meaningful: one is “mostly red”, another “a green edge”. So they first pass through a vision encoder, itself a transformer, in which every patch looks at every other patch. By the end, the vector for a patch on the car’s wheel carries information like “part of a car”. Many models reuse an encoder called CLIP for this (Radford et al. 2021). How CLIP learned to do that is the key to the whole story.

03Making pictures and words meet

Cutting an image into vectors is easy. Making those vectors mean the same things as the language model’s word vectors is the hard part. If the vector for a photo of a dog lands nowhere near the idea of “dog”, the language model cannot use it.

CLIP solved this with a simple game, played over 400 million image–caption pairs collected from the web. Show an image encoder and a text encoder a batch of photos and their captions. Reward them when each photo’s vector is closest to its own caption’s vector and far from the others. This is called contrastive training. After enough rounds, photos and descriptions of the same thing end up near each other in one shared space. Later work extended the same trick to sound, depth and other kinds of data (Girdhar et al. 2023).

Training pulls matching image, text and sound together

A sketch of a shared embedding space, flattened to two dimensions. Toggle before and after training; hover or tap points.

Figure 3: Before training, an image and its caption land in unrelated places. After contrastive training, position means meaning: everything about dogs sits together, whatever form it arrived in. Illustrative; real spaces have hundreds of dimensions.

With an aligned encoder in hand, the last step is small. A little projector, often just two layers, reshapes the image vectors to the exact size and style of the language model’s word vectors. LLaVA, one of the first open models to do this, then trained on image–instruction pairs so the model learned to talk about what it sees (Liu et al. 2023).

04Audio: a picture of sound

Sound arrives as a wave: thousands of pressure readings per second. That raw wave is too long and too repetitive to read directly, so most models first draw a spectrogram, a picture of which pitches are loud at each moment. Speech then looks like stripes and bands, and a model can read it much as it reads an image.

Whisper, OpenAI’s speech model, takes 25-millisecond slices every 10 milliseconds and measures 80 frequency bands in each (128 in its latest version) (Radford et al. 2022). That gives 100 columns per second. Its encoder then merges neighbouring columns, leaving 50 vectors per second of audio. Gemini’s API counts 32 tokens per second (Google, Gemini API docs).

From a sound wave to the vectors a model reads

A real spectrogram, computed with Whisper’s settings, of a synthetic 3-second sound: three vowels, an “s”, a rising whistle and a clap. Drag the slider to move through it.

Figure 4: Vowels show as stacked horizontal bands, the “s” as a haze in the high frequencies, the whistle as one rising line and the clap as a thin vertical stripe. Each block in the bottom row is one vector; the language model never sees the wave itself.

There is a second way to turn audio into tokens, used when a model must also speak. A neural audio codec compresses sound into a sequence of discrete codes, like a tiny vocabulary of sound fragments, and can turn those codes back into audio (Zeghidour et al. 2021; Défossez et al. 2022). A model that predicts codec tokens can produce speech the same way it produces words.

05Video: a flip-book of images

A video is a stack of images over time, usually with a soundtrack. The simplest approach is to sample frames, turn each into image tokens and place them in order, with timestamps and the audio alongside. Some models instead cut video into small 3D blocks that span a few frames, so motion is captured inside a single token (Arnab et al. 2021).

Frames are expensive, so models sample sparingly. Gemini’s API, for example, samples one frame per second by default and counts video at 263 tokens per second (Google, Gemini API docs). That keeps costs manageable, but anything that happens between two sampled frames is simply not there.

What the model sees depends on how often it looks

A 10-second clip of a bouncing ball. Black lines mark the sampled frames. Change the rate and watch the cost and the yellow moment.

Figure 5: At one frame a second the model never sees the ball hit the can; it sees a standing can and then a fallen one, and has to guess what happened in between. Sampling more often catches it, at several times the cost. The 258 tokens per frame match one small image in Gemini’s API.

06Three ways to wire it together

Given encoders that produce vectors, there are three main ways to connect them to a language model. They differ in what is reused, what is trained, and whether the model can produce images or sound as well as understand them.

Adapter, cross-attention or native

Switch between the three designs.

Figure 6: Adapters (Liu et al. 2023) are the cheapest and most common in open models. Cross-attention (Alayrac et al. 2022) protects a frozen language model. Native models such as Chameleon train on mixed tokens from the start (Chameleon Team 2024); GPT-4o and Gemini are described by their makers as trained end to end across modalities (OpenAI 2024; Gemini Team 2023).

07Inside the sequence: words look at pixels

Once image vectors and word vectors share a sequence, attention does the rest. When the model processes the word “car” in your question, attention lets it pull information from whichever vectors are most relevant, and after alignment training those include the patches that show the car. No special “vision module” answers the question; the same layers that link a pronoun to its noun link a word to a region of the picture.

Each text token draws on the image patches it needs

An illustration of attention from text to image, with hand-set weights; brighter squares get more attention.

Figure 7: Attention is a learned, soft lookup: every token takes a weighted mix of all earlier vectors. The weights here are drawn by hand to show the idea. In real models attention is spread across many heads and layers and is messier.

08The token budget

Every vector in the sequence costs compute and fills up the model’s context window. Text is cheap. Pictures, sound and especially video are not.

A minute of video costs as many tokens as a long book chapter

Tokens per input, log scale. Each bar is a documented or measured count for a specific model.

Figure 8: A minute of video at Gemini’s rate uses about 250 times as many tokens as a short paragraph. Paragraph: a -word sample paragraph summarising this post, counted with GPT-4o’s tokenizer. Other counts from the cited documentation and papers.

09What this explains about everyday quirks

Underneath the variety there is one idea: find a way to cut each kind of input into pieces, turn each piece into a vector, train until vectors about the same thing land in the same place, and let one transformer read them in a single line.

References

  1. Alayrac et al. (2022). Flamingo: a Visual Language Model for Few-Shot Learning. NeurIPS 2022. arXiv:2204.14198
  2. Arnab, Dehghani, Heigold, Sun, Lučić, Schmid (2021). ViViT: A Video Vision Transformer. ICCV 2021. arXiv:2103.15691
  3. Chameleon Team (2024). Chameleon: Mixed-Modal Early-Fusion Foundation Models. arXiv:2405.09818
  4. Défossez, Copet, Synnaeve, Adi (2022). High Fidelity Neural Audio Compression (EnCodec). arXiv:2210.13438
  5. Dosovitskiy et al. (2021). An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale. ICLR 2021. arXiv:2010.11929
  6. Gemini Team, Google (2023). Gemini: A Family of Highly Capable Multimodal Models. arXiv:2312.11805
  7. Google. Understand and count tokens, Gemini API documentation (accessed December 2026). ai.google.dev/gemini-api/docs/tokens
  8. Girdhar, El-Nouby, Liu, Singh, Alwala, Joulin, Misra (2023). ImageBind: One Embedding Space To Bind Them All. CVPR 2023. arXiv:2305.05665
  9. Liu, Li, Wu, Lee (2023). Visual Instruction Tuning (LLaVA). NeurIPS 2023. arXiv:2304.08485
  10. Liu, Li, Li, Lee (2024). Improved Baselines with Visual Instruction Tuning (LLaVA-1.5). CVPR 2024. arXiv:2310.03744
  11. OpenAI (2024). Hello GPT-4o. openai.com/index/hello-gpt-4o
  12. Radford et al. (2021). Learning Transferable Visual Models From Natural Language Supervision (CLIP). ICML 2021. arXiv:2103.00020
  13. Radford, Kim, Xu, Brockman, McLeavey, Sutskever (2022). Robust Speech Recognition via Large-Scale Weak Supervision (Whisper). arXiv:2212.04356
  14. Vaswani et al. (2017). Attention Is All You Need. NeurIPS 2017. arXiv:1706.03762
  15. Zeghidour, Luebs, Omran, Skoglund, Tagliasacchi (2021). SoundStream: An End-to-End Neural Audio Codec. arXiv:2107.03312