Search

Search papers and lessons

LLaVA-OneVision: Easy Visual Task Transfer

Bo Li, Yuanhan Zhang, Dong Guo et al. · 2024

LLaVA-OneVision is a family of open vision-language models, from 0.5B to 72B parameters, trained in stages so that single-image skills transfer to multi-image and video tasks.

On this page

  • Colour = topic mix
  • Neural network basics
  • Calculus
  • Discrete math
  • Linear algebra
  • Probability
  • Architectures
  • ReadReady to readNot yet

TL;DR

LLaVA-OneVision is a family of open large multimodal models, with 0.5, 7 and 72 billion parameters, that handle single images, sets of several images and video in one model. The model connects a vision encoder to a language model with a small projector, then trains it in stages. The main idea is that a model trained well on single images can be extended with a short stage of mixed images and video, and it then gains video understanding by transfer. The 72 billion parameter version scores above GPT-4V on many single-image benchmarks, although it stays below GPT-4o on several of them.

Builds on: Visual Instruction Tuning, Sigmoid Loss for Language Image Pre-Training · Leads to: Vision-Language Model

Why it mattered

The paper is a recipe as much as a model. Its authors show that one open model can be competitive across three settings that earlier open models usually handled one at a time: single images, multi-image inputs and video. The paper's results table compares the 0.5B, 7B and 72B models with GPT-4V and GPT-4o on single-image, multi-image and video benchmarks. The authors note that LLaVA-NeXT-Interleave was, to their knowledge, the first open attempt to report good results in all three settings, and that LLaVA-OneVision inherits its training recipe and data.

The paper also reports a concrete form of transfer. Its single-image stage contains no video, yet the final model reports strong video scores after a second stage of 1.6 million mixed image, multi-image and video samples. The authors name this task transfer and treat it as the source of the new capabilities they describe.

The problem

A vision-language model has to match two inputs: the pixels of an image, and the words of a question. Its language part is already a trained Language Model, and its vision part is already a trained image encoder. The difficult step is to connect them so that the language model can use visual detail, without losing what it already knows.

Three things make this harder than it looks. First, the amount of visual detail is set by how the image is turned into tokens, and more tokens cost more compute. Second, the training data is unevenly spread: there are many high-quality single-image instruction sets and far fewer video or multi-image sets. Third, a model that is tuned for one setting can lose ability in another. The paper's question is how to reach good performance in all three settings with a fixed compute budget.

How it works

Take one small example. Suppose a vision encoder turns each image crop into 4 tokens (a toy number; the real value is 729), and the model is asked a question about an image split into a 2 by 1 grid of crops. The paper's AnyRes scheme adds a resized copy of the whole image to the crops, so there are 3 pieces in total.

flowchart LR
  A["Image"] --> B["AnyRes: base image plus 2 by 1 crops"]
  B --> C["SigLIP vision encoder"]
  C --> D["2-layer MLP projector"]
  D --> E["Visual tokens"]
  F["Text question"] --> G["Qwen-2 language model"]
  E --> G
  G --> H["Answer, one token at a time"]
  1. Split the image into pieces. The base image is resized to one crop. The grid is 2 by 1, which gives two more crops. In total there are 3 pieces. Check: a grid of a by b crops plus the base image gives a times b plus 1 pieces.

  2. Encode each piece. The SigLIP vision encoder turns each piece into a grid of features. With the toy value, each piece gives 4 features. Check: 3 pieces with 4 features each give 12 visual features in total.

  3. Project the features into the language model's word space. A 2-layer MLP maps each feature to a vector of the same size as a word embedding. These vectors are the visual tokens. There are still 12 of them. Check: the projector changes the size of each vector but not the number of tokens.

  4. Put the visual tokens and the text tokens in one sequence. The question is written as text after the visual tokens, and the language model reads the whole sequence. Check: the model sees the image as ordinary input tokens, so it can attend to them like words.

  5. Generate the answer. The language model predicts one answer token at a time. Each prediction depends on the visual tokens, the question and the answer so far. Check: the probability of the whole answer is the product of the probabilities of its tokens.

Real values follow the same steps. The paper uses 729 features per 384 by 384 crop, and it limits the total number of visual tokens by a budget that depends on the training stage.

Worked examples

Example
1. Counting tokens for one crop

A vision encoder gives T=4T = 4 tokens per crop. The image is a 1 by 1 grid, so a=1a = 1 and b=1b = 1.

  1. Number of pieces: a×b+1=1×1+1=2a \times b + 1 = 1 \times 1 + 1 = 2. There is one crop and the base image.
  2. Total tokens: L=2×4=8L = 2 \times 4 = 8.
  3. Check against a budget: if τ=10\tau = 10, then L=8≤10L = 8 \leq 10, so no reduction is applied.

