All models

CoCa

An image-text encoder-decoder trained with contrastive and captioning losses in a single forward pass.

Multimodal · 990 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (74 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Family
CoCa
Parameters
133.4M
Operations
990
Framework
PyTorch
Recurrent
No
Published
Transactions on Machine Learning Research (arXiv 2022)
Cited by
576 (as of 19 October 2026)
Authors
Jiahui Yu, Zirui Wang, Vijay Vasudevan and others
License
MIT
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m15331
Graph hash
806826ee6b6b37c2f123cf084b755c1373b5cffc9a352651554d748174a240bd
Skeleton hash
39fdbe5d260e562d842c73fad26e84cc08968c2f3eaa37d3323ba2b0281b395a
Architecture hash
f1716bfef2e509c56e5275393f29d98ccdaa8a9dcf0cb05b43c9cab3eb0f8eb7
Diagram SHA-256
3e78910ae7fe2c82b0c92bc9b8ec9cae1792f0f00d96acee3a3204f20ff32ad4
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

The CoCa-pytorch build by lucidrains uses parallel SwiGLU feedforwards for both the unimodal and multimodal transformers as well as the cross attention blocks. Its configuration uses 20000 text tokens.

About this model's family

CoCa, the Contrastive Captioner, is an image-text encoder-decoder foundation model pretrained jointly with a contrastive loss and a captioning loss, so one network subsumes the abilities of contrastive models like CLIP and generative ones like SimVLM.

The text decoder is split in two: the first half of its layers omit cross-attention and encode text alone, while the remaining layers cross-attend to the image encoder for multimodal representations. A contrastive loss is applied between the image embedding and the unimodal text embedding, and a captioning loss on the multimodal decoder's autoregressive token predictions. Because the two objectives share one computational graph, both are computed with minimal overhead. Attentional poolers adapt the image features to each objective, with 256 queries for the generative loss and a single query for the contrastive loss. Following ALIGN, images are encoded at 288×288 resolution with 18×18 patches, giving 256 image tokens.

The paper's largest model follows a ViT-giant setup with 1B parameters in the image encoder and 2.1B altogether with the text decoder. On ImageNet classification the paper reports 86.3% zero-shot top-1 accuracy, 90.6% with a frozen encoder and learned classification head, and 91.0% with a finetuned encoder. The coca_base build here is one of the CoCa configs listed by the open_clip library, alongside coca_ViT-B-32 and coca_roberta-ViT-B-32.

Key idea. CoCa pretrains one image-text encoder-decoder jointly with contrastive and captioning losses, subsuming the capabilities of contrastive models like CLIP and generative models like SimVLM.

  • coca
  • contrastive captioner
  • contrastive captioners
  • image-text foundation model
  • open_clip coca
  • coca_base
  • image captioning
  • zero-shot classification
  • vision-language
  • multimodal

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{yu2022cocacontrastivecaptionersimagetext,
      title={CoCa: Contrastive Captioners are Image-Text Foundation Models}, 
      author={Jiahui Yu and Zirui Wang and Vijay Vasudevan and Legg Yeung and Mojtaba Seyedhosseini and Yonghui Wu},
      year={2022},
      eprint={2205.01917},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2205.01917}, 
}