All models

BEiT-3

One Transformer for pictures and text: shared attention, separate experts per modality, trained by masking both.

Multimodal · 1,088 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 (15 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

Parameters
221M
Operations
1,088
Framework
PyTorch
Recurrent
No
Published
CVPR 2023
Cited by
147 (as of 4 October 2026)
Authors
Wenhui Wang, Hangbo Bao, Li Dong 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
m14343
Graph hash
0fe0b909361e4ee6aeb840da3c7096de47ae10338761db58a9edf8aeb7b0addd
Skeleton hash
b58dc8486faeb967e32c1f8e0a15e97eaba0fbed5146f6a935de5d030bc78179
Architecture hash
bc368710f6974f2d7a816130b14b57b8b8e32a533e16f237590549b931ef6c38
Diagram SHA-256
8578176f10f8b6068c46011a56eebc854d3a2e0a8b2225e8b0d692220e3bf7f8
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

This is the full Multiway Transformer with its shared self-attention and vision and language experts, returning token features rather than class logits.

BEiT-3 is a general-purpose multimodal foundation model that reaches state-of-the-art transfer performance on both vision and vision-language tasks. The paper frames it as part of a big convergence of language, vision and multimodal pretraining, advanced from three aspects: backbone architecture, pretraining task, and model scaling up. The title's idea is to treat an image as a foreign language, so images, texts and image-text pairs are all handled by masked language modeling on Imglish, English and parallel sentences in a unified manner.

The backbone is the Multiway Transformer: each block has a shared self-attention module and a pool of feed-forward networks, the modality experts, with each input token routed to the expert for its modality. Each layer contains a vision expert and a language expert, and the top three layers add vision-language experts designed for fusion encoders. The shared self-attention learns the alignment between modalities and enables deep fusion for vision-language tasks. Pretraining is a unified masked data modeling objective: some percentage of text tokens or image patches is masked and the model is trained to recover the masked tokens. Text is tokenized by a SentencePiece tokenizer and images by the BEiT v2 tokenizer, which supplies discrete visual tokens as the reconstruction targets.

The paper's model is giant-size: a 40-layer Multiway Transformer with 1408 hidden size, 6144 intermediate size and 16 attention heads. It has 1.9B parameters in total, including 692M for vision experts, 692M for language experts, 52M for vision-language experts and 317M for the shared self-attention module. Only the vision-related parameters, about 1B, are activated when the model is used as a vision encoder. The timm members captured here are image-only classification towers converted for vision-only tasks, pretrained on ImageNet-22k images, 160GB of text documents and web-scale image-text pairs with masked data modeling, then fine-tuned on ImageNet-22k and ImageNet-1k. The full Multiway member is built with TorchScale, a PyTorch library for scaling up Transformers efficiently and effectively. Reported results are state-of-the-art on object detection (COCO), semantic segmentation (ADE20K), image classification (ImageNet), visual reasoning (NLVR2), visual question answering (VQAv2), image captioning (COCO), and cross-modal retrieval (Flickr30K, COCO).

Key idea. A single Multiway Transformer backbone, shared self-attention plus per-modality feed-forward experts, pretrained by one masked data modeling objective on images, texts and image-text pairs, and scaled to 1.9B parameters.

  • BEiT-3
  • beit3
  • Image as a Foreign Language
  • Multiway Transformer
  • beit3_base_patch16_224
  • beit3_large_patch16_224
  • beit3_giant_patch14_224
  • beit3_giant_patch14_336
  • masked data modeling
  • Imglish
  • vision-language foundation model
  • unilm beit3
  • torchscale
  • timm

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

Cite the paper

@misc{wang2022imageforeignlanguagebeit,
      title={Image as a Foreign Language: BEiT Pretraining for All Vision and Vision-Language Tasks}, 
      author={Wenhui Wang and Hangbo Bao and Li Dong and Johan Bjorck and Zhiliang Peng and Qiang Liu and Kriti Aggarwal and Owais Khan Mohammed and Saksham Singhal and Subhojit Som and Furu Wei},
      year={2022},
      eprint={2208.10442},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2208.10442}, 
}