Back to paper library
arXiv 2020Multimodal learningPaper notes

Pixel-BERT

The Language of Pixels

Original paper

Pixel-BERT: Aligning Image Pixels with Text by Deep Multi-Modal Transformers

Paper authors

Zhicheng Huang · Zhaoyang Zeng · Bei Liu · Dongmei Fu · Jianlong Fu

Publication
Publication venue not yet verified
First submitted to arXiv
arXiv:2004.00849
Cite this paper · BibTeX

The citation identifies the linked source version. It cites the original paper and its authors.

@misc{multimodalitypixelbert2020,
  title = {{Pixel-BERT: Aligning Image Pixels with Text by Deep Multi-Modal Transformers}},
  author = {Zhicheng Huang and Zhaoyang Zeng and Bei Liu and Dongmei Fu and Jianlong Fu},
  year = {2020},
  eprint = {2004.00849},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2004.00849}
}
On this page

In the past, when discussing the integration of vision and language models, most researchers followed a conventional standard procedure:

  1. Use object detection models like Faster R-CNN to extract region features from images.
  2. Combine these features with language models for cross-modal learning.
  3. Explore various designs for cross-modal learning.

But who said a pre-trained object detection model must be the first step in the image encoding process?

Maybe no one explicitly stated it, but it became a common practice over time.

For researchers, it is often easier to follow previous works, make improvements, and achieve a slight performance increase of 1% to 3% to produce a commendable paper.

This trend continues until a breakthrough method is proposed or the evaluation dataset's performance saturates, leading to the next wave of changes.

Future researchers might question: Why did people back then rely so much on Transformer models?

The authors challenge the convention of extracting fixed detector-region features before image–text fusion, not the validity of object detection as a task.

Object detection models are typically designed for specific visual tasks, potentially introducing biases that are not aligned with language understanding, especially when the visual representation capability of these models is limited by specific task categories.

Pixel-BERT offers a fresh perspective. It no longer relies on pre-trained object detection models but learns visual encoding directly from image pixels. This approach captures "pixel-level" visual information, including shapes, textures, and spatial relationships, which might be lost in object detection models. Combined with language encoding, this model effectively captures the subtle interactions between vision and language, learning richer and more detailed cross-modal representations.

Problem Definition

The authors identify and define the following issues in this paper:

  1. Cross-Modal Semantic Gap

    Current cross-modal learning (especially between vision and language) faces challenges due to the semantic gap between visual and language representations.

  2. Limitations of Visual Features

    Previous methods tend to use region-based visual features extracted from object detection models. However, these region-based feature extractors are designed for specific visual tasks, leading to information gaps when combined with language understanding. Important visual information like object shapes, spatial relationships between overlapping objects, and object states might be lost.

  3. Constraints of Existing Visual Features

    Region-based visual features currently used have limitations in representing broader visual semantics such as scenes and emotions, which object detection models might not capture.

Solution

Pixel-BERT Model Design

Earlier models commonly use learned CNN/ROI feature vectors from Faster R-CNN proposals. They do not simply feed the raw RGB values inside each box to the image–text model.

But this method has its limitations:

  • Information Loss: Bounding boxes might include some irrelevant background or miss parts of important objects, leading to information loss.
  • Task-Specific Constraints: These object detection models are designed for specific visual tasks and may not be suitable for other cross-modal tasks.

Pixel Feature Encoding

Pixel-BERT uses jointly trainable CNN grid features. “Pixel” here refers to a feature-map position, not one Transformer token per original image pixel. The CNN still starts from ImageNet-pretrained weights.

  1. Pixel Learning: Using CNNs like ResNet, visual features are learned directly from the entire image, considering every pixel, not just those within bounding boxes.
  2. Feature Extraction:
    • Image Input: The input image first enters the model.
    • CNN Backbone: A pre-trained neural network is used to extract visual features from the input image.
    • Convolution (Conv): Further processing of features through convolutional layers.
    • Pooling: Add 2×2 max pooling, giving an overall spatial downsampling factor of about 64 along each axis.
    • Random Sample: During pre-training, randomly selects 100 feature-map positions for the Transformer to limit its input length.
  3. Semantic Encoding: Each pixel feature is augmented with a semantic encoding vector (sv). This special vector differentiates visual encoding from language encoding. All pixel features share the same sv, acting as a bias term added to the CNN backbone.

Sentence Feature Encoding

The model follows BERT’s method to encode the language information of sentences.

  1. Sentence Tokenization

    A given sentence is tokenized into a sequence of words, a standard step in natural language processing, breaking the sentence into its constituent words.

  2. Word Tokenization

    Using the WordPiece model, each word is tokenized. This method, commonly used in BERT, breaks a word into smaller recognizable segments or subwords, useful for handling rare or out-of-vocabulary words.

  3. Encoding Matrix Transformation

    Each token is encoded into a vector through an encoding matrix, mapping each unique token or subword into a fixed-dimensional vector space.

  4. Positional Encoding

    Positional information is crucial for models like Transformers. Thus, similar to BERT, Pixel-BERT adds positional encoding to capture the position of each token in the sequence.

  5. Combining Encoded Features

    Each input token is represented as w^i=LayerNorm⁡(wi+pi+sw)\hat w_i=\operatorname{LayerNorm}(w_i+p_i+s_w). Since sws_w is shared across text positions, it can be absorbed into learned positional embeddings and is omitted as a separate term. These are pre-Transformer inputs.

  6. Final Language Representation

    The resulting token sequence is passed to the cross-modal Transformer; it is not yet a final contextualized sentence vector.

Cross-Modal Learning

The model uses Transformers to learn cross-modal attention, particularly the relationships between CNN feature-map positions and language tokens. All encoded features are combined into a long input sequence, with special tokens like [CLS] and [SEP] to distinguish its structure. This design lets gradients from the cross-modal task reach the CNN backbone.

Pre-Training Methods

Throughout this section, “pixel features” means CNN feature-map tokens. Robustness and reduced overfitting are motivations supported by the experiments, not guarantees under arbitrary occlusion.

To learn general visual and sentence representations for vision and language-related tasks, the authors adopted a self-supervised approach for pre-training on large aggregated datasets.

  • Masked Language Model (MLM)

    About 15% of language tokens become masked-prediction targets. The model uses remaining text and CNN visual tokens to predict the original words. It does not reconstruct image pixels; random visual-feature sampling is a separate mechanism.

    Traditional BERT is unimodal, meaning it performs masked prediction only within language tokens. However, due to Pixel-BERT’s cross-modal nature, it leverages visual tokens for prediction. This capability makes Pixel-BERT more adept at handling contexts that might be ambiguous or challenging to interpret purely from language. For instance, when masked tokens in the language correlate directly with objects or scenes in the image, visual tokens provide crucial context, aiding the model in making accurate predictions.

  • Image-Text Matching (ITM)

    Image-Text Matching (ITM) is a complex strategy designed to evaluate the model's ability to understand the deep semantic relationships between images and their corresponding text descriptions. It’s not just about finding direct matches but about recognizing nuanced connections.

    ITM classifies the fused [CLS] representation, training with equal numbers of original pairs and randomly shuffled negatives. A blossom caption paired with a blossom image is a positive example, while pairing it with a desert image is negative. The objective encourages a higher positive score.

    However, to enhance the model's discrimination ability, "negative pairs" (where the image and text do not match) are introduced during training. For instance, pairing the text "under the cherry blossoms in spring" with an image showing a desert landscape. This design helps the model learn when the image and text are mismatched. Through this combination of positive and negative training pairs, the model can more accurately assess image-text match quality in real-world applications.

  • Pixel Random Sampling

    Pixel Random Sampling is a unique strategy in Pixel-BERT aimed at enhancing the model's robustness and reducing overfitting risk.

    Pre-training samples 100 CNN feature-map positions as visual tokens for the Transformer. The whole image still passes through the CNN; this reduces Transformer input length rather than discarding raw image pixels before encoding.

    This approach has several advantages:

    • Enhanced Robustness: By seeing a different subset of feature-map positions each time, the model is encouraged to learn from incomplete visual-token input.
    • Increased Efficiency: Fewer visual tokens reduce the Transformer’s computation during pre-training; the whole image still passes through the CNN.
    • Reduced Overfitting Risk: Changing the visual-token subset may discourage reliance on fixed feature positions; the ablation measures downstream scores, not robustness under arbitrary occlusion.

    Sampling is used only in pre-training; downstream fine-tuning and testing use the complete CNN feature grid. The authors choose this to avoid losing information during short fine-tuning runs and to keep train/test inputs consistent, not as a universal requirement for every task.

Discussion

VQA Performance

  • The ResNet-50 version scores 71.35/71.42 on VQA test-dev/test-std. Its 71.35 test-dev score exceeds the listed ViLBERT 70.55 and VisualBERT 70.80, but trails VL-BERT 71.79 and LXMERT 72.42.

  • The ResNeXt-152 version scores 74.45/74.55 on test-dev/test-std. This is the historical comparison in the cited paper; backbone, input resolution and training configuration also influence results.

  • The table lists UNITER at 72.46 on test-std; the paper's prose separately cites UNITER-large at 73.40. They are different comparison rows, and the latter is not Pixel-BERT’s score.

These results support learning visual and language attention from CNN feature-map positions. Differences in visual backbones and pre-training settings still matter in comparisons across models.

NLVR2 Performance

In the natural language visual reasoning (NLVR2) task, the goal is to predict whether a language description corresponds to the given image pair. Pixel-BERT takes two image-language pairs as input, obtaining two encoded vectors from the [CLS] token. These vectors are concatenated and then used to train a classifier to predict "true" or "false" using cross-entropy loss.

The ResNeXt-152 version scores 76.5/77.2 on NLVR2 dev/test-P, above the listed LXMERT and UNITER Pair but below UNITER Pair-biattn at 77.1/77.9. ResNet-50 scores 71.7/72.4; the backbone setting must be specified.

Pixel-BERT performs well not only on VQA but also on this task of evaluating a language description against two images. These results indicate its flexibility in adapting to different input formats.

Image-Text Retrieval

Retrieval fine-tuning updates only Transformer parameters.

  • The figure is Table 4's Flickr30K 1K test set, not MS-COCO. With ResNeXt-152, Pixel-BERT reaches text retrieval (TR) R@1 of 87.0, above Unicoder-VL's 86.2 and UNITER's 84.7. Its image retrieval (IR) R@1 of 71.5 ties those two models.
  • The paper separately reports MS-COCO in Table 5. There, ResNeXt-152 scores TR R@1 of 84.9/63.6 and IR R@1 of 71.6/50.1 on the 1K/5K tests. The prose's gains of 0.6/0.3 points for TR and 1.9/1.7 for IR refer to particular baselines on these COCO splits, not to the Flickr30K figure.

Pixel-BERT shows strong image-text retrieval results, especially on MS-COCO text-to-image R@1. These are comparisons across models with different visual backbones and training settings.

Key Design Elements

The authors attribute part of Pixel-BERT's effectiveness and excellent performance to several key design elements:

  1. Choice of Pre-Training Tasks

    Against row 1 without pre-training, MLM alone in row 3 raises VQA from 63.50 to 71.13 and NLVR2 from 52.0 to 70.9. ITM alone in row 2 improves retrieval, but NLVR2 slips from 52.0 to 51.9.

  2. Combining Different Pre-Training Tasks

    With the same ResNet-50 backbone and random sampling, combining MLM and ITM in row 5 improves the reported scores over either objective alone.

  3. Random Pixel Sampling

    This design aims to enhance robustness and reduce overfitting. Holding the ResNet-50 backbone and MLM+ITM fixed, random sampling in row 5 versus all feature positions in row 4 raises VQA 70.84→71.35, TR 72.0→75.7, IR 57.7→59.8, and NLVR2 71.3→71.7.

  4. Choice of Visual Backbone

    The model's performance also depends on the selected visual backbone. Using a more powerful ResNeXt-152 significantly improves performance, showcasing Pixel-BERT's ability to combine with strong visual backbones.

Conclusion

The visualization relates textual attention to image positions and offers qualitative clues about model behavior.

In recent research developments, pre-training models in the vision and language field have achieved remarkable results. To address the limitations of region-based visual representations, the authors introduce a CNN-based visual encoder, cleverly combined with multi-modal Transformers, creating the Pixel-BERT model.

Pixel-BERT explores the connections between image features and text, with its attention maps offering a view of the visual-language representations it learns. Its random sampling strategy improves the measured downstream results. Pre-trained on Visual Genome and MS-COCO, the model achieves strong results on the evaluated tasks. The authors also plan to pre-train on more datasets and explore self-supervised visual-content tasks to improve it further.