Keeping an Eye on Context: Attention Allocation over Input Partitions in Referring Expression Generation (2023)

Abstract: In Referring Expression Generation, model inputs are often composed of different representations, including the visual properties of the intended referent, its relative position and size, and the visual context. Yet, the extent to which this information influences the generation process of black-box neural models is largely unclear. We investigate the relative weighting of target, location, and context information in the attention components of a Transformer-based generation model. Our results show a general target bias, which, however, depends on the content of the generated expressions, pointing to interesting directions for future research.

## introduction context is crucial in multimodal language generation tasks such as referring expression generation (reg), as descriptions for visible entities not only depend on their own appearance but also on their surroundings (e.g. @xcite . for reg, this is especially evident, as the same expression can unambiguously describe an object in one context but be misleading in others @xcite . to this end, it has become a common practice to provide neural generation models for multimodal reg not only with visual representations for the target itself but also with information about its location and size and the visual context it appears in (see figure 1 ). however, due to their blackbox nature, it is not entirely clear to which extend state-of-the-art neural reg models take all of these representations into consideration. while ablation studies show how context information contribute to model performance @xcite , they provide limited insight into how it is processed and to what extend it is relevant for e.g. lexical decisions. similar questions arise in other vision & language (v&l) tasks such as image captioning, where recent work has looked into analyzing the internal attention mechanisms of generation models (e.g. @xcite . however, as the respective models usually take global images as input, analyses are mostly concerned with attention distribution within those representations rather than across different parts of the input. for reg, some authors use attention heatmaps as a method of model introspection @xcite @xcite , but without analyzing the patterns in detail. as a first step for deeper investigations of how contextual information is processed in reg models, we quantify how attention is allocated over the partitioned inputs in a simple reg model. in more detail, we examine the model's relative focus on different parts of the input during inference, i.e. representations of the visual appearance of the referential target, its location in the image and the visual context it appears in. we analyze the attention weights on these input partitions both globally and for a subset of generated tokens to see if the weighting is affected by the expression content. to the best of our knowledge, no dedicated studies have yet been conducted on how attention is allocated across input partitions in reg models (but see @xcite discuss this for a single example). our results indicate that contextual information is utilized by the model in linguistically meaningful ways, highlighting promising directions for further research. in recent years, advances in neural modeling and vision and language corpora such as refcoco @xcite enabled reg set-ups based on real-world images. neural reg models generally resemble architectures from e.g. image captioning, but are adapted in different ways to increase the discriminativeness of generated expressions @xcite . this includes simulations of listener behaviour embedded in training objectives @xcite , comprehension modules @xcite , reinforcement agents @xcite or decoding strategies @xcite , but also supplementing model inputs with additional information. for this, some works propose visual comparisons to encode differences in appearance between targets and context objects @xcite @xcite @xcite , whereas others directly use representations of the global image as context @xcite @xcite @xcite . in addition to visual context, many approaches provide their models with the relative position and size of the target in the image @xcite @xcite @xcite @xcite @xcite . to be used as model inputs, different representations are usually concatenated, i.e. the inputs are composed of partitions of visual target and context features as well as location information. attention analysis in v&l in recent years, attention mechanisms @xcite have become a cornerstone in generative v&l tasks like image captioning @xcite @xcite @xcite @xcite , among many others, cf. zohourianshahzadi and kalita 2021). despite some cautious remarks @xcite , attention is used as a method for model introspection (e.g. clark et al. 2019; voita et al. 2019; vig 2019 for text and cao et al. 2020, 2022; ilinykh and dobnik @xcite for v&l settings). while recent reg approaches build on transformer @xcite architectures with attention as the key component @xcite , the inner workings of the attention modules have only been studied in qualitative terms @xcite @xcite . here, we perform a quantitative analysis of attention allocation in a simple transformer-based reg model. ## conclusion and future directions in this paper, we investigated attention allocation across input partitions for a simple reg model. our results show that the model attends to all sources of information, albeit with a general bias towards the target. in addition, our models show systematic differences between encoder and decoder attention across datasets, as well as sensitivity to the meaning of the generated tokens. importantly, this study only represents a small step toward a more thorough understanding of the significance of different types of information in reg. one limitation of this work is that our models are not explicitly optimized for the general objective of the reg task, i.e., unambiguously identifying the referential target (see limitations section). consequently, as regarding for possible distractors is crucial for this, we see great potential in investigating how different approaches to increase the pragmatic informativeness of generated expressions (cf. section 2) affect the relative weighting of input partitions. along with this, given the multifaceted role of situational context for reg @xcite , future work should take a closer look at attention allocation over semantic units in the visual context, e.g. to see whether objects with certain classes or relations to the target are weighted more or less during generation.