Interpretation: a 1 by 1 grid with the base image gives twice the tokens of a single crop, because the base image is always included.

Example
2. The standard case, with the stage budgets

Use the paper's full-size tokens: T=729T = 729 per 384 by 384 crop. Stage 1.5 allows at most 5×729=36455 \times 729 = 3645 visual tokens. Stage 2 allows at most 10×729=729010 \times 729 = 7290 tokens.

  1. Take a 2 by 2 grid. Then a×b+1=5a \times b + 1 = 5, so L=5×729=3645L = 5 \times 729 = 3645.
  2. Compare with the stage 1.5 budget: 3645≤36453645 \leq 3645, so the 2 by 2 grid fits without reduction.
  3. Take a 3 by 3 grid. Then a×b+1=10a \times b + 1 = 10, so L=10×729=7290L = 10 \times 729 = 7290.
  4. Compare with the stage 2 budget: 7290≤72907290 \leq 7290, so it also fits.
  5. Take a 4 by 4 grid. Then a×b+1=17a \times b + 1 = 17, so L=17×729=12393L = 17 \times 729 = 12393, which is above 7290. The tokens per crop must be reduced to Tnew=7290/17=428.8T_{\text{new}} = 7290/17 = 428.8 before the grid is used.

Interpretation: the stage budgets set how large a grid the model may use, and the largest grids are compressed rather than dropped.

Example
3. A realistic video case, reasoned from the paper

In the OneVision stage, each video frame is resized to the base resolution and gives 729 tokens. The paper applies 2×22 \times 2 bilinear interpolation to each frame, which gives 196 tokens per frame, and samples up to 32 frames per video. Take the stage-2 budget of 7290 tokens.

  1. Without reduction, each frame costs 729 tokens, so 7290/729=107290 / 729 = 10 frames fit.
  2. With the reduction, each frame costs 196 tokens. The paper's cap is 32 frames, so the video costs 32×196=627232 \times 196 = 6272 tokens.
  3. Check: 6272≤72906272 \leq 7290, so the 32 frames fit in the budget with room to spare.
  4. Ratio: 32/10=3.232 / 10 = 3.2 times as many frames can be included after the reduction.

Try it: to fit 32 frames into the same 7290 budget, how many tokens can each frame keep? Answer: 7290/32≈2277290 / 32 \approx 227 tokens per frame, so the 196-token reduction fits comfortably.

Interpretation: reducing tokens per frame lets the model see more frames of a video in the same budget. The paper says that empirical evidence suggests this gives a better trade-off between performance and computational cost.

The math

The model is a language model conditioned on visual tokens. Write Xv\mathbf{X}_v for the image input, Xq\mathbf{X}_q for the question tokens and Xa\mathbf{X}_a for the answer tokens, which has length NN. The probability of the answer is

p(Xa∣Xv,Xq)=∏i=1Np(xi∣Xv,Xq,<i,Xa,<i),p(\mathbf{X}_a \mid \mathbf{X}_v, \mathbf{X}_q) = \prod_{i=1}^{N} p(x_i \mid \mathbf{X}_v, \mathbf{X}_{q,<i}, \mathbf{X}_{a,<i}),

where xix_i is the answer token being predicted, and Xq,<i\mathbf{X}_{q,<i} and Xa,<i\mathbf{X}_{a,<i} are the question and answer tokens that come before it. The visual input appears in every factor, so the visual signal is available for every answer token.

Step 1 in symbols: the token count of AnyRes

For a grid of aa columns and bb rows, the image gives a×ba \times b crops, each with TT tokens, plus the base image. The total is

L=(a×b+1)×T.L = (a \times b + 1) \times T.

For the toy example, a=2a = 2, b=1b = 1 and T=4T = 4, so L=3×4=12L = 3 \times 4 = 12. With T=729T = 729 and a 2 by 2 grid, L=5×729=3645L = 5 \times 729 = 3645.

If LL would exceed a budget τ\tau, the paper lowers the tokens per crop with bilinear interpolation:

