Meshed-Memory Transformer (M2 Transformer)
A Transformer for image captioning with memory-augmented encoding and meshed encoder-decoder attention.
Multimodal · 499 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
- 38.4M
- Operations
- 499
- Framework
- PyTorch
- Recurrent
- No
- Published
- CVPR 2020
- Cited by
- 1,258 (as of 27 October 2026)
- Authors
- Marcella Cornia, Matteo Stefanini, Lorenzo Baraldi, Rita Cucchiara
- License
- BSD-3-Clause
- 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
- m18412
- Graph hash
- 722e50070e0f1aa8dff44750b124ff9db9e75116eed4f8dcaa8c45bde3a29089
- Skeleton hash
- 043f6a4e519b8820437963b7888c3d16706150a636c2c8a3462641efbd374a2a
- Architecture hash
- 5a98d49791454719121171970737943fcd77f074d272c1e91d3a67560b3304ad
- Diagram SHA-256
- 5176c9f3a65f7f9b8a7a945f0b326dfc94e0f029628964285e252ab3d0291d67
- 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 Meshed-Memory Transformer, or M2 Transformer, is an image captioning model in which every interaction between words and image features is modeled with attention, without recurrence. It does not take pixels as input: image regions are represented by 2048-dimensional feature vectors from Faster R-CNN with ResNet-101. At most 50 region vectors are used per image.
The design takes inspiration from the Transformer model for machine translation. In the encoder, the keys and values of self-attention are extended with additional vectors, implemented as plain learnable vectors that are updated directly by SGD. These extra slots can encode a priori information. In the decoder, each layer performs cross-attention with all encoding layers instead of only the last one. The contributions from the different encoding layers are modulated and then summed. Because this creates a mesh of connections between encoder and decoder layers, the authors named the model Meshed-Memory Transformer.
The paper found the best performance with three encoding and three decoding layers. Training begins with a word-level cross-entropy loss and continues with reinforcement learning to fine-tune sequence generation. In the paper's single-model comparison, the model's CIDEr score was 1.4 points above the best earlier result. Its ablation found that removing the memory vectors lowered performance by around 1 CIDEr point.
Key idea. The M2 Transformer learns a multi-level representation of relationships between image regions with learned a priori knowledge and decodes through mesh-like connections to low- and high-level features.
- Meshed-Memory Transformer
- M2 Transformer
- M^2 Transformer
- meshed memory
- image captioning
- captioning transformer
- COCO captioning
- memory-augmented attention
- meshed decoder
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@misc{cornia2020meshedmemorytransformerimagecaptioning,
title={Meshed-Memory Transformer for Image Captioning},
author={Marcella Cornia and Matteo Stefanini and Lorenzo Baraldi and Rita Cucchiara},
year={2020},
eprint={1912.08226},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/1912.08226},
}