{"notes":[{"id":"multimodality/beit-v3","category":"multimodality","legacyPath":"multimodality/2208-beit-v3","legacySlug":"2208-beit-v3","legacyPaths":[],"title":"BEiT-3","subtitle":"Great Minds Think Alike","author":"Z. Yuan","paperDate":"2022-08-22","publishedOn":"2024-12-31","paperTitle":"Image as a Foreign Language: BEiT Pretraining for All Vision and Vision-Language Tasks","paperUrl":"https://arxiv.org/abs/2208.10442","bibliography":{"title":"Image as a Foreign Language: BEiT Pretraining for All Vision and Vision-Language Tasks","authors":["Wenhui Wang","Hangbo Bao","Li Dong","Johan Bjorck","Zhiliang Peng","Qiang Liu","Kriti Aggarwal","Owais Khan Mohammed","Saksham Singhal","Subhojit Som","Furu Wei"],"url":"https://arxiv.org/abs/2208.10442","pdfUrl":"https://arxiv.org/pdf/2208.10442v2","codeUrl":"https://github.com/microsoft/unilm/tree/master/beit3","preprint":{"id":"2208.10442","submittedOn":"2022-08-22","url":"https://arxiv.org/abs/2208.10442"},"publication":{"venue":"CVPR","year":2023,"kind":"conference","url":"https://openaccess.thecvf.com/content/CVPR2023/html/Wang_Image_as_a_Foreign_Language_BEiT_Pretraining_for_Vision_and_CVPR_2023_paper.html"},"citation":"@misc{multimodalitybeitv32022,\n  title = {{Image as a Foreign Language: BEiT Pretraining for All Vision and Vision-Language Tasks}},\n  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},\n  year = {2022},\n  eprint = {2208.10442},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/2208.10442}\n}\n","citationPath":"/content/papers/citations/multimodality/beit-v3.da59712d53e1.bib"},"thumbnail":{"src":"/content/papers/assets/29b3716ceccbc3340eda2ad7c1b5cc075b7411d9f23a7bf7e7465190ab7e6ef7.jpg","width":1224,"height":570},"locale":"en","path":"/content/papers/en/multimodality/beit-v3.92cb288627b4.md","headings":[{"id":"defining-the-problem","text":"Defining the Problem","depth":2},{"id":"problem-solving","text":"Problem Solving","depth":2},{"id":"model-architecture","text":"Model Architecture","depth":3},{"id":"multimodal-adaptation","text":"Multimodal Adaptation","depth":3},{"id":"pre-training-tasks","text":"Pre-training Tasks","depth":3},{"id":"model-and-training-data","text":"Model and Training Data","depth":3},{"id":"training-strategy","text":"Training Strategy","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"comparison-with-other-models","text":"Comparison with Other Models","depth":3},{"id":"module-contribution-analysis","text":"Module Contribution Analysis","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{"problem-definition":"defining-the-problem","solution":"problem-solving","multiway-transformer-shared-attention-modality-specific-ffns":"model-architecture","one-backbone-five-downstream-layouts":"multimodal-adaptation","one-pre-training-objective-three-data-types":"pre-training-tasks","scale-and-training-bill":"model-and-training-data","results-and-discussion":"discussion","a-striking-chart-still-needs-its-metrics":"comparison-with-other-models","which-component-mattered-most":"module-contribution-analysis"},"guide":null,"relatedReading":[{"id":"vision-transformers/beit-v2","relation":"background","topic":"Masked visual pretraining"}]},{"id":"vision-transformers/beit-v2","category":"vision-transformers","legacyPath":"vision-transformers/2208-beit-v2","legacySlug":"2208-beit-v2","legacyPaths":[],"title":"BEiT v2","subtitle":"Hidden Codes in High Dimensions","author":"Z. Yuan","paperDate":"2022-08-12","publishedOn":"2024-12-15","paperTitle":"BEiT v2: Masked Image Modeling with Vector-Quantized Visual Tokenizers","paperUrl":"https://arxiv.org/abs/2208.06366","bibliography":{"title":"BEiT v2: Masked Image Modeling with Vector-Quantized Visual Tokenizers","authors":["Zhiliang Peng","Li Dong","Hangbo Bao","Qixiang Ye","Furu Wei"],"url":"https://arxiv.org/abs/2208.06366","pdfUrl":"https://arxiv.org/pdf/2208.06366v2","codeUrl":"https://github.com/microsoft/unilm/tree/master/beit2","preprint":{"id":"2208.06366","submittedOn":"2022-08-12","url":"https://arxiv.org/abs/2208.06366"},"publication":null,"citation":"@misc{visiontransformersbeitv22022,\n  title = {{BEiT v2: Masked Image Modeling with Vector-Quantized Visual Tokenizers}},\n  author = {Zhiliang Peng and Li Dong and Hangbo Bao and Qixiang Ye and Furu Wei},\n  year = {2022},\n  eprint = {2208.06366},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/2208.06366}\n}\n","citationPath":"/content/papers/citations/vision-transformers/beit-v2.a1d8a42e31b0.bib"},"thumbnail":{"src":"/content/papers/assets/4d70ebb67c819b57a03a242c6d6f16af25de8682a068c003ce50035fc7184df0.jpg","width":1576,"height":570},"locale":"en","path":"/content/papers/en/vision-transformers/beit-v2.70a94d682283.md","headings":[{"id":"defining-the-problem","text":"Defining the Problem","depth":2},{"id":"solving-the-problem","text":"Solving the Problem","depth":2},{"id":"model-architecture","text":"Model Architecture","depth":3},{"id":"pretraining-method","text":"Pretraining Method","depth":3},{"id":"global-representation-pretraining","text":"Global Representation Pretraining","depth":3},{"id":"model-configuration","text":"Model Configuration","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"comparison-with-other-methods","text":"Comparison with Other Methods","depth":3},{"id":"ablation-study---codebook-size","text":"Ablation Study - Codebook Size","depth":3},{"id":"ablation-study---patch-aggregation-strategy","text":"Ablation Study - Patch Aggregation Strategy","depth":3},{"id":"ablation-study---teacher-objective-analysis","text":"Ablation Study - Teacher Objective Analysis","depth":3},{"id":"codebook-visualization","text":"Codebook Visualization","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"vision-transformers/beit","relation":"background","topic":"Masked visual pretraining"},{"id":"multimodality/beit-v3","relation":"next","topic":"Masked visual pretraining"}]}],"text":"Everyone knows that BEiT’s signature feature is the \"discrete coding.\"\n\nSo, upon encountering this paper, we instinctively expect BEiT-3 to introduce some novel \"discrete coding\" techniques.\n\nHowever, BEiT-3 **uses** discrete visual targets from BEiT v2 instead of inventing a new tokenizer. Its main question is: **How can we pretrain on text, images, and image–text pairs under one objective?**\n\nThat said, reminiscing about past successes is only natural—let’s not dwell too much on it.\n\n## Defining the Problem\n\nThe idea of \"pretraining images and text together\" is no longer groundbreaking.\n\nEarlier methods often used several pretraining objectives at once, such as image–text contrastive learning, image–text matching, language modeling, or masking. Retrieval itself is a downstream task in this comparison.\n\nIf it doesn’t ring a bell, let’s revisit the BLIP framework we studied earlier:\n\n\n\n![blip arch](/content/papers/assets/322ffdc07e192675b67e86d11d738be51834cd39a07d0979d66e8c27f0e8bd42.jpg)\n\n\n\nThis image is **BLIP's Figure 2**, included for comparison. Its image and text branches learn cross-modal relationships through ITC, ITM, and LM. This works, but managing several objectives and modes becomes more involved as models and data grow.\n\nSince images can be split into patches and text can be tokenized, why not use one masked-prediction framework? Treating images as another “language” is the author's metaphor; image patches remain a distinct input modality.\n\nPrevious researchers have undoubtedly considered this. However, the lack of an effective framework suggests that there are inherent challenges.\n\nThe authors believe that we should address this issue with a \"multi-path architecture.\"\n\n## Problem Solving\n\n### Model Architecture\n\n\n\n![model arch](/content/papers/assets/29b3716ceccbc3340eda2ad7c1b5cc075b7411d9f23a7bf7e7465190ab7e6ef7.jpg)\n\n\n\nThe multi-path architecture follows VLMo's **Mixture-of-Modality-Experts** idea: share self-attention but use modality-specific feed-forward networks. VLMo applied this design to multimodal pretraining before BEiT-3.\n\n\n> [!NOTE]\n> \n> For readers interested in VLMo, you can read:\n> \n> - [**[21.11] VLMo: Unified Vision-Language Pre-Training with Mixture-of-Modality-Experts**](https://arxiv.org/abs/2111.02358)\n> \n> \n> \n> ![vlmo arch](/content/papers/assets/c831e58bb2c2896fb8f7628f24f08e0b86fc4faf1acaa94eb7f8dd7741f67fe6.jpg)\n> \n> \n> \n> In VLMo, image, text, and paired data are introduced through staged pretraining objectives. BEiT-3 trains all three data types with the masked-prediction objective. This is **VLMo's Figure 2**, not a BEiT-3 training figure.\n\n\nThus, BEiT-3's architecture directly references VLMo's Multiway Transformers.\n\nEach Multiway Transformer module consists of shared self-attention and modality-specific feed-forward networks (FFNs). The input modality and chosen model configuration determine the expert path; this is not Switch Transformer's learned token-by-token routing.\n\nIn the authors' implementation, each layer includes a vision expert and a language expert; in addition, the top three layers are configured with vision-language experts for the fusion encoders.\n\nUsing a set of modality experts allows the model to capture more information specific to each modality. The shared self-attention module learns the alignment between different modalities and performs deep fusion in multimodal tasks (such as vision-language).\n\n\n> [!TIP]\n> \n> **Does this series look like the MoE in Switch Transformer?**\n> \n> - [**[21.01] Switch Transformer**](/blog/papers/transformers/switch-transformer)\n> \n> \n> \n> ![switch arch](/content/papers/assets/eecbcc790357c0311e5dbbaebb405abcb6c03693360947f21b08eb91602f1ac1.jpg)\n> \n> \n> \n> Both designs “choose an expert,” but the comparison image is **Switch Transformer's** learned router. BEiT-3 selects its FFN by modality. We should not treat the two routing mechanisms as identical or mistake this illustration for BEiT-3's architecture.\n\n\n### Multimodal Adaptation\n\n![multimodal](/content/papers/assets/9ae9e6506f47d0af8f90051b9f65e246fda1d2934308f008f2456195bd095204.jpg)\n\nAs shown in the figure above, the authors demonstrate BEiT-3's \"shared Multiway Transformer\" architecture, which can \"flexibly switch\" or \"combine\" into the required model form for different downstream tasks.\n\n- **(a) Vision Encoder**: Used for visual tasks that require only image feature representations, such as image classification, object detection, instance segmentation, and semantic segmentation.\n- **(b) Language Encoder**: Exposes the text-only route; the paper's diagram illustrates masked language modeling, not measured text-classification or dialogue results.\n- **(c) Fusion Encoder**: Used for tasks that require deep interaction between images and text, such as Visual Question Answering (VQA), Visual Reasoning (NLVR2), image-text reasoning, where both image and text need to be \"seen\" simultaneously for integrated understanding.\n- **(d) Dual Encoder**: Used for efficient image–text retrieval, representing candidates separately. The contrastive loss drawn here belongs to **retrieval fine-tuning**, not the masked pretraining stage.\n- **(e) Sequence-to-Sequence Learning**: Used for image captioning. During fine-tuning, an attention mask lets caption text see the image and preceding text while predicting masked caption tokens; at inference it generates words in order.\n\nWhether the task needs image encoding, text encoding, fusion, retrieval, or generation, the backbone can be configured for it. Task-specific heads and fine-tuning still differ: VQA, for example, uses a classifier over the **3,129 most frequent training answers**.\n\n### Pre-training Tasks\n\nDuring the pre-training process of BEiT-3, the model randomly masks some of the text tokens or image patches and trains the model to recover these masked tokens. This method helps the model learn the representations of text and images while also capturing the correspondence between them.\n\nDuring training, SentencePiece tokenizes text. The **image input is patch embeddings**; a BEiT v2 tokenizer supplies discrete visual **prediction targets** for masked patches. The authors mask 15% of text-only tokens, 50% of text tokens in image–text pairs, and 40% of image patches with blockwise masking.\n\nBEiT-3 uses a pretraining batch of **6,144**, smaller than the paper's cited contrastive-model batches of **65k** for CoCa, **32k** for CLIP, and **24k** for Florence. These are different model configurations.\n\n\n> [!TIP]\n> \n> That is where BEiT v2's tokenizer comes in—hence the BEiT-3 name. The tokenizer is reused, not invented here, and its tokens are targets rather than the image input.\n\n\n### Model and Training Data\n\nBEiT-3 has about 1.9 billion (1.9B) parameters: 692 million in vision FFNs, 692 million in language FFNs, 52 million in vision–language FFNs, and 317 million in shared attention. The architecture draws from ViT-giant. A vision-only pass activates roughly **1B vision-related parameters**, although the full model still contains all routes.\n\nThe model consists of 40 layers of Multiway Transformer. Each layer has a hidden dimension of 1408, an intermediate layer dimension of 6144, and 16 attention heads. Each layer contains both a \"vision expert\" and a \"language expert.\" Additionally, the top three layers of the Multiway Transformer incorporate \"vision-language experts\" for deeper cross-modal fusion.\n\nBEiT-3 uses both \"unimodal\" and \"multimodal\" data for pre-training. Unimodal data refers to data containing only \"pure images\" or \"pure text,\" while multimodal data refers to \"image + text\" pairs.\n\nMultimodal data sources: There are about 15 million images and 21 million image-text pairs from five public datasets: Conceptual 12M (CC12M), Conceptual Captions (CC3M), SBU Captions (SBU), COCO, and Visual Genome (VG).\n\nUnimodal data includes 14 million images from ImageNet-21K and 160GB of text data, sourced from English Wikipedia, BookCorpus, OpenWebText, CC-News, and Stories.\n\n### Training Strategy\n\nBEiT-3 pre-training lasts for 1 million steps. Each training batch consists of 6144 samples, including: 2048 images, 2048 text samples, and 2048 image-text pairs.\n\nImages use **14×14-pixel patches** at 224×224 resolution during pretraining. The image augmentation follows BEiT, including random resized cropping, horizontal flipping, and color jitter.\n\nThe text tokenizer used is SentencePiece, with a vocabulary size of 64k.\n\nOther hyperparameters include:\n\n- AdamW optimizer, with hyperparameters: $\\beta_1=0.9, \\beta_2=0.98, \\epsilon=1e-6$.\n- Learning rate schedule uses cosine annealing, with a maximum learning rate of 1e-3, reaching this peak learning rate after 10,000 steps.\n- Weight decay is set to 0.05.\n- Random depth technique is applied with a probability of 0.1 to reduce overfitting and enhance model generalization.\n\n\n> [!TIP]\n> \n> This batch size is actually much smaller than many contrastive learning models, as contrastive models often require very large batch sizes for effective negative sample comparison.\n\n\n## Discussion\n\n### Comparison with Other Models\n\n\n\n![compare](/content/papers/assets/a49d206010e535a9ee3f3282f7e523c7677ca1c40e9c1ce16403ab438613936c.jpg)\n\n\n\nThe authors performed extensive evaluations of BEiT-3 on various public benchmarks for vision-language and vision tasks.\n\nBEiT-3 exceeds selected earlier results on several of the charted vision and vision–language benchmarks. The radar axes use **different metrics and scales**; the enclosed area is not a single overall score. Model, data, and fine-tuning conditions also vary across the cited comparisons. The detailed table is below:\n\n\n\n![table](/content/papers/assets/ecfa235653f69ca327c7be2d4ff194d5aa1e999ef6684ddaff261e078088e182.jpg)\n\n\n\nTable 1 reports ADE20K mIoU **62.8**, COCO box AP **63.7** and mask AP **54.8**, ImageNet top-1 **89.6**, VQAv2 **84.0**, NLVR2 **92.6**, COCO caption CIDEr **147.6**, and retrieval average R@1. The ImageNet † comparison is limited to public resources; the captioning ‡ result does not use CIDEr optimization. Retrieval R@1 averages image-to-text and text-to-image directions. The retrieval headline also includes **intermediate contrastive fine-tuning**, a stage after masked pretraining.\n\nFor COCO 5K retrieval, Table 5 reports **84.8 / 67.2** R@1 in the two directions, averaging **76.0**. Appendix Table 10 shows **82.7 / 65.1** after direct downstream fine-tuning and **84.8 / 67.2** after the added intermediate stage. Flickr30K “zero-shot” means no Flickr30K labels, but that intermediate fine-tuning on the pretraining image–text pairs has already occurred. So the one masked **pretraining** objective and the later retrieval loss should be counted separately.\n\n### Module Contribution Analysis\n\nThe paper does not separately ablate data scale, Multiway experts, and the masked objective to measure each one's contribution. Appendix Table 10 does compare retrieval **with and without intermediate contrastive fine-tuning**. That still leaves us unable to rank all of the components, so the following is my qualitative reading:\n\n- **Is the \"large amount of data\" the core contribution?**\n\n  BEiT-3 pre-trains on a large-scale unimodal and multimodal dataset, including 14M ImageNet-21K images, 160GB of text data, and 15M image/21M image-text pairs.\n\n  Large datasets can matter for large-model performance, but this paper does not isolate their contribution. The authors emphasize using academically accessible data rather than proprietary collections. Some listed scores exceed earlier models using private data, but the comparisons also differ in model size and fine-tuning.\n\n  The vast data provides a foundation, but it is not the only innovation. The true focus of the paper is on \"the unity and effectiveness of the method.\"\n\n---\n\n- **The Expert Model Architecture**\n\n  Every Transformer layer has vision and language FFNs; only the top three also have a vision–language FFN. The layers share self-attention.\n\n  This is modality-based FFN selection, rather than Switch Transformer's learned router. Multiway lets the same backbone take a vision route, a text route, or a fusion route. That is useful engineering design, but the table does not isolate its numerical benefit.\n\n  However, this \"multi-path architecture\" design originates from VLMo's innovation, so it is not considered a key contribution of BEiT-3.\n\n---\n\n- **Unified Training Objective Function**\n\n  The authors replace several pretraining losses with the **masked data modeling** family of objectives across image-only, text-only, and paired samples. Paired samples let the model learn cross-modal representations within that shared setting.\n\n  The mask-then-predict idea is not new—BERT and earlier BEiT models used related objectives—but many multimodal predecessors combined explicit contrastive, ITM, and other losses. BEiT-3's **pretraining** uses only the masked-prediction family. Its three data types still enter in a fixed batch composition, and retrieval later uses contrastive fine-tuning. This is a simpler pretraining objective, not a claim that all downstream training uses one loss.\n\n  Simplifying pretraining is one of the paper's core messages. The benchmark table validates the **complete recipe** on several tasks.\n\n---\n\n- **Discrete Image Encoding Based on BEiT**\n\n  Earlier BEiT models use discrete visual tokens, analogous to a vocabulary, as **targets** for masked image modeling. BEiT-3 still feeds the network continuous image-patch embeddings.\n\n  This technology itself comes from earlier BEiT versions (v1, v2), not BEiT-3. However, this paper further proves the feasibility of treating \"images like another language.\" By discretizing image encoding, the model can process both text and images using the same BERT-like pre-training mechanism.\n\n  Discretization changes the target representation for masked patches; it does **not** replace BEiT-3's patch embeddings. The tokenizer is inherited from BEiT v2, so its innovation mainly belongs to earlier work.\n\n---\n\nLarge-scale data and discrete visual targets support the recipe. If we had to pick what is most distinctive, I would point to the **combination** of Multiway routing and a unified masked pretraining objective. The paper does not provide a controlled ablation that separates those two contributions.\n\nThe results show that simplified pretraining and flexible expert paths can support several downstream applications at scale. Data volume, model size, and task-specific fine-tuning also affect the reported scores.\n\n## Conclusion\n\nIn this paper, the authors propose a general multimodal foundational model: BEiT-3.\n\nBy treating images as a form of \"foreign language,\" the authors were able to apply the same masked \"language modeling\" method to train text, images, and image-text pairs, and use the Multiway Transformers architecture, allowing the model to switch flexibly between different modalities.\n\nCompared with multimodal pipelines that juggle several pretraining losses, BEiT-3's masked pretraining objective is simpler to organize. That makes it an attractive design, though a 1.9B-parameter model, one million steps, and task-specific fine-tuning are still part of its practical cost.\n","imageSizes":{"/content/papers/assets/322ffdc07e192675b67e86d11d738be51834cd39a07d0979d66e8c27f0e8bd42.jpg":{"width":1760,"height":706},"/content/papers/assets/29b3716ceccbc3340eda2ad7c1b5cc075b7411d9f23a7bf7e7465190ab7e6ef7.jpg":{"width":1224,"height":570},"/content/papers/assets/c831e58bb2c2896fb8f7628f24f08e0b86fc4faf1acaa94eb7f8dd7741f67fe6.jpg":{"width":1224,"height":354},"/content/papers/assets/eecbcc790357c0311e5dbbaebb405abcb6c03693360947f21b08eb91602f1ac1.jpg":{"width":1224,"height":648},"/content/papers/assets/9ae9e6506f47d0af8f90051b9f65e246fda1d2934308f008f2456195bd095204.jpg":{"width":1374,"height":890},"/content/papers/assets/a49d206010e535a9ee3f3282f7e523c7677ca1c40e9c1ce16403ab438613936c.jpg":{"width":1224,"height":880},"/content/papers/assets/ecfa235653f69ca327c7be2d4ff194d5aa1e999ef6684ddaff261e078088e182.jpg":{"width":1224,"height":502}}}
