When Can Transformers Ground and Compose: Insights from Compositional Generalization Benchmarks (2022)

Abstract: Humans can reason compositionally whilst grounding language utterances to the real world. Recent benchmarks like ReaSCAN (Wu et al., 2021) use navigation tasks grounded in a grid world to assess whether neural models exhibit similar capabilities. In this work, we present a simple transformer-based model that outperforms specialized architectures on ReaSCAN and a modified version (Qiu et al., 2021) of gSCAN (Ruis et al., 2020). On analyzing the task, we find that identifying the target location in the grid world is the main challenge for the models. Furthermore, we show that a particular split in ReaSCAN, which tests depth generalization, is unfair. On an amended version of this split, we show that transformers can generalize to deeper input structures. Finally, we design a simpler grounded compositional generalization task, RefEx, to investigate how transformers reason compositionally. We show that a single self-attention layer with a single head generalizes to novel combinations of object attributes. Moreover, we derive a precise mathematical construction of the transformer’s computations from the learned network. Overall, we provide valuable insights about the grounded compositional generalization task and the behaviour of transformers on it, which would be useful for researchers working in this area.

## introduction natural languages are believed to be compositional @xcite , i.e., the meaning of an expression is determined by the meaning of its constituents and how they are combined. the field of compositional generalization seeks to understand whether neural models used for language processing exhibit compositional behaviour. in recent years, the field has received increased attention resulting in the development of many new benchmarks (lake and baroni, 2018; kim and linzen, † work done at microsoft research india. command: pull the big cylinder that is inside of a small blue box and in the same column as a small green circle hesitantly action sequence: turn left, turn left, walk, stay, walk, stay, turn left, walk, stay, walk, stay, pull, stay, pull, stay 2020; keysers et al., 2020) and approaches @xcite @xcite to solve them. natural language utterances are also grounded to the real world. to encourage development of systems that are both compositional and grounded, ruis et al. (2020) created the gscan dataset. recently, @xcite proposed the gsrr dataset 1 and @xcite proposed the reas-can dataset to address certain limitations in gscan. these tasks consist of navigation commands grounded in a 2d grid world containing an agent and multiple objects with different visual attributes. given a command and grid world, a model needs to output the sequence of actions for the agent to execute. fig. 1 shows an example from reascan. the difficulty of the task lies in generalizing to out-of-distribution splits that are formed by systematically holding out particular compositions of object attributes and command structures from train set. heinze-deml and bouchacourt (2020); @xcite developed specialized architectures for gscan that are either difficult to adapt to other problems or require extra supervision. contributions. our goal is to better understand these grounded compositional generalization tasks and design generic ml models to solve them. our contributions include: walk to the small red square. ## background we focus on the gscan @xcite , gsrr @xcite and @xcite split held-out examples a1 yellow squares referred with color and shape a2 red squares as target a3 the main challenge of the task is generalizing on the specially designed test splits that consist of various types of examples systematically held-out from the train set as shown in the results of various previously proposed methods are shown in model random (i) comp. average ii iii iv v vi ## our approach we start with the multimodal transformer model as used in @xcite . this model, hereafter called the base model, follows encoder-decoder structure @xcite and uses crossmodal attention in the encoder. encoder maps world state @xmath0. the command tokens these are passed through n transformer blocks, each consisting of two parallel multi-head attention blocks (one for vision and one for language modality), with representation of one modality passed as key and value to the attention block of the other modality. decoder consists of n stacked blocks similar to the decoder in @xcite . each block contains one self-attention block and one multihead attention block over the contextual representation h @xmath1; h v ] of the encoder. below, we describe the modifications we make to this base architecture to create grocot. implementation details are provided in appendix b. ## analyzing the grounded compositional generalization tasks 4.1 target identification vs navigation: what is the challenge? in order to solve these tasks, a model needs to perform two subtasks: (1) identify the target location by composing the words and reasoning about the relative clauses, and (2) navigate the agent in the grid world by generating the right set of output tokens. to understand why models fail and how to improve them, we need to pinpoint where the main difficulty in the task lies. below we describe a set of experiments that demonstrate that target identification is the main challenge in reascan rather than navigation or sequence generation. 4 we show this for the gscan dataset in appendix e.1.3. target identification from encoder representations. we train a linear layer on top of the last layer of learned encoder representations of the bestperforming model to perform target identification. reascan accuracy w/ gold target locations 99.9 99.9 99.9 99.9 99.9 99.9 99.9 99.9 we model the task as a 36-way classification problem, where each grid location is treated as a distinct class. we train the model over all reascan examples with the ground truth target locations. note that we only update the weights of the linear layer; the parameters of the encoder are kept frozen. we then test this model's target identification abilities over the systematic generalization splits. the first row of we also provide exhaustive ablations for this experiment in sequence generation from gold target locations. we provide the model with gold target locations when training it on the reascan training set. we enumerate all the 36 grid cell locations and simply append gridnum to the end of the natural language command where @xmath2, 2, ..., 36}, depending on the ground-truth target location for a particular example. the results are provided in the last row of in this section, with comprehensive empirical evidence, we showed that models are highly competent at agent navigation and that the chief difficulty lies in identifying the target location. ## refex: understanding how transformers ground and compose we wish to understand how transformers succeed on grounded compositional generalization tasks. however, the complexity of both, the reascan task, and the multi-modal transformer, makes it difficult to interpret the model. hence, we design a new task, refex, based on the target identification subtask of reascan. 9 in the following sections, we show that even a one-layer, one-head attentiononly model can successfully ground and compose multiple object attributes in refex. we then give a precise construction of the model, which demonstrates the detailed computations corresponding to grounding and composition. ## conclusion and future work recent benchmarks like gscan and reascan test grounded compositional generalization abilities of ml models. in this work, we identify key modifications in multimodal transformers that improve compositional generalization on these benchmarks. with a battery of probing experiments, we found that identifying the target location is the main challenge for the models. additionally, we showed that a particular test set in reascan is unfair and proposed a modified train-test split in its stead. finally, we designed a new task, refex, to study grounding and composition in attention-only transformers. we showed the efficacy of single self-attention layer with single head in successfully grounding and composing multiple visual attributes in a grid world environment. from the learned models, we derived an explicit and interpretable construction that captures the model's behavior and completely describes the detailed computations corresponding to grounding and composition. while our focus has been on tabula rasa models, it is also of interest to see if pretraining on large datasets enables good performance on the considered benchmarks. our preliminary investigations on gpt-3 and codex (appendix d) suggest that these text-based models have some way to go; more thorough investigation is left for the future. we expect future work to address the current limitations of models on action sequence side compositional generalization, i.e., generalizing to novel combinations of action tokens. moreover, our results indicate that designing compositional generalization splits can be surprisingly subtle and require careful scrutiny. finally, grounded compositional generalization benchmarks should also target more realistic setups with natural images in the future.