Search

Search papers and lessons

Improved Baselines with Visual Instruction Tuning

Haotian Liu, Chunyuan Li, Yuheng Li et al. · 2023

LLaVA-1.5 swaps LLaVA's linear image connector for a two-layer MLP and adds short-answer VQA data, reaching state of the art on 11 benchmarks with public data and one day of training on 8 A100s.

On this page

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

TL;DR

LLaVA-1.5 shows that a small change to the original LLaVA recipe gives a much stronger open model. Replacing LLaVA's single linear layer with a two-layer MLP, adding academic VQA data with a short-answer instruction, and using a higher-resolution image encoder raise the score on 11 benchmarks, and the 13B model trains in about a day on one 8-A100 node using public data. The paper's main point is that the simple design was never the bottleneck.

Builds on: Visual Instruction Tuning (LLaVA), Learning Transferable Visual Models From Natural Language Supervision (CLIP), Vision Transformer (ViT), Instruction Tuning, Language Model · Leads to: Vision-Language Model (the family whose recipes it changed)

Why it mattered

Large multimodal models answer questions about pictures. Before this paper, the strongest results came from systems with elaborate parts, such as the learned query module (Q-Former) in InstructBLIP. LLaVA-1.5 reached state-of-the-art on a broad set of benchmarks with publicly available data, and its best 13B model used about 1.2 million training examples across its two stages. The 13B model trains in about one day on a single node of 8 A100 GPUs. That made a strong vision-language baseline something a university lab could train and reproduce, which is why later open work uses it as a reference point.

The paper also showed how to scale the same design to larger images, by cutting a high-resolution picture into grid tiles.

The problem

Before this work, two lines of models disagreed on what worked. LLaVA was simple: one linear layer maps image features into the language model's input space, and the language model is tuned on visual instructions. Its weakness was academic benchmarks, which expect short answers, because its training data rarely asked for them. InstructBLIP used academic VQA data and a learned query module, and it did well on those benchmarks, but it did less well on open visual conversation.

The paper asks which difference is responsible. It suspects the amount of data, the presence of the query module, or the instruction format. Its answer is that the query module is not needed and the format matters more.

How it works

The walkthrough follows one training example through the system, then the changes that the paper adds.

  1. Input. An image and a question, such as a picture of a bus and the question "What color is the bus?" The image is resized to a fixed square size.
  2. Image encoder. A CLIP vision transformer (ViT-L) cuts the image into patches and returns one feature vector per patch. The 336-pixel version gives a 24 by 24 grid of patch features. Check: 336 divided by 14 is 24, and the patch size is 14 pixels for this encoder.
  3. Connector. The patch features pass through a connector that maps each one into the language model's embedding space. LLaVA used one linear layer. LLaVA-1.5 uses a two-layer MLP with a nonlinearity in between. This is the first change.
  4. Prompt assembly. The projected image tokens are placed in the prompt together with the question text. The question carries the response format instruction, for example "Answer the question using a single word or phrase." This is the second change, and it is applied only to the academic VQA examples.
  5. Language model. Vicuna-v1.5, a language model fine-tuned from LLaMA 2, reads the whole sequence and predicts the answer one token at a time, as in any Language Model.
  6. Training. Two stages. In pretraining, only the connector is trained on image-caption pairs, so the image tokens learn to look like words. In instruction tuning, the language model and the connector are trained on the mixture of visual instructions and academic data, while the image encoder stays frozen, so the model learns to follow formats.
  7. Output. The model writes "Blue" for the bus question, and for the longer prompt it writes a paragraph. The format instruction decides which.

The third change is resolution: the paper raises the image size from 224 to 336 pixels. Its high-resolution variant, LLaVA-1.5-HD, divides a larger image into 336-pixel tiles, encodes each tile, and adds a downsampled whole image so the model keeps a global view.

flowchart LR
  A["Image"] --> B["CLIP ViT-L encoder: patch features"]
  B --> C["Two-layer MLP connector"]
  C --> D["Image tokens in the prompt"]
  E["Question plus format instruction"] --> D
  D --> F["Vicuna-v1.5 language model"]
  F --> G["Answer, short or long"]

The math

The paper does not write out its MLP. In the notation used here, let XvX_v be the patch features from the encoder, one row per patch. The connector is a two-layer MLP applied to each row:

Hv=σ(XvW1+b1) W2+b2,H_v = \sigma(X_v W_1 + b_1) \, W_2 + b_2,

