{'fraction_non_alphanumeric': 0.030535381624773886, 'fraction_numerical': 0.013472285968843652, 'mean_word_length': 4.863542820959316, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Modality-Agnostic Attention Fusion for visual search with text feedback

Image retrieval with natural language feedback offers the promise of catalog search based on fine-grained visual features that go beyond objects and binary attributes, facilitating real-world applications such as e-commerce. Our Modality-Agnostic Attention Fusion (MAAF) model combines image and text features and outperforms existing approaches on two visual search with modifying phrase datasets, Fashion IQ and CSS, and performs competitively on a dataset with only single-word modifications, Fashion200k. We also introduce two new challenging benchmarks adapted from Birds-to-Words and Spot-the-Diff, which provide new settings with rich language inputs, and we show that our approach without modification outperforms strong baselines. To better understand our model, we conduct detailed ablations on Fashion IQ and provide visualizations of the surprising phenomenon of words avoiding"attending"to the image region they refer to.


Introduction
In recent years, the task of image retrieval has advanced to allow for more complex, multi-modal queries, including those involving both images and text [14,15,47,23,5]. Such systems accommodate users by offering a more expressive framework for conveying image search targets.
Here we study the setting in which a query is specified by an image together with text that describes how to alter the image to arrive at the desired concept. We are particularly interested in distinguishing fine-grained differences between images, which may not be characterized by the presence, absence, or location of discrete objects. This setting includes valuable applications such as searching a fashion catalog, and it is a good match for the flexibility of natural language compared to pre-specified lists of attributes or sets of objects.
Vo et al. [47] introduced datasets to study this task and demonstrated that combining text and image features with a residual gating mechanism yielded the best results among adaptations of several existing methods. More recent advances have used attention mechanisms [23,5] and introduced the Fashion IQ dataset, providing a setting with richer text modifications [15].
We propose a simple model we call Modality-Agnostic Attention Fusion (MAAF) to address the text-modified image retrieval task. The core fusion idea is to extract "token" vectors representing parts of the input for each modality, then stack these tokens into a single sequence to process with an attention model. Applying this broad idea to our specific task requires extracting useful tokens from text and from images that may not have multiple objects, and finally combining the attention model outputs into a single vector suitable for nearest-neighbor search. We compare approaches for each of these steps and show that a simple LSTM for the text input, convolutional feature maps at multiple scales for the image input, and average pooling within each class of token achieves the strongest results on Fashion IQ. We hypothesized that our flexible modality-agnostic approach would outperform two-streamed approaches with cross-modal attention, and we provide experiments to con-firm this hypothesis on Fashion IQ.
Our best model outperforms the state of the art on Fashion IQ as well as CSS3D [47], and we show competitive results on Fashion-200k and MIT States. These latter datasets have only single-word text modifications, so we also introduce two new benchmarks with richer language components. These benchmarks are based on Birds-to-Words [10] and Spot-the-Diff [26], and we show that our model outperforms strong baselines including TIRG [47] on them without modification.
We also show through visualizations the counterintuitive behavior of words avoiding attending to the regions they refer to. To the best of our knowledge, this work is the first to identify such behaviour, which we attribute to the nature of the task.
In brief, we make the following contributions: • We present Modality-Agnostic Attention Fusion (MAAF), an approach to image retrieval using attention over undifferentiated text and image queries, which yields improvements over the state-of-the-art in several retrieval tasks.
• We quantitatively demonstrate the utility of various components of the retrieval system through baseline and ablation experiments.
• We introduce two new challenging benchmarks for evaluating models on the multimodal image retrieval task.
• We show through visualizations that our attention mechanism exhibits the counter-intuitive behavior of attending to complementary regions of those the modifying sentence word tokens refer to.

Model
Our goal is to learn a common embedding space for query images modified by text and for catalog images, so that the most closely matching catalog entries for a given image + text query can be ranked by calculating the similarity between that querys embedding and the catalog images' embeddings. Our Modality-Agnostic Attention Fusion (MAAF) approach is illustrated in Fig. 2.
The data from each modality is first passed through a standard architecture.
Images are passed into a ResNet50 [18,19]. Text is tokenized and word embeddings are passed through an LSTM [21]. When not otherwise specified, the weights of the ResNet are pretrained on Im-ageNet while the word embeddings and LSTM weights are randomly initialized.
We extract token sequences from each modality and fuse them using dot-product attention. The image tokens φ x correspond to spatial locations in ResNet feature maps.
The outputs of the last convolutional block are treated as 7x7=49 tokens, one corresponding to each spatial location, after a learned linear projection to 512 dimensions from the original 2048 channels. The outputs of earlier ResNet blocks may be treated similarly; the third block yields 14x14=196 additional image tokens. Unless otherwise specified, our model uses these 49+196 = 245 image tokens for multi-resolution image understanding. The LSTM naturally yields a token φ t for each input word token, namely the hidden state of the LSTM at that input.

Concatenated self-attention
MAAF concatenates the token sequences Φ = [φ x , φ t ] and passes the result into alternating self-attention and fully-connected layers as in the Transformer encoder [45].
Here self-attention refers to the operation where each of the query Q, key K, and value V matrices are calculated from the input sequence Φ by multiplying each token in the sequence by a learned matrix. Thus This mechanism allows each token to attend to any other, so an image token may be modified most strongly by another image token or by a text token. The output is another sequence of the same shape, which is added to the original sequence and possibly passed into subsequent layers with the same structure. Note that we use the same W Q , W K , W V for both modalities; after the initial token extraction the mechanism is agnostic to the origin of each token.
The attention map transformation f : R n → R n , where n is the number of key tokens (and the number of value tokens), is usually the softmax function as in [45]. As we discuss in sec. 3.1, however, we found that setting f to the identity function yielded significantly better performance on the CSS task.

Image-text cross attention
We also experimented with treating the image tokens as one sequence and the text tokens as another, using crossattention to allow text-image interactions as in the Transformer decoder [45]. Specifically, we use cross-attention operations and/or  Figure 2. Illustration of MAAF. A candidate image is indicated by the solid outline, and a target image is indicated by the dotted outline. Image tokens are extracted from blocks 3 and 4 of ResNet, then projected to 512 dimensions and flattened into a sequence. The modifying caption is fed through a single layer LSTM, which represents each word as a token. MAAF simply stacks all tokens and then applies scaled dot-product attention. The output is then average pooled.
self-attention within a modality and cross-attention between the modalities also allows these interactions, but we hypothesized that the modality-agnostic self attention method would work better. We provide empirical comparisons of these methods on the Fashion IQ dataset (sec. 4). We note that some image-text models for other tasks, such as ViL-BERT [31], have used separate image and text streams with cross-attention, while others such as VL-BERT [43] more closely resemble our modality-agnostic approach.

Embeddings
In order to obtain a single embedding for a given query (or catalog image), we pool the outputs across tokens. Specifically, we first average pool within each type of token, obtaining one vector of dimension 512 for the 49 image tokens corresponding to the last ResNet block, another single vector for the 196 tokens corresponding to the previous ResNet block, and another vector for the text tokens. These three vectors are then averaged, and the result is normalized.
The pooled embedding is multiplied by a learned scale parameter to get the final embedding vector. This scalar is initialized to 4, and it is important to learn it -leaving the scale parameter fixed instead greatly harms performance. Note this is equivalent to learning a temperature parameter in the softmax cross-entropy loss.
Catalog image embeddings are obtained in the same manner, except that there is no contribution from text tokens. Comparisons between image-text queries and catalog images are made using cosine similarity between the corresponding embeddings.
We considered several alternatives to the scheme described above for obtaining final embeddings for queries and catalog images. Table 2 compares the alternatives on Fashion IQ. RP refers to our "resolutionwise" average pool-ing, versus pooling all tokens equally. ITA refers to passing the catalog "images through attention" as opposed to only through the ResNet model. IT refers to including the text tokens in the pooling, as opposed to only the tokens corresponding to image features. Table 3 compares MAAF to existing methods on Fashion IQ.

Loss and training
We use a batch-based classification loss as in [47], with early experiments showing that the triplet loss performs worse by the recall@k metric. Each batch is constructed from N pairs of a query (image plus text) and its corresponding target image. The loss for the ith query is the cross-entropy between probability-like quantities softmax j=1,...,N and the one-hot vector with a 1 in the ith position. The model is trained at an initial learning rate of 0.001 for the image model parameters (which are pretrained on ImageNet when not otherwise stated) and 0.01 for all other parameters. The learning rate is decreased by a factor of 10 every 50k iterations and training is stopped at 150k iterations (except for the CSS dataset, see sec. 3.1). We use a batch size of 32 for all experiments. Our base model uses 2 attention blocks with query, key, and value sizes 512, 8 attention heads, and 256-dimensional fully-connected layers.

Experiments
We evaluate model performance on each dataset using "recall at k" (Rk for short), the fraction of queries for which a labeled "correct" result appears in the top k retrievals.
"make yellow sphere small" that serve as modification text for synthesized images in a 3-by-3 grid scene. Although it is a relatively simple dataset, CSS has the benefit of facilitating carefully controlled experiments. We therefore use it to perform a few qualitative analyses, which we present in Sec. 4, in addition to the quantitative results below.
Unlike most other datasets, larger configurations of our model trained on CSS exhibited overfitting, so we limited ourselves to configurations using block 4 (only) of ResNet50 and a single attention block. Additionally, we stopped training after 75K iterations. Replacing the softmax function with identity in the attention block significantly improved R1. Use of sinusoidal positional encodings as in [45] did not significantly improve performance when using softmax, and significantly impaired performance when using the identity function.

Fashion IQ
Fashion IQ [15] consists of ∼60K real-world product images (originally sourced from amazon.com) with human natural language sentences to facilitate the training of interactive image retrieval systems. The sentences are derived by tasking annotators with describing the differences between each target product image and a reference product image (e.g., "longer more dressy"). The product items were selected from three categories: Dresses, Tops&Tees, and Shirts. The training data consists of ∼36K examples, with ∼12K examples each for the validation and test splits. Within each split, examples are approximately equally divided across the three categories. The strongest models in competitions at recent conference workshops 1 were ensembles of weaker single models. In this paper we focus on single (not ensembled) models.
Since the three categories are fairly distinct, we draw each minibatch from a single category. 1 https://sites.google.com/view/lingir/fashion-iq

Comparisons to reported results and ablations
We find that our best model outperforms all other reported single models on the validation set, with the exception of a model reported in a technical report [27] that used extra non-public data. Since the model of [27] is very similar to TIRG [47] and results for their model trained without this extra non-public data are not available, we speculate that this text corpus is important to their increased performance relative to TIRG. We compare also to TIRG directly and find that our model performs better. See Tables 2 and 3 for full results, including detailed ablations of the design choices for our attention mechanism.
Other competition entries outperformed our best single model using ensembles of weaker models [53,54].

Attention model variations
We also investigated several two-stream variations of our attention mechanism to confirm that our primary singlestream variant performs best. Results of those experiments are shown in Table 4.

Text Representation
Self-supervised training of the Transformer model on large text corpora has proved effective for a variety of natural language tasks, including natural language inference, sentiment analysis, named entity recognition, and question answering [9]. A natural approach to encode a text sentence is to use this type of model to extract its highly contextual word feature representations. However, for Fashion IQ, which has only 4,769 words in the training set vocabulary, and whose modifying sentences contain only 5.4 tokens on average, it is not clear that such a large neural network is necessary or optimal for the problem. Therefore we did a comparative study of different sentence encodings. Table 5 compares the performance of MAAF when using only word embeddings (Embedding), versus the sequential word representations from a recurrent neural network (LSTM), versus context-aware word representations extracted by a self-attention model, learnable (Transformer) or pretrained (BERT). The experiments revealed that learning an LSTM from randomly initialized word embeddings is most effective for this task. A single embedding layer that treats the sentence as a bag of words performs only about 27% (relative) worse than the LSTM. We attribute this result to the simplistic nature of the modifying text sentences. Somewhat surprisingly, richer word context does not seem to benefit the task as evidenced by the weaker score obtained by a transformer with a single encoder block. Additionally, the model with large pretrained BERT for the text model achieves higher validation performance when the BERT weights are frozen during training. Fixing the embedding layer with the GLOVE weight matrix seems to hurt performance, with the exception of a single linear layer, where fixed GLOVE word embeddings impose a useful prior on the word distribution. We attribute this to the small size and fashion-specific domain of the vocabulary, which a co-occurrence matrix for more general vocabulary maps to a small region of the embedding space.

Birds-to-Words
Birds-to-Words [10] consists of images of birds from iNaturalist together with paragraphs humans wrote to describe the difference between pairs of these images. Each of 3,347 image pairs has on average 4.8 paragraphs, each describing the differences between the pair of birds in an average of 32.1 tokens. Birds-to-Words provides richer text descriptions in each example than any of the other datasets we study, although the number of examples is small. Forbes et al. [10] studied the generation of these fine-grained relative captions, but we adapt their dataset for the task of retrieving the described second image given the relative caption. We train our model according to the best configuration described in Section 3.2, but for only 30k batches to avoid overfitting. The baseline models are trained with the same parameters for the shared components, with the number of training iterations selected to optimize validation set performance. Table 6 shows our results for this task on the Birds-to-Words test set, which does not share images or descriptions with the training or validation sets.

Spot-the-Diff
Spot-the-Diff [26] consists of snapshots from surveillance footage together with single-sentence captions humans wrote to describe the differences between pairs of snapshots from one of 11 viewpoints at different times. There are 17,672 image-image-caption triples from 8,566 image pairs in the training set, 3,310 triples from 1,493 image pairs in the validation set, and 2,107 triples from 1,270 image pairs in the test set. The dataset was originally designed to study relative caption generation, but it provides a challenging setting for our task since images from the same source are highly similar. Table 6 shows results for our model and baselines on the test set.

Fashion200k
The Fashion200k dataset [17] as used in Vo et al. [47] consists of pairs of images of women's clothing products that differ by one attribute. The word for that attribute serves as the modifying caption. We took the best performing configuration of our model on Fashion IQ, and trained it in the same way on Fashion200k with essentially no changes. Table 7 compares the result to existing methods.

Qualitative results and visualizations
The simplicity of the CSS dataset (see sec. 3.1) allows us to probe our attention mechanism and visualize its behavior. We analyzed our model with softmax on this dataset, using only the 7x7 representation from block 4 of ResNet, and only one attention block. While each attention head may do something different, we observed systematic behavior by averaging attention maps over the attention heads and over data examples with particular properties.
For Fig. 3 36.6 ± 0.4  [46] 12.3 ± 1.1 FiLM [37] 12.9 ± 0.7 Param hashing [35] 12.2 ±1.1 Relationship [39] 13.0 ± 0.6 TIRG [47] 14.1 ± 0.6 Locally Bounded [23] 17.8 ± 0.5 VAL [5] 22.9 Ours 18.94 test set, then averaged them across attention heads. We then divided the examples into groups by position word (e.g. "top-right", "bottom-center", etc.), averaged over these groups, extracted the first 49 elements of the row of f (QK T ) corresponding to the token for the position word, and reshaped these elements into a 7x7 array. Fig. 4 illustrates the structure of f (QK T ) to help the reader understand this procedure. We thus obtained an image of how strongly, on average, "top-right" attends to each of the 7x7 image regions. Notice that in all cases, the region referenced by the position word is a dark spot surrounded by higher weights. The position word does not attend to the position it references; rather it attends to everything else.
This behavior -a word systematically ignoring what it references -seems to contradict the intuition provided by image captioning work. For example, Xu et al. [50] show that, in an attention mechanism linking words and text, words will in general attend to relevant regions of an image. Because in our setting the captions describe modifications to the image, and the model seeks a final embedding closer to the target image, a word may avoid attending to its referent since its referent in the query image will tend not to be informative about the target image.  Figure 4. The structure of f (QK T ) in concatenated self-attention, annotated with approximate areas devoted to each 'type' of attention (image to image vs. image to text). The blue square represents the 7x7 array of image tokens extracted from block 4 of ResNet; the red square represents the 14x14 array of image tokens extracted from block 3. Each 2d array of tokens is reshaped to a 1d array of tokens by stacking. Finally, the text tokens, shown in green, are added to the bottom. Fig. 5 shows that this counter-intuitive pattern appears to hold for color words as well. Here we use not the attention weights for the color word directly, but one minus these weights. The result is, for example, an image of what the word "red" ignores in the image, that is, what the word "red" systematically does not pay attention to. Fig. 5 shows the 1-minus-attention-modulated images averaged over examples containing each color word (excluding examples where the referenced object is being added), with the overall mean image subtracted. We again see that each color word systematically ignores the object to which it refers (i.e., an Figure 5. Averaged candidate images from the CSS test set, multiplicatively modulated by one minus the 7x7 attention map (averaged across all eight attention heads) produced by our network with a single attention block for color word tokens: red, yellow, green, cyan, blue, purple, brown and gray.
"much longer dress" "much shorter dress" "it has longer sleeves" object of that color). Figure 6 shows analogous images for Fashion IQ, showing some of the related effects that can occur in a less controlled setting than CSS. For words in the dataset that correspond to specific parts of a clothing item, such as short sleeves, or longer/shorter dress, we notice that several attention heads highlight the corresponding parts of the image. More interestingly, for additive changes such as "longer dress", the model shows high attention weights over the corresponding image region, whereas for subtractive changes such as "shorter dress", the model has negative attention weights over the corresponding image region, focusing on the remaining parts to keep.

Related Work
The ability of modern deep neural network architectures to extract highly semantic image features, as well as contextual and long-range text features, has ignited the study of tasks that combine image and natural language understanding. Most of the work in this field has been spurred by initial efforts to generate more discursive image caption descriptions (Image Captioning [46,42,38,2,41]), work often generalized to visual question answering (VQA) [3,33,11,2]. Other tasks such as visual grounding of text (so-called referring expressions), visual commonsense reasoning, and caption-based image retrieval have also received significant attention.

Fine-grained image retrieval
Several image retrieval challenges and corresponding datasets have fostered the study of domain-specific image feature extraction. In the fashion domain, datasets like Street-to-Shop [16], DeepFashion [30], and DeepFashion-v2 [13] are labeled with clothing item attributes, as well as which images correspond to the same product. The triplet loss was introduced as a way to learn from these paired label annotations in [22], and several sampling techniques for mining hard negatives were studied in subsequent works [40,20]. Other work explored variations of the loss function and related tasks such as face identification [22,8,48].

Image and text modeling with attention
Hu et al. in [24] demonstrate the benefit of incorporating attention for object recognition. The authors propose a "geometric attention" that seeks to account for the spatial relationships between object pairs. On the text side, several works have shown the importance of attention modeling for improved performance in tasks such as machine translation [4,45] and language modeling [9,7]. Most notably, the introduction of the Transformer architecture in [45], with its ability to model both self-and cross-attention, has enabled significant advances in the state-of-the-art for these and other tasks. Self-supervised pretraining on a large text corpus allowed BERT [9] to achieve still better results.

Joint visuolinguistic representations
Anderson et al. used text context to weight attention to image regions proposed by a bottom-up object detector for image captioning and VQA [2]. Previous approaches used spatial locations in a CNN feature map as objects of attention for these tasks [38,32,52,50,33,49,51,56].
Parallel to our work, several groups have developed models using attention mechanisms for joint visuolinguistic representations for tasks such as visual commonsense reasoning, visual question answering, referring expression comprehension, and image retrieval from captions. Several recent works [43,44,28,31,55,1,6] train BERTlike models on large-scale data to achieve general visuolinguistic representations which are then fine-tuned (possibly with modifications or additions) for these tasks. A similar model has also been trained directly on image captioning and VQA [29]. These models all extract features from the region proposals of an object detector, which is more appropriate for understanding scenes composed of multiple familiar objects than the fine-grained differences in single objects that we address. Another approach for related problems uses image patches [12]. We instead use the positional feature maps at multiple scales as image tokens, to learn both global (e.g. shape, size) and local features (e.g. texture, material) which an object detector cannot decompose.
Hosseinzadeh and Wang [23] approached the same task we address using fixed regions of image pixels to obtain image tokens for a cross-attention fusion mechanism similar to the ones we studied in section 3.2.2. Their approach is weaker on the datasets where comparison is possible.
Chen, Gong, and Bazzani [5] use outputs at multiple levels of a convolutional network to obtain image features at multiple scales for attention as we do, but their model fuses the text as a single vector with the image features before their attention mechanisms. This approach is substantially different and does not perform as well as ours on Fashion IQ, although it performs better on Fashion 200k, which uses single-word text modifications. We suspect that their approach is better suited for simple text whereas ours is better adapted for longer, more complicated text modifications. Table 2 shows the performance of several variations of the attention fusion mechanism on the Fashion IQ validation set, including means and standard deviations across five runs with identical settings but different random initializations. Below we clarify the meaning of each variation of our model.

S1. Detailed model ablations on Fashion IQ
A model with resolution-wise pooling (RP) performs average-pooling across the 7x7=49 image tokens from the last ResNet block separately from average-pooling across the 14x14 image tokens from the penultimate ResNet block. The results of pooling each of the two sets of tokens are then averaged to obtain the final embedding. A model without resolution-wise pooling simply treats all image tokens equally. We hypothesized that resolution-wise pooling would provide some benefit by correcting the overrepresentation of the finer-grained 14x14 features. Our experiments supported that hypothesis, but the size of the performance increase was comparable to the inter-trial variation.
A model with "image through attention" (ITA) uses the attention blocks even in the absence of a modifying caption. ITA can also be thought of as modifying the catalog images by the "null" caption containing no words, using the MAAF mechanism. A model without ITA directly uses ResNet features to represent the catalog images. Models with ITA consistently perform better by around 2 percentage points, suggesting that this is a better formulation for the task and an important part of our model. Note that ITA does not imply additional parameters, since the same attention blocks are used for catalog images as for the image-plus-text queries.
A model with "include text" (IT) includes the outputs corresponding to the text tokens in the final average pooling, allowing these tokens to directly influence the final embedding. Using this variation tends to have a small benefit. Table S1 shows the effect of ablating the 14x14 resolution inputs, while keeping RP, IT, and ITA (RP has no effect when only 7x7 inputs are utilized). We also tested the sensitivity of our model to the number of units in the fully connected layers following the dot product attention layers (Table S2) and the number of transformer blocks in our network (Table S3). Table S2 shows the performance of MAAF on Fashion IQ as we vary the size of the fully-connected layers in the attention blocks. The result is not very sensitive to this hyperparameter, and all other results in the paper use our original setting of 256.

S1.1. Cross-attention variations
MAAF uses perhaps the simplest dot-product attention mechanism for fusing representations from different modalities: we concatenate the "sequences" of tokens from each modality and treat each token in the resulting sequence equally. We also studied two-stream approaches where the architecture explicitly keeps the two modalities separate. To fairly compare the two-stream approach to our one-stream approach, we evaluated several variations of the two-stream approach in Table 4 of the main text. Here we clarify the computation performed by each of these models and why we expected that the one-stream approach would perform better. Table 4 shows the performance of several combinations of attention operations on Fashion IQ. In each case, a sequence of attention operations (each treated as a residual) is followed by a position-wise feedforward layer. Commas indicate operations performed in sequence, parallel bars || indicate operations done in parallel, i.e., the second operation does not use the outputs of the first operation.
We found that a model including all four operations in sequence did not train stably under our training scheme. We therefore used alternative learning rate schedules: dividing all rates by 2, and a simple "warm-up" starting with this lower rate for 5000 iterations. Results in Table 4 are reported for the best learning rate schedule for each model, usually the largest rate leading to stable training.
To see in detail how the different attention combinations relate to one another and to the single-stream approach, let x 0 denote the "sequence" of image tokens as input to the attention block and y 0 denote the sequence of text tokens. Then one head of image self-attention with a residual connection is (suppressing LayerNorm and Dropout for brevity) and cross-attention to the text is The most competitive two-stream attention block we found acts on image tokens in the following way In comparison, if we denote by φ 0 the concatenated sequence of image and text tokens, our MAAF one-stream attention is given by In particular, the image tokens in the output of MAAF are where is the denominator of the softmax f . Rewriting the twostream operation (8) more explicitly for comparison with (10), where B and C are softmax denominators, we can see that both operations include the same basic f (xx)x and f (xy)y interactions of the inputs x, y (up to constants and learned matrices). However, these equations also elucidate three potentially important differences between the two operations. First, in the two-stream operation the attention weights to the text tokens depend on x 1 , which has context from the other image tokens. Second, the softmax is computed over the imageimage and image-text attention weights separately in the two-stream case. Third, the two-stream case has an additional set of learnable parameters W Q1 , W K1 , W V 1 .
In our implementation of the two-stream model as two sublayers, there are also additional LayerNorm and Dropout operations which could have an effect. We also use multiple attention heads in each sublayer. The position-wise feedforward layers, however, are only applied after the operations in the equations above.
Which model would perform better is ultimately an empirical question, but our intuition favored the one-stream model. The one-stream model allows the same basic interactions with fewer parameters, and any benefit from using the post-self-attention x 1 for computing image-text attention weights could likely also be obtained from multiple blocks of the one-stream operation.

S2. Performance by type of modifier
To better understand the source of our model's performance gains, we evaluated it on subsets of the Fashion IQ validation set that included keywords of several types, e.g., color (red, blue, green, ...) and texture (stripe, solid, plaid, ...). Table S4 shows the results of this experiment. These modifier classes are not mutually exclusive since a caption like "is plaid blue and black" contains keywords for multiple modifier classes (in this case "plaid" texture and "blue and black" color). For all subsets, our model outperforms TIRG by roughly 16% relative on (R10 + R50)/2.

S3. Visualization of Attention Weights on
Fashion IQ Figure 6 in the main text displays the same effects that we have identified and explored in the CSS dataset, but in the less controlled setting of FashionIQ. For words in this dataset that correspond to specific parts of a clothing item, such as "short sleeves", or "longer/shorter dress", we notice that several attention heads highlight the corresponding parts of the image. More interestingly, for additive changes such as "longer dress", the model shows large attention weights over the corresponding image region; whereas for subtractive changes such as "shorter dress" the model shows small attention weights. Large and small attention weights here are to be understood in comparison to the attention weights for a randomly chosen word from the modifying caption.
For each word and modifying sentence in Figure 6 in the main text, we display the attention map averaged over multiple images in the test set. To minimize the noise due to the variance of different clothing items' absolute positions in the images, we clustered the grayscale images in pixelspace (using k-means with k = 5) and only consider the images in the largest cluster. The rescaled 14x14 attention weights computed for the first 200 images in that cluster,  Figure S1. Average image for each of the Fashion IQ clothing categories, over the whole dataset or the largest cluster in pixel space. are overlaid on the average of those images. These average images can be seen in the third row of Figure S1 below. The variation in clothing item position over the first 10 images in the largest cluster (row 2) is visibly smaller than that over the first 10 images of the whole dataset (row 1). This observation suggests that averaging attention maps for the same word over multiple examples in the same cluster could give a more consistent, spatially localized map. Figure 1 in the main text displays the top 3 retrievals using MAAF for several queries in the Fashion IQ validation set. Figure S2 displays the top 10 retrievals for 10 more randomly selected queries from the Fashion IQ validation set. Note that the dataset does not contain exhaustive labels, so some appropriate retrievals are not labeled as correct.

S4. Retrieval examples on Fashion IQ
The two captions provided for each query are displayed joined by "+" and without modification. The captions are presented in this manner to the model but with punctuation removed and all letters lowercase. We made various efforts to normalize the text by spell checking, lemmatization, and stopword omission, but in early experiments these steps did not improve the performance of our models and so were not used for the experiments in the paper.

S5. MIT States
The MIT States dataset [25] consists of about 60k images, each with an object/noun label and a state/adjective label. To compare with [47], we evaluate image retrieval using queries of an image together with the state/adjective for a target image with the same object/noun. The nouns in the test set are not seen during training, so the system needs to apply adjectives it knows to unseen objects. Table  S5 shows our results compared to other existing models. Figure S2. Example retrievals on the Fashion IQ validation set. A green rectangle indicates the labeled "target" for the query.