An ordinary language model reads only text. A multimodal model also accepts other kinds of data and answers about them: it describes a photograph, reads a scan, answers a question about a chart. The most common variant is a model with images and text as input and text as output.
VLMs: image and text
These models are called vision language models (VLMs). In the Hugging Face documentation they fall under the image-text-to-text task: unlike image-to-text models, which solve one narrow task, VLMs accept an arbitrary text prompt together with the picture.
What a VLM consists of
| Part | What it does |
|---|---|
| Image encoder | turns the picture into a set of vectors; often a Vision Transformer, such as CLIP-ViT |
| Projector | maps the image vectors into the same space in which text tokens work; in LLaVA 1.5 it is a small MLP network |
| Language model | receives text tokens and “image tokens” interleaved, and writes the answer |
In LLaVA, a picture takes up a noticeable share of the context: in the Transformers configuration, the default length of one image is 576 tokens (image_seq_length). So several pictures quickly eat up the context window, and the prompt text contains an <image> marker, which is replaced by these tokens.
Other kinds of data
- Audio: speech recognition models and models that understand audio input.
- Video: a sequence of frames, which produces even more tokens.
- As output: images and audio are more often created by separate models, such as diffusion models.
The idea of connecting a ready-made image encoder to a language model and fine-tuning the combination on “image — instruction” pairs is described in the LLaVA paper (Liu et al., 2023).
Sources
the term is written from these pages- Hugging Face Transformers: Image-text-to-texthuggingface.co/docs/transformers/main/en/tasks/image_text_to_text(opens in a new tab)
- Liu и др. Visual Instruction Tuning (LLaVA), arXiv:2304.08485arxiv.org/abs/2304.08485(opens in a new tab)
- Hugging Face Transformers: LLaVAhuggingface.co/docs/transformers/main/en/model_doc/llava(opens in a new tab)
Verified 18 Nov