Tnew={τa×b+1if L>τ,Tif L≤τ.T_{\text{new}} = \begin{cases} \dfrac{\tau}{a \times b + 1} & \text{if } L \gt \tau, \\ T & \text{if } L \leq \tau. \end{cases}
12345678902000400060008000number of crops in the grid, a times bvisual tokens
  • visual tokens with no reduction
  • stage-2 budget, 10 times 729
Here x is the number of crops, a times b. The base image always adds one more 729-token piece, so the curve is 729 times x plus 729. The marked point is a 2 by 2 grid, which gives 3645 tokens.

Step 2 in symbols: the vision encoder

The encoder gg maps an image to features Zv=g(Xv)\mathbf{Z}_v = g(\mathbf{X}_v). The projector pp maps them to visual tokens Hv=p(Zv)\mathbf{H}_v = p(\mathbf{Z}_v). The projector is a 2-layer MLP. The features are the grid outputs of the encoder, taken before or after its last Transformer layer.

Step 3 in symbols: the projector

The MLP is a function pp that acts on each feature vector separately. It changes the vector size to match the language model's word embeddings, so each feature becomes one visual token of the same size as a word.

Step 5 in symbols: the answer probability

Each factor in the product is the probability that the language model assigns to the next answer token. The product of these probabilities is the probability of the whole answer, which the training loss uses.

Results

The paper reports 0-shot accuracy with greedy decoding, using the LMMs-Eval evaluation suite, and it takes most baseline numbers from the original papers. The main comparisons below are copied from its Table 2.

  • Single-image, 72B against GPT-4V and GPT-4o. On AI2D the 72B model scores 85.6, against 78.2 for GPT-4V and 94.2 for GPT-4o. On DocVQA (test) it scores 91.3, against 88.4 and 92.8. On ChartQA it scores 83.7, against 78.5 (GPT-4V was reported with 4-shot prompts on this benchmark) and 85.7. On MathVista (testmini) it scores 67.5, against 49.9 and 63.8.
  • Multi-image. On Mantis the 72B model scores 77.6, against 62.7 for GPT-4V. On MuirBench it scores 54.8, below GPT-4V at 62.3. The paper does not report a GPT-4o value on these multi-image rows.
  • Video. On VideoMME the 72B model scores 66.2, against 59.9 for GPT-4V and 71.9 for GPT-4o. On MVBench it scores 59.4, against 43.5 for GPT-4V.
  • Smaller models. The 7B model scores 81.4 on AI2D, 87.5 on DocVQA and 48.8 on MMMU. The 0.5B model scores 57.1 on AI2D and 44.0 on VideoMME.

The limits are stated by the authors. Benchmarks marked with a dagger in their table had training sets in the model's data mixture; these include AI2D, ChartQA, DocVQA, InfoVQA, ScienceQA and text-rich VQA, so their scores are not held-out tests. On real-world chat the numbers show a gap: on LLaVA-Wilder (small), the 72B model scores 72.0, against 81.0 for GPT-4V and 85.9 for GPT-4o. The development experiments were run within a fixed compute budget and aimed at useful insights rather than at pushing performance limits.

Reading guide

Check yourself

QuestionRecall: what are the three kinds of input that the model handles, and which training stage first brings in video?Show answer

The model handles single images, multi-image sets and video. Video is first introduced in the OneVision stage, which trains on a mixture of video, multi-image and single-image data after the single-image stage.

QuestionComputation: a vision encoder gives 729 tokens per crop. The image is split into a 3 by 2 grid. How many visual tokens does AnyRes produce without reduction, and does the total fit the stage-2 budget of 7290?Show answer

The grid has a×b=6a \times b = 6 crops, so the number of pieces is 6+1=76 + 1 = 7. The total is L=7×729=5103L = 7 \times 729 = 5103. Since 5103≤72905103 \leq 7290, no reduction is needed, and the total fits the stage-2 budget.

QuestionWhy: why does the paper spend more visual tokens on single images than on video frames during training?Show answer

The paper says that there are many more high-quality single-image instruction samples than video or multi-image samples. A long token sequence for each image also makes the image look like a video to the model, which the authors say gives a smoother transfer from image to video understanding. Using many tokens per image is therefore a choice made for transfer as well as for detail.

QuestionApplied: a team wants to use the OneVision recipe on a small budget. They want the model to see many video frames, but they cannot afford 729 tokens per frame. What does the paper suggest, and what is the trade-off?Show answer

The paper suggests reducing the tokens per frame with bilinear interpolation, so that more frames fit in the same token budget. The trade-off is that each frame carries less visual detail. The paper says that empirical evidence suggests this gives a better balance of performance and cost than keeping full detail with fewer frames, but it is a trade-off, not a free gain.

Sources

Read the full paper

Bo Li, Yuanhan Zhang, Dong Guo et al., 2024. arXiv:2408.03326