CoCa, short for Contrastive Captioner, is an image-text foundation model that trains one network with two objectives at once: a contrastive loss that aligns image and text embeddings, as in CLIP, and a captioning loss that teaches a decoder to generate text from images. Introduced by Google Research in 2022, it is a reference architecture in Multimodal AI because it shows that retrieval-style alignment and generative captioning can share most of their computation.
Within artificial intelligence, CoCa sits between pure dual-encoder models such as CLIP and ALIGN and encoder-decoder captioners such as SimVLM. A single pretrained CoCa checkpoint supports zero-shot image classification, cross-modal retrieval, image captioning and visual question answering, either directly or after light adaptation.
How the CoCa architecture splits its text decoder
CoCa consists of an image encoder and a text decoder that is cut into two halves. The image encoder is usually a Vision Transformer that turns an image into a sequence of patch embeddings. The text decoder is a causal Transformer, but its lower layers omit cross-attention to the image, while its upper layers include cross-attention.
The lower half, called the unimodal text decoder, therefore encodes text alone and produces a text embedding from a learnable token appended at the end of the sequence. The upper half, the multimodal text decoder, reads that same representation, attends to the image features and predicts the caption token by token. This design lets one forward pass serve both objectives instead of running separate encoders.
The following table lists the main components and the role each one plays during pretraining.
| Component | Input | Output | Used by |
|---|---|---|---|
| Image encoder | Image patches | Sequence of visual features | Both losses |
| Contrastive attentional pooler | Visual features | One global image embedding | Contrastive loss |
| Generative attentional pooler | Visual features | About 256 visual tokens | Captioning loss |
| Unimodal text decoder | Caption tokens | Text embedding and hidden states | Contrastive loss |
| Multimodal text decoder | Hidden states plus visual tokens | Next-token predictions | Captioning loss |
The attentional poolers are small cross-attention layers with learnable queries. A single query summarizes the image for contrastive matching, while a larger set of queries keeps spatial detail for generation. Using task-specific poolers lets one encoder serve tasks that need very different granularity.
The two training objectives and how they combine
The total CoCa loss is a weighted sum of the contrastive and captioning losses. In the original work, the captioning term carried twice the weight of the contrastive term, which reflects the finding that generative supervision gives richer, fine-grained signals while contrastive supervision gives strong global alignment.
| Property | Contrastive loss | Captioning loss |
|---|---|---|
| Learning signal | Match each image to its own text in the batch | Predict every caption token given the image |
| Granularity | Global, whole-image level | Fine-grained, word level |
| Batch dependence | Needs very large batches | Works per example |
| Main downstream benefit | Retrieval and zero-shot classification | Captioning and question answering |
| Typical weight in CoCa | 1 | 2 |
Because the unimodal decoder layers are shared, the extra cost of adding the contrastive branch is modest. The image is encoded once and the caption is processed once, so the model avoids the doubled compute of training a separate CLIP model and a separate captioner.
How CoCa compares with related multimodal models
CoCa is best understood as a unification of earlier design families. It keeps the efficient embedding interface of dual encoders while adding the generative ability that encoder-decoder models offer. Several later systems, including the BLIP family, explore similar combinations of objectives.
| Model family | Training objective | Generates text | Fast retrieval |
|---|---|---|---|
| CLIP and ALIGN | Contrastive only | No | Yes |
| SimVLM | Captioning only | Yes | No |
| CoCa | Contrastive plus captioning | Yes | Yes |
| BLIP | Contrastive, matching and captioning | Yes | Yes |
| SigLIP | Sigmoid pairwise loss | No | Yes |
A frequent misconception is that CoCa is a multimodal large language model. It is not: its text decoder is comparatively small and is trained for captions, not for open-ended dialogue. Modern vision-language models often reuse a CoCa-style image encoder but pair it with a separate large language model through a multimodal projector.
Pretraining data and reported capabilities
The original CoCa was trained from scratch on two large corpora: the JFT-3B image dataset, whose class labels were converted to text, and the noisy alt-text image pairs used for ALIGN. The largest variant had about 2.1 billion parameters, of which roughly one billion belonged to the image encoder.
Reported results placed CoCa at the top of several benchmarks at release, including about 86 percent zero-shot top-1 accuracy on ImageNet and above 90 percent after fine-tuning. Open reimplementations, such as those trained on LAION data in the OpenCLIP library, reach lower but still competitive numbers, and the gap shows how strongly data scale and quality shape the outcome.
- Zero-shot classification: compare the image embedding with embeddings of class-name prompts.
- Image-text retrieval: index image embeddings and search with text embeddings, or the reverse.
- Captioning: decode text autoregressively from the multimodal decoder.
- Frozen-feature transfer: train only a light attentional pooler on top of the encoder for video or image tasks.
Limitations and practical cautions
CoCa inherits the weaknesses of web-scale image-text data: social biases, uneven language coverage and noisy captions that can produce multimodal hallucination in generated descriptions. The contrastive branch also requires very large batch sizes and many accelerators to train well, which limits independent replication.
Practitioners should also note that the contrastive embedding and the caption decoder do not always agree. A model may retrieve the correct image while generating a caption that misses a detail, so systems that combine both outputs need separate evaluation for each task.
| Pitfall | Cause | Mitigation |
|---|---|---|
| Poor zero-shot accuracy | Prompts differ from training captions | Use prompt ensembles of class names |
| Generic captions | Short, noisy alt-text in pretraining | Fine-tune on curated caption data |
| Unstable contrastive training | Small batches give weak negatives | Increase batch size or use gradient caching |
| Unexpected bias | Skewed web data | Audit outputs on targeted test sets |
A plain-language summary
CoCa is a computer model that learns to see and describe pictures. It studies millions of images that come with short texts. It learns two skills at the same time.
The first skill is matching. Given a picture, it can find the right sentence, or the other way around. The second skill is describing. It can write a short caption for a new picture.
Think of a student who learns flash cards and also writes short essays about the same cards. Doing both makes each skill stronger, and the student does not need to study the cards twice.
An example from practice
A museum with a digital archive of 400,000 photographs wants visitors to search its collection with ordinary phrases such as “harbor at sunset with sailing boats”. Most photographs have only a catalog number and a date, so keyword search fails.
The archive team runs an open CoCa checkpoint over every photograph once. They store the image embeddings in a vector index for text search and also save a generated draft caption for each item. Curators then review the drafts in batches and correct names, places and dates that the model cannot know.
Within a few months, visitors can find relevant images by description, and curators spend their time verifying captions instead of writing them from nothing. The team keeps a rule that every published caption is checked by a person, because the model sometimes invents details that are not in the photograph.