where W1W_1 and W2W_2 are learned matrices, b1b_1 and b2b_2 are bias rows added to every patch, and σ\sigma is a nonlinear activation applied entry by entry. The rows of HvH_v are the image tokens that the language model reads. The linear baseline has no σ\sigma and only one layer, so it is one matrix WW with Hv=XvW+bH_v = X_v W + b, applied to each patch.

The response format step has no formula. It appends a fixed string to the question, so the training objective is the same next-token loss as in the rest of instruction tuning, with the format string in the input. The MLP has more parameters than the single layer it replaces, so the training recipe must be checked again with the new connector.

Results

The main evidence is an ablation that adds one change at a time to LLaVA, measured on three benchmarks: GQA (short-answer visual knowledge), MME (a perception and cognition score), and MM-Vet (open visual conversation, graded with GPT-4). Some values from the paper's Table 2, for the 7B model at 224 pixels:

SettingGQAMMEMM-Vet
LLaVAnot reported809.625.5
+ VQA-v2 data47.01197.027.7
+ response format prompt46.81323.826.3
+ MLP connector47.31355.227.8

Adding the MLP connector improves MME from 1323.8 to 1355.2 and MM-Vet from 26.3 to 27.8. The format prompt helps MME a lot but lowers MM-Vet in this row, which the paper does not hide. The later rows add OCR and region data, the 336-pixel encoder, GQA, ShareGPT conversations and the 13B model. The final 13B row reaches GQA 63.3, MME 1531.3 and MM-Vet 36.1.

On Table 3, the 13B model at 336 pixels scores 80.0 on VQAv2, 63.3 on GQA, 53.6 on VizWiz, 71.6 on ScienceQA-IMG and 61.3 on TextVQA, using 558K pretraining and 665K instruction examples. The HD variant at 448 pixels scores 81.8, 64.7, 57.5, 71.0 and 62.5. These are the paper's figures, and because the benchmarks differ in training data and prompts, direct comparison with other systems is weaker than the tables suggest.

Limits. The paper reports that subsampling the mixture to 50 percent keeps more than 98 percent of the full dataset's performance, so the mixture still matters at the margin. The model is weak on multiple-image input, on long-form problem solving, and on very high resolutions that cost long training runs. Benchmarks are a proxy: the paper reports strong scores on hallucination tests, but the scores depend on the fixed prompts and the decoding setup, which may differ from a real user's GPT-4-graded chat.

Reading guide

  1. Abstract and Section 1. Read these for the claim: the simple connector is strong, and the data format is the real lever.
  2. Section 2, Related Work. Needs Vision Transformer (ViT) (the encoder) and Instruction Tuning (what the second stage does).
  3. Section 3.1, Preliminaries. Compare the linear LLaVA design with InstructBLIP's query module. Needs Visual Instruction Tuning (LLaVA) and Learning Transferable Visual Models From Natural Language Supervision (CLIP).
  4. Section 3.2, Response Format Prompting. Read Table 1 and Table 2 side by side. Needs Instruction Tuning.
  5. Section 3.3, Scaling. The MLP connector, the academic data, resolution and the 13B model. Needs Feedforward Neural Network for the MLP and Language Model for the LLM.
  6. Section 3.4 and Appendix A.1, High resolution. The tiling method; read this only after 3.3.
  7. Sections 4 and 5. Benchmarks and open problems. Needs no new prerequisites beyond the above.

Check yourself

QuestionRecall: what did LLaVA-1.5 change in the connector compared with LLaVA?Show answer

It replaced the single linear layer that maps image patch features into the language model's input space with a two-layer MLP with a nonlinearity between the layers. In the paper's ablation, this change gave a gain on top of the other changes.

QuestionCompute: a 336-pixel image with a patch size of 14 pixels gives how many patch features in a square grid, and how many in total?Show answer

336/14=24336 / 14 = 24, so the grid is 24 by 24. The total is 24×24=57624 \times 24 = 576 patch features, each one a row that the connector maps into the language model's space.

QuestionWhy does the paper argue the response format prompt matters, rather than just the amount of VQA data?Show answer

Adding VQA data alone teaches the model short answers but not when to use them. A fixed format instruction appended to the question lets the model choose the output length from the request, so the answer does not need post-processing.

QuestionApplied: a team has a budget for one training run and wants a strong open multimodal model for a question-answering product where answers must be short. Which of the paper's changes should they copy first, and why?Show answer

They should copy the MLP connector and the academic VQA data with the single-phrase format instruction. The connector is a small change, and the paper shows it helps. The format instruction is what gives short answers on demand. The high-resolution encoder and the 13B model cost more compute per run, so they can come later once the cheap changes are in.

Sources

Read the full paper

Haotian Liu, Chunyuan Li, Yuheng Li et al., 2023. arXiv:2310.03744