Sky + Fire = Sunset. Exploring Parallels between Visually Grounded Metaphors and Image Classifiers (2020)

Abstract: This work explores the differences and similarities between neural image classifiers’ mis-categorisations and visually grounded metaphors - that we could conceive as intentional mis-categorisations. We discuss the possibility of using automatic image classifiers to approximate human metaphoric behaviours, and the limitations of such frame. We report two pilot experiments to study grounded metaphoricity. In the first we represent metaphors as a form of visual mis-categorisation. In the second we model metaphors as a more flexible, compositional operation in a continuous visual space generated from automatic classification systems.

## introduction visually grounded metaphors are metaphors that function on the visual similarity between two objects. humans use visually grounded metaphors to describe scenes or objects in a vivid way: we could call a large person an elephant, describe somebody's blue eyes as a clear summer sky; and so forth. the basic idea is that using a metaphoric element to "overlay" on the described object creates, in the imagination of the reader or listener of the metaphor, a stronger and effective mind picture. at the same time, the mechanisms and workings underlying metaphors remain unclear. grounded metaphors are among several categories of metaphors that work on the interplay of all five senses plus the abstract dimension of language. some of these metaphors and similes are harder to model: the precise reason why a cold voice creates the idea of a specific tone and sound of voice, or why some other synesthetic expressions like a blue music work in the human brain is difficult to define. visually grounded metaphors, unlike metaphors that draw from several senses, could be easier to model: and we could try to study them by applying the visual models used for image captioning in nlp. the central question of this paper is whether, and to to what degree human visual metaphors can be reproduced using image features trained in the image captioning scenario. this pilot study defines some possible lines of exploration through two small scale experiments that lead to further research in this area of connecting language and vision and modelling of metaphorical language. more data and analyses will be necessary to further deepen the topic. ## state of the art a large bibliography has discussed the relation between language and perception and the way linguistic meaning is expressed linguistically and non-linguistically. this is done by grounding word meaning in visual perception @xcite and testing the compositionality of visuallyenriched language representations @xcite , and more recently even using sensorymotor robotics to model lexico-grammatical patterns @xcite , often for the construction of multimodal or dialogue agents @xcite , under the general assumption that many aspects of language cannot be captured without extra-linguistic information @xcite . despite this and the existence of consolidated linguistic work about the mechanisms of the underlying metaphor processing @xcite , the research on the topic of metaphor and grounded language models is quite scarce and has focused on the use of visual features to identify metaphors @xcite . the common practice in the domain is currently to attempt metaphor identification and modelling through linguistic data only @xcite @xcite neurolinguistic studies such as @xcite show that the literal properties of terms are still activated if those terms are used metaphorically, confirming the idea that metaphors create a compositional feature transfer between source and target: for example, senso-motory verbs used in metaphorical ways still activate their "normal" senso-motory paths in the brain, a behaviour that distinguishes metaphors from idioms @xcite . other studies, such as @xcite , show that some abstract concept, like power, seem linked, in the brain, to a spatial feature, like the vertical up-down dimension, which would, according to the study, account for the spatial metaphors of power that tend to visualise hierarchy on a vertical axis. in short, several studies in neurolinguistics support the idea that many metaphors do indeed rely on sensory knowledge @xcite . reproducing these mechanisms in computational models is the main idea behind our project. the goal of our study is to examine to what degree these observations are reflected in the performance of image classification deep neural models trained on images. the way image classification models both represent and categorise pictures can help us understand better to what extent grounded compositional metaphors are actually grounded (section 4) and compositional (section 6). ## models for our study we use pre-trained visual object classification models available in keras @xcite . the two main models used in this work are resnet50 @xcite and vgg16 @xcite . for comparison we also use vgg19 @xcite and inceptionresnetv2 @xcite . in the versions we use for this study, the networks were pre-trained on 1,000 object categories from imagenet. unlike the systems used for articulated image description, these models generate single token captions. @xcite . all models operate through in three steps: (i) the model takes an image as input; (ii) using the pre-trained weights the model transforms the image into a vector that represents its main features; (iii) the model's final layer operates a prediction or classification over such a vector. since the categories are limited (here to 1,000) and the models imperfect, mis-categorisations occur. ## mis-categorisations a classifier presented with an image will output a list of possible captions or descriptions, with confidence scores that indicate the similarity between the output category and the image. for example, if presented with a picture of a bird, resnet50 will output the following probabilities: the gap in probabilities between the first and the second prediction is large, and the probabilities after the 4th item are insignificant. it is possible to notice how in all cases the model's predictions are based on the main features of the elephant's shape: the output's classes share some visual similarities with the indian elephant, in a decreasing order of overlap. the model predicts, in order, the indian elephants; other kinds of elephants; and other animals that in resnet50's ontology share important properties with the indian elephant. the reader can observe that the suggested alternative species have common characteristics of being massive four-legged animals and in many cases displaying prominent tusks. we can compare the network's behaviour with the strategies a human would adopt in the attempt to describe a specific animal to someone who has never seen it before: looking for other animals sharing some similarities with it. this mechanism becomes even more evident if we present the network with a category that was absent from its training data, or that was too rare in the training to allow the model to generalise on its features. let's take for example figure 1 , an image of a fire on a dark background. the keras' pre-trained model of resnet50 lacks the category "fire" in its training dataset, and if presented with this picture, the model returns the following list of probabilities over categories: stove (0.85), fire screen (0.14), dutch oven (0.002). the network identifies categories of objects in which fire is a likely component. being unable to figure out the object's category with confidence, the model returns captions drawn from categories of objects that share some properties with the presented image. the picture's background and style play important roles as well. for example, resnet50 categorises the leftmost image in figure 2 , a drawing representing a dragon, as comic book (0.28) or laptop (0.08), and the rightmost image figure 2 , a statue of dragon, as pedestal (0.61), fountain (0.38) or palace (0.0005). in both cases the classifier focuses on the "style" of the objecta drawing in the first case, a statue in the second case -to attempt a low-probability classification. mis-categorisations can happen if the object appears in a new or unusual way that confuses the network. for example, resnet50 has various bridge categories in its ontology such as steel arch bridge, but it tends to classify pictures of small bridges mirrored in the water as viaduct or lakeside, being confused by the elements present in the image. similarly, it labels an aerial picture of a large modern bridge crossing the sea as bannister (0.44) or dam (0.03). as in the previous cases, the model looks for objects that pertain to the same field or conceptual area of the difficult image: to categorise bridges the models look for dams, viaducts and so on. in the same way, if presented with a picture of a church, the model suggests church (0.93), bell cote (0.02), monastery (0.02), and it tries to describe the burj khalifa as a mosque (0.13), a palace (0.08), a bell cote (0.07) or an airship (0.06). the last association is of particular interest for our study, since the model moves out of the conceptual domain of the picture to look for similarities in different areas. but what happens if the model is presented with an image belonging to a conceptual domain completely unknown? for example, "our" resnet50 lacks in its pre-trained categories every thing pertaining to the sky: clouds, planets and stars are absent from its ontology. if presented with a classical image of saturn, the model predicts candle (0.81). we suspect that the reason of this unexpected elaboration lies in the colour of saturn's atmosphere, that is similar, in some pictures, to a candle's wax colour. in other situations, the network focuses on background elements that it recognises. for example, this model is also not trained on people: it cannot label a person as person. if presented with the image of a person in a bathtub, the suggested captions are bathtub (0.08), bath towel (0.07), tub (0.06). for similar reasons, and showing some politically incorrect bias, the model labels the person in figure 3 as prison (0.05), jean (0.02) and barrow (0.06). in a picture representing a breaking storm over the sea, resnet50 -not "knowing" what a storm ispics the peripheral elements: breakwater and pier. the abundant literature on object classification has duly noted these systematic mistakes @xcite . the main intuition of this study is that some of these mis-categorisations seem to make a metaphoric sense for a human reader. for example, resnet50 classifies a picture of lightnings as spider web. although this may seem like an unexpected comparison, there are several pictures of lightnings on the internet that are described by human annotators as spider web lightning due to their thread-like and branching shape. on the other hand, if a model labels the picture of a man sitting by a fire as a volcano, the metaphoric power of the classification becomes doubtful (although not necessarily absent). to explore the parallels and differences between human visually rooted metaphors and visual models' mis-categorisations, we collected through manual online search a dataset of 100 pictures that human users had described with a metaphor or simile as shown in figure 5 . we exclusively selected metaphors that had only their target in the 1,000 im-agenet categories present in our models' ontology: for example, images of lightning (source, absent from the ontology) described as spider webs (target, present in the ontology), or fireworks (source, absent from the ontology) described as sea urchins (target, present in the ontology). with such a dataset it is possible to see, to a limited extent, whether the mis-categorisations performed by the models confronted with unforeseen elements go in the direction of the metaphors and similes humans conceive to provide a vivid description of an object. if a human captioner described the image of a sponge (absent from the models' ontology) as a harp (present in the models' ontology), and our models categorise the same image as a harp, there is an overlap between the two frames. if, as in this case, our models categorise the same image as something else, e.g. a barn spider, there is a difference between the two frames. ## visual spaces the category of cigarette is absent from the ontology of the models we use in this study. if presented with a cigarette, most models see a ruler or a band aid. the classification step happens in the last layer of the networks: before that final layer, each model transforms its input picture in a 1x224x244x3 tensor that encodes the relevant visual features of the picture as a 4-dimensional set of weights. from such tensor the model draws a 1x1000 vector that represents the probability of such tensor to fall in each one of the 1000 categories. this characteristic, shared by most neural classifiers, opens the possibility of exploring visually rooted metaphors as operations in a continuum, by using the final tensor extracted by each picture as a vector in a multi-dimensional space. returning to the cigarette example, our vgg16 model cannot recognise any of the objects or symbols present in figure 6 . the last picture confuses our model which miscategories it in a different way than the previous two images: the model fails to pick the similarities evident to a human eye. but if we flatten the precategorisation final tensors created by the model to represent these three images and compute their cosine similarity, we might be able to overcome the rigidity of the classification step. here are the results of such trial: the cosine similarity between the cigarette (a) and the danger sign (b) is 0.5, as the two pictures are different. but the similarity between (b) and the cigarettes are dangerous sign (c) is 0.68, while the similarity between (a) and (c) is as high as 0.83. in other words, the visual similarity that the multi-class classification frame kept latent clearly emerges. model top 1 top 5 top 20 vgg16 0.25 0.39 0.57 vgg19 0.23 0.33 0.54 inceptionresnet 0.00 0.01 0.05 resnet50 0.26 0.39 0.53 to strengthen this frame, we create visual vectors that represent several images of the same concept in order to create "conceptual" clusters or, in other words, new "classes" for our experiment without the need of a full new training set. for example, if we sum the flattened output tensors for two danger signs we obtain a new vector that "represents" both danger signs' relevant features. this approach seems to return better results. if we compute the cosine similarity between three different danger signs' tensors, we obtain an average similarity of 0.64. but if we sum two danger signs' tensors and compute the cosine similarity of the resulting tensor with the left-out picture's tensor, the average similarity rises to 0.73. in other words, by summing two danger signs' tensors we created a visually meaningful centroid in the feature space that represents better than any single image the essential appearance of a generic danger sign. it is possible to imagine that adding more pictures would make a more consistent representation. however, the most interesting aspect of this approach for our study is the possibility of obtaining a reasonable effect without the need of collecting large datasets or training the model from scratch. the same effect happens with the cigarette pictures: if the cosine similarity between two simple pictures of cigarettes as in figure 6 (a) is 0.95, the cosine similarity of a single cigarette vector with the summed vector of two other images of cigarettes rises to 0.99. now we can compute the similarity between cigarettes, danger signs and cigarettes are dangerous disclaimers of the kind presented in figure 6 as a cosine similarity between vectors. through this simple operation the similarity between the danger signs' vector and the disclaimers' vector rises up to 0.81, and the similarity between the cigarettes' vector and the disclaimers' vector rises to 0.87. if we sum the cigarettes' vector and the danger signs' vector and compare the result with the anti-smoke disclaimers' vector, the cosine similarity goes to 0.92. this high similarity does not seem to be the effect of noise: the similarity of the anti-smoke disclaimers' vector and a vector of an unrelated picture, such as an image of a firework, is -0.8.the essential visual similarities that make the symbolic disclaimer in figure 6 (c) understandable for humans are retrievable from the visual feature space. to prove the concept, we computed the cosine similarity between the danger signs' vector and the individual vectors of all the pictures present in the dataset described in this study. despite more than 100 confounders, the three pictures of danger signs came with the highest ranking, followed by the two antismoke disclaimers. we then repeated the operation with the (danger+cigarette) vector, that retrieved all the cigarettes as most similar pictures. this leads to our final investigation. ## adding fire to the sky: compositionality in visually grounded metaphors a visually grounded metaphor sometimes used to describe an impressive sunset is the sky is on fire. this is a simple and effective grounded metaphor: the reader or listener "adds" the colours and intensity of fire to the sky in order to imagine a vivid sunset. if this metaphor is indeed rooted in visual data and visual data only, this is the operation we should be able to perform in the visual space to "create" a sunset vector. through online manual search we collected 8 pictures of sunsets described as sky on fire by their captioners. the individual vectors of some of these pictures already present the similarities necessary for the metaphoric shift: out of 8 pictures described as sky on fire 2 retrieved as most similar picture in our dataset a picture of a fire with an average cosine similarity of 0.6, and another 4 had pictures of fire among the first ten most similar elements, with an average cosine similarity of 0.5. figure 8 : a schematic visualisation of the cosine similarities between the sky, the fire and the sky on fire vectors. the sky vector is relatively similar to the sky on fire vector and further away from the fire vector. but is it possible to reproduce the compositionality of this metaphor in the visual space? to answer this question, we created a sky vector out of 10 pictures of (mainly blue) skies such as the one in figure 7 (a). the average cosine similarity of these pictures is around 0 (the lowest possible cosine similarity is -1). this relatively low similarity between sky pictures is probably due to the lack of stable and recognisable shapes in the "concept of sky": most of our sky pictures featured a of varying hue background sometimes with some clouds, and the clouds' shapes varied constantly. we then created a fire vector out of 13 pictures of fire such as the one in figure 7 (b) with average cosine similarity figure 9 : a visually grounded metaphor in the visual space. if we sum the sky vector with the fire vector, we create a "metaphoric" new vector which is closer to the sky on fire vector than the simple sky vector was: adding fire to the sky seems an effective way to recreate a sunset. of 0.6. finally, we created a sunset vector out of 7 pictures of sunsets captioned by humans as sky on fire, as the one in figure 7(c ). the average cosine similarity between the pictures of this group is 0.74. as represented in figure 8 , the cosine similarity between the sky vector and the fire vector is low: -0.5. the objects, sky and fire, have little in common in terms of visual features. the cosine similarity between the sky and sky on fire vectors that represent the same object under different conditions is higher: 0.64. if we sum the vectors of sky and fire, we create a sky-fire vector as shown in figure 9 . the cosine similarity of this new vector with the sky on fire vector rises to 0.82. in other words, adding the metaphoric fire to the literal sky made the sky vector closer to the sunset vector. the compositional sky on fire metaphor seems to work in our visual space (see figure 9 for a visualisation). although this is a particularly clear case of visual compositionality, metaphoric compositionality of this kind seems to be present also in other examples. in collecting pictures that represent such metaphors from online data is a difficult task. the metaphors have to be compositional, visually grounded and included in captions. we thus collected a tiny dataset of 22 such metaphors (some of which we include in every time the modifier increases the similarity between a true metaphor's source and target, we count it as a true positive. every time the same happens for a false metaphor, we count it as a false positive . we show the performance of the inceptionresnet and resnet50 models on this dataset in for both classifiers, the majority of the real metaphors improved (in terms of source-target cosine similarity) if we added the modifier with the source: in other words, in over 60 per cent of the cases we reproduced the mere visual compositionality of these metaphors. at the same time, the majority of the false metaphors got worse (in terms of souce-target cosine similarity) if we added the modifier to the source, confirming that the effect is linked to the visual compositionality of such expressions. ## conclusions and future works we conceived this study as an exploration of visually grounded metaphors in two experiments and two tiny datasets. in the first experiment we focus on categorisation: two image captioning models classified pictures of previously unseen elements and compared them with human-generated metaphors for the same pictures, returning a low overlap between human generated metaphors and models' mis-classifications. it is important to keep in mind that metaphors are flexible and diverse, and some of the mis-classifications of the models might be valid metaphors for humans -they were just absent from the specific dataset we collected. in this respect, an overlap of 30% between human metaphors and the first 5 captions produced by the models is encouraging. in a number of cases, the mis-classifications of the models do not seem to align with anything similar to a human-like metaphor, especially if variables like background or peripheral elements come into play. this doesn't mean that the so-called visually rooted metaphors are not visually rooted: but they might rely on either more complex similarity that were not captured by our models, or on a composition of visual and extra-visual world knowledge. in the second experiment we focus on unsupervised composition using a multi-dimensional visual feature space that offers a flexible representation for our domain. using an unsupervised approach we cannot produce a comparison against a labelled dataset as in the classification experiment. however, we do show that the apparent visual compositionality in several metaphors can be predicted in the visual feature space. in most cases adding the metaphoric modifier to the metaphor's source made the source and the target closer than they were before. this shift indicates that the metaphors are grounded in the visual features that are encoded by image classification models. the visual elements present in those metaphors are working in the visual space and account for the effectiveness and flexibility of the metaphoric expressions. there are several ways to continue from this study. first of all, our datasets are very small. collecting larger corpora of visually grounded metaphors and relative pictures would be necessary to expand our study. this would also imply finding more systematic ways of selecting both the metaphors and their pictures, since for these studies we used our sole sensibility to select and collect the examples. it would also be interesting to add more complex cases, especially when operating on the continuum visual space, and to compare the compositional efficiency of different metaphors. while such selection and collection steps are challenging due to the complex nature of the problem we study, the ever-growing wealth of annotated pictures makes us optimist about its feasability. an open question remains to what degree different metaphors are grounded visually and to what degree they can be predicted from the language models. it would also be interesting to check which visual clues are most useful to the classifiers when they reproduce human metaphorical combinations. finally, even if no human ever produced a specific metaphor, this doesn't mean that such metaphor is bad: it would be interesting in the future to measure the level of human appreciation of visually grounded metaphors generated through image captioning. these will be the foci of our future work.