What Does BERT with Vision Look At? (2020)

Abstract: Pre-trained visually grounded language models such as ViLBERT, LXMERT, and UNITER have achieved significant performance improvement on vision-and-language tasks but what they learn during pre-training remains unclear. In this work, we demonstrate that certain attention heads of a visually grounded language model actively ground elements of language to image regions. Specifically, some heads can map entities to image regions, performing the task known as entity grounding. Some heads can even detect the syntactic relations between non-entity words and image regions, tracking, for example, associations between verbs and regions corresponding to their arguments. We denote this ability as syntactic grounding . We verify grounding both quantitatively and qualitatively, using Flickr30K Entities as a testbed.

## introduction recently, bert @xcite variants with vision such as vilbert @xcite , lxmert @xcite , and uniter @xcite have achieved new records on several vision-and-language reasoning tasks, e.g. vqa @xcite , nlvr 2 @xcite , and vcr @xcite . these pre-trained visually grounded language models use transformers @xcite to jointly model words and image regions. they are pretrained on paired image-text data, where given parts of the input the model is trained to predict the missing pieces. despite their strong performance, it remains unclear if these models have learned the desired cross-modal representations. conversely, a large body of work @xcite @xcite has focused on understanding the internal behaviours of pre-trained language models @xcite @xcite and find that they capture linguistic features such as pos, syntactic structures, and coreferences. this inspires us to ask: what do visually grounded language models learn during pre-training? following @xcite , we find that certain attention heads of a visually grounded language model acquire an intuitive yet fundamental ability that is often believed to be a prerequisite for advanced visual reasoning @xcite : grounding of language to image regions. we first observe that some heads can perform entity grounding, where entities that have direct semantic correspondences in the image are mapped to the correct regions. for example, in figure 1 , the word "man" attends to the person on the left of the image. further, non-entity words often attend to image regions that correspond to their syntactic neighbors and we call this syntactic grounding. for example, "wearing" is attending to its subject, the man in the image. we argue that syntactic grounding actually complements entity grounding and that it is a natural byproduct of cross-modal reasoning. for example, to ground "man" to the person on the left rather than other pedestrians, the model needs to identify the syntactic relationships among "man", "wearing", "white", and "shirt" and ground "shirt" and "man" subsequently. during such process, it is helpful and natural that "wearing" attends to the man in the image. we verify such phenomena by treating each attention head as a ready-to-use classifier @xcite that given an input word, always outputs the most-attended-to image region. using flickr30k entities @xcite as a test bed, we demonstrate that certain heads could perform entity and syntactic grounding with an accuracy significantly higher than a rule-based baseline. further, higher layers tend to have higher grounding accuracy, suggesting that the model is figure 1 : attention weights of some selected heads in a pre-trained visually grounded language model. in high layers (e.g., the 10-th and 11-th layer), the model can implicitly grounding visual concepts (e.g., "other pedestrians" and "man wearing white shirt"). the model also captures certain syntactic dependency relations (e.g., "walking" is aligned to the man region in the 6-th layer). the model also refines its understanding over the layers, incorrectly aligning "man" and "shirt" in the 3-rd layer but correcting them in higher layers. figure 2 : the architecture of visualbert. image regions and language are combined with a transformer to allow the self-attention to discover implicit alignments between language and vision. n. it is pre-trained with a masked language modeling (objective 1), and sentence-image prediction task (objective 2), on caption data and then fine-tuned for different tasks. input to visualbert includes a text segment and an image. the image is represeted as a set of visual embeddings, where each embedding vector corresponds to a bounding region in the image, derived from an object detector @xcite . text and visual embeddings are then passed through multiple transformer layers to build joint representations. visualbert is pre-trained on the coco dataset @xcite , concisting of around 100k images with 5 captions each. we use two objectives for pre-training. (1) masked language modeling with the image. some elements of text input are masked and the model learns to predict the masked words based on the remaining text and visual context. (2) sentence-image prediction. for coco, where there are multiple captions corresponding to one image, we provide a text segment consisting of two captions. one of the caption is describing the image, while the other has a 50% chance to be another corresponding caption and a 50% chance to be a randomly drawn caption. the model is trained to distinguish these two situations. extensive experiments on four vision-andlanguage datasets @xcite @xcite verify that pre-trained visualbert exceeds all comparable baselines significantly. a summary of the results is present in ## related work there is a long research history of bridging vision and language @xcite @xcite with the lasted advances being visually grounded language models @xcite @xcite @xcite . however, little analysis has been done on understanding what vision-and-language models learn. previous works on vqa and image captioning @xcite @xcite have only shown qualitative examples on the grounding ability of the models, while another line of work focuses on designing dedicated models for the entity grounding task @xcite . we, however, present a quantitative study on whether visually grounded language models acquire the grounding ability during pre-training without explicit supervision. our work is inspired by papers on analyzing pretrained language models. one line of work uses probing tasks to study the internal representations @xcite @xcite while another studies the attention mechanism @xcite @xcite . we follow the latter but we believe the grounding behaviour could also be probed in the internal representations of visualbert. a person ball racket layer 3 layer 4 layer 5 layer 6 layer 10 layer 11 person hits a ball with a tennis rack ##et a man computer cat computer* face* layer 3 layer 4 layer 5 layer 6 layer 10 layer 11 works on a computer with a cat in the background man woman sweater husband layer 3 layer 4 layer 5 layer 6 layer 10 layer 11 a flu ##flustered women in a white sweater is teased her husband by ## conclusion and future work we have presented an analysis on the attention maps of visualbert, a proposed visually grounded language model. we note that the grounding behaviour we have found is linguistically inspired, as entity grounding can be regarded as cross-modal entity coref resolution while syntactic grounding can be regarded as cross-modal parsing. moreover, visualbert exhibits a hint of cross-modal pronoun resolution, as in the bottom image of figure 5 , the word "her" is resolved to the woman. for future work, it would be interesting to see if more linguistically-inspired phenomena can be systematically found in cross-modal models.