ClipCap
An image captioner that maps a CLIP image encoding into a prefix from which GPT-2 generates the caption.
Multimodal · 549 operations Checked
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
- Task
- Multimodal
- Parameters
- 155.9M
- Operations
- 549
- Framework
- PyTorch
- Recurrent
- No
- Published
- 2021, arXiv preprint
- Cited by
- 353 (as of 26 October 2026)
- Authors
- Ron Mokady, Amir Hertz, Amit H. Bermano
- License
- MIT
- Checked
- Passed: the trace was replayed operation by operation and matched the model's own output for this input.
Files
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
Details
- Stable ID
- m15319
- Graph hash
- 02aa7e2bb0074e2df0f4c91b3ca54add7cf770a74e188b17e14b874e3966aeb7
- Skeleton hash
- ad6fe89dfd14220570886c7cf29d9b0d2f04e348d5dffc1b5b872efc84ba4069
- Architecture hash
- eff57470dfd5ac16e600cf9091b615f90d918333e5a6fe048242049f94701093
- Diagram SHA-256
- 2638762f112c85e89d6799c38ee59e6c53cd2539564b4080fd3298be02e20368
- 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
ClipCap is an image captioning model, where the model predicts a textual caption for a given input image. Its approach is to use the CLIP encoding of the image as a prefix to the caption, produced by a simple mapping network, and to have a language model generate the caption from it. The language model is GPT-2.
The mapping network is the key component, and it translates the CLIP embedding to the GPT-2 space. The prefix it produces is a fixed size sequence of embeddings, concatenated to the caption embeddings. At inference the language model generates the caption word after word, starting from the CLIP prefix. The paper describes two versions. When the language model is fine-tuned along with the mapping network, a simple Multi-Layer Perceptron (MLP) is used. When the language model is frozen, the paper proposes the more expressive transformer architecture for the mapping network. This model is the MLP version, for which the paper used a prefix length of K = 10 and a single hidden layer.
The paper's motivation is training cost, and it reports training on a single Nvidia GTX1080 GPU for 80 hours over the three million samples of the Conceptual Captions dataset. It reports results comparable to the leading approaches of the time on Conceptual Captions and nocaps, and marginally lower on COCO. The paper says its attempt to adjust a frozen language model is inspired by the work of Li and Liang, who learn only a prefix.
Key idea. ClipCap turns a CLIP image encoding into a prefix through a simple mapping network, and a pre-trained language model, GPT-2, generates the caption from that prefix.
- clipcap
- clip prefix captioning
- clip prefix for image captioning
- clip_prefix_caption
- image captioning
- prefix captioning
- mapping network
- caption generation
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@misc{mokady2021clipcapclipprefiximage,
title={ClipCap: CLIP Prefix for Image Captioning},
author={Ron Mokady and Amir Hertz and Amit H. Bermano},
year={2021},
eprint={2111.09734},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2111.09734},
}