TL;DR
Vision-language models usually train a large image-and-text network end to end, which costs a great deal of compute. BLIP-2 instead freezes a pre-trained image encoder and a pre-trained large language model, and trains only a small bridge called the Q-Former in two stages. The result is zero-shot visual question answering that beats Flamingo-80B by 8.7% on VQAv2 while using 54 times fewer trainable parameters.
Where you'll see it: the pattern of training a small adapter between a frozen vision encoder and a frozen LLM.
The problem
Vision-language pre-training teaches a model to relate pictures and text. The strong approach so far trained a whole model on large image-text datasets, end to end. That is expensive, and it wastes the knowledge already inside good single-modality models. A strong image encoder knows what objects look like. A strong language model knows how to write, reason and follow instructions.
Connecting the two is hard when both are frozen. A language model never saw images during its text-only training, so the visual input has to be translated into something it can read. Earlier frozen-model methods, such as Frozen and Flamingo, trained with an image-to-text generation loss alone. The paper argues that this loss is not enough to close the gap between the two modalities.
Key idea
BLIP-2 puts a Querying Transformer, or Q-Former, between the two frozen models. The Q-Former has 32 learnable query vectors (the details are in the Q-Former lesson). It reads image features from the frozen encoder and outputs a short sequence of 32 vectors for the language model.
Training happens in two stages. The first stage teaches the queries to extract the image information that matters for the text, using three losses. The second stage connects the output to the frozen language model, so the language model learns to read those vectors as a visual prompt.
flowchart LR
subgraph Stage1[Stage 1: representation]
IE1[Frozen image encoder] --> QF1[Q-Former] --> L1[ITC, ITG, ITM losses]
TX1[Text] --> QF1
end
subgraph Stage2[Stage 2: generation]
QF2[Q-Former] --> P[Linear projection] --> LM[Frozen LLM]
IE2[Frozen image encoder] --> QF2
end
Stage1 --> Stage2
The bottleneck is the important idea. The language model sees only 32 visual vectors, so the Q-Former has to decide what to keep, and the pre-training losses decide that choice.
The method
The model architecture and the three stage-one losses are the subject of the Q-Former lesson, so this section names only what the paper uses at the system level. The Q-Former is initialised from BERT-base, with 188M trainable parameters in total according to the paper. The frozen image encoders are CLIP ViT-L/14 and EVA-CLIP ViT-g/14, and the penultimate layer's output is used. The frozen language models are the OPT family (decoder-only, unsupervised) and the FlanT5 family (encoder-decoder, instruction-tuned).
Stage one runs 250k steps. Stage two runs 80k steps. The optimiser is AdamW with , and weight decay 0.05. The learning rate has a cosine decay from a peak of , a 2k-step linear warm-up, and a minimum of in stage two. Images are with random resized crops and horizontal flips.
Pre-training data is the BLIP dataset of 129M images. It includes COCO, Visual Genome, CC3M, CC12M, SBU and 115M images from LAION400M. Web captions are supplemented with synthetic captions from the BLIP captioner, ranked by CLIP ViT-L/14 similarity. The top two captions per image are kept, and one is sampled at each step.
The paper notes that the frozen models are converted to FP16 (BFloat16 for FlanT5) and that no performance loss was seen against 32-bit models. The largest model, ViT-g with FlanT5-XXL, takes under 6 days for stage one and under 3 days for stage two on one machine with sixteen 40GB A100 GPUs.
Results
Zero-shot VQA
Table 2 compares zero-shot VQA with the strongest prior methods. The BLIP-2 variant with ViT-g and FlanT5-XXL is listed at 65.2 (VQAv2 val) and 65.0 (VQAv2 test-dev), 45.9 on OK-VQA and 44.7 on GQA. The text says BLIP-2 is 8.7% above Flamingo-80B on zero-shot VQAv2 with 54 times fewer trainable parameters. The gap equals 65.0 minus 56.3, where 56.3 is Flamingo-80B's VQAv2 test-dev score in Table 2 (it has no val entry). On OK-VQA, Flamingo-80B (50.6) is ahead of BLIP-2 (45.9); the paper attributes this to OK-VQA's focus on world knowledge, where Flamingo's 70B Chinchilla language model knows more than the 11B FlanT5-XXL. The 54 times figure is consistent with , using Flamingo-80B's 10.2B trainable parameters and the Q-Former's 188M.
The paper's Table 1 reports BLIP-2 at 65.0 on VQAv2, with 188M trainable parameters. The same model family is listed in Table 2 with 107M to 108M trainable parameters and a VQAv2 score of 65.2. Table 1 gives the Q-Former's full 188M, and Table 2 lists 107M to 108M for the trainable parameters of the ViT-g variants. The paper does not explain the difference, so this lesson reports both as printed. Table 1's 65.0 matches the test-dev score in the Table 2 row.
What the stronger parts buy
The paper observes that a stronger image encoder and a stronger language model both raise the score. ViT-g beats ViT-L with each language model family. Larger models in the same family do better. The instruction-tuned FlanT5 beats the unsupervised OPT on VQA. This supports the claim that the method is generic: it inherits gains from whichever frozen parts are used.
Does stage one matter?
Figure 5 removes the representation-learning stage and trains only the generation stage. Zero-shot VQA drops substantially for both language model families. With OPT, performance degrades as training goes on, which the paper describes as catastrophic forgetting. Without stage one, the Q-Former has to learn the whole modality gap from the language-modelling loss alone, and that is the setting the paper argues is insufficient.
Other results
The paper also reports image captioning on NoCaps and COCO, and image-text retrieval on COCO and Flickr30K. The paper's Figure 4 shows instruction-following examples such as visual conversation and visual knowledge reasoning. These are qualitative. The lesson does not quote the captioning and retrieval numbers, because the tables were not checked line by line for this draft.
Why it mattered
BLIP-2 showed that a small trainable module can connect two frozen large models and reach strong performance at low training cost. The paper presents the recipe of a frozen vision encoder, a small bridge, and a frozen LLM as a generic and compute-efficient strategy that gains from stronger unimodal models. The paper's own limitation section names the template's weak point: the pre-training data holds one image-text pair per sample, so the model does not improve with in-context image-text examples. The authors attribute this to the data and point to interleaved image-text data as future work. The method also inherits the risks of the LLM, including offensive output, social bias and private information leaks, and the paper suggests instructions and filtered data as partial remedies.
Reading guide
Read the lessons below in this order before the paper's sections:
- Section 1, Introduction. Needs Vision Transformer (ViT) (the image encoder), Language Model (what the frozen LLM is), and Contrastive Learning (ITC is a contrastive loss).
- Section 2, Related work. Needs BERT for the Q-Former initialisation and CLIP for the frozen encoders. Skim Section 2.2 for Flamingo's Perceiver Resampler, which the paper calls similar.
- Section 3.1, Model architecture. Needs Transformer, Attention Mechanism, Multi-Head Attention and Q-Former.
- Section 3.2, Representation learning. Needs Cross-Entropy Loss and Softmax for the contrastive and generation losses, and Masked Language Modeling for the BLIP background.
- Section 3.3, Generative learning. Needs Language Model, Encoder-Decoder Architecture and T5 for the FlanT5 backbone.
- Section 4, Experiments. Needs Instruction Tuning to read the FlanT5 results and In-Context Learning for the limitation section.
Check yourself
QuestionRecall: how many trainable parameters does BLIP-2's Q-Former have, and what two frozen components does it sit between?Show answer
The paper reports 188M trainable parameters for the Q-Former. It sits between a frozen image encoder (CLIP ViT-L/14 or EVA-CLIP ViT-g/14) and a frozen language model (OPT or FlanT5).
QuestionComputation: Flamingo-80B has 10.2B trainable parameters and BLIP-2 has 188M. Roughly how many times fewer trainable parameters does BLIP-2 use?Show answer
. This matches the paper's claim of 54 times fewer trainable parameters.
QuestionWhy: why does the paper freeze the image encoder and the language model during pre-training?Show answer
Freezing keeps the knowledge already in each model and cuts the compute, since only a small module is updated. The paper also argues that freezing the LLM helps avoid catastrophic forgetting, which it observed when the LLM was trained with the generation stage alone.
QuestionApplied scenario: you want to add image understanding to a text-only LLM you cannot retrain, using a small budget. Based on this paper, what would you train, and what would you test first?Show answer
Train a small Q-Former-style bridge with a fixed number of query vectors, with the LLM and image encoder frozen. Test the representation-learning stage first, by checking whether the bridge's outputs carry text-relevant visual information. The paper's ablation suggests that skipping that stage can lead to weak zero-shot results and forgetting.
Sources
- BLIP-2: Bootstrapping Language-Image Pre-training with Frozen Image Encoders and Large Language Models (Li et al., 2023)
- BLIP: Bootstrapping Language-Image Pre-training for Unified Vision-Language Understanding and Generation (Li et al., 2022)
- Learning Transferable Visual Models From Natural Language Supervision (Radford et al., 2021)