V ec2 S ent: Probing Sentence Embeddings with Natural Language Generation (2020)

Abstract: We introspect black-box sentence embeddings by conditionally generating from them with the objective to retrieve the underlying discrete sentence. We perceive of this as a new unsupervised probing task and show that it correlates well with downstream task performance. We also illustrate how the language generated from different encoders differs. We apply our approach to generate sentence analogies from sentence embeddings.

## introduction generalizing the concept of word embeddings to sentence level, sentence embeddings (a.k.a. sentence encoders) are ubiquitous in nlp as features in downstream classification tasks and in semantic similarity and retrieval applications @xcite . probing sentence encoders for the linguistic information signals they contain has likewise become an important field of research, as this allows to introspect otherwise black-box representations @xcite . the idea behind probing tasks is to query representations for certain kinds of linguistic information such as the dependency tree depth of an encoded sentence. there are a variety of problems surrounding current probing task specifications: (i) probing tasks need to be manually construed, which brings with it a certain degree of arbitrariness and incompleteness; (ii) most probing tasks require labeled datasets or trained classifiers such as dependency parsers for linguistic processing-however, these may be unavailable for many low-resource languages or available only to a limited degree; (iii) it is not entirely clear how probing tasks have to be designed, e.g., how much training data they require and which classifier to use for probing @xcite ; (iv) @xcite also argue that standard probing tasks do not outline the information signals a classifier actually uses for making predictions. our contribution is to design an alternative, more direct introspection of sentence embeddings, namely, through conditional natural language generation, which we call "vec2sent" (v2s). by retrieving and (manually) investigating the discrete output obtained from a dense vector representation, linguistic properties of the embedding may be 'directly' unveiled: e.g., we expect that a word-order insensitive model would have a comparatively hard time in restoring the correct syntax of an encoded sentence. v2s requires no labeled data, making it applicable to any language that has at least several ten thousands of written sentences available-e.g., it is particularly suitable for multilingual probing @xcite . since v2s makes the opaque space r d observable, it may also reveal intriguing properties of how encoders encode text (cf. ## approach for an input sentence @xmath0, consider its sentence representation @xmath1. we consider a decoder d which takes x as input and produces natural language text as output. we train d to reconstruct x from x. for simplicity, we design d as a recurrent neural network (rnn) with lstm cells, rather than as a more recent model class like transformers. at each time step i in the rnn, the goal is to predict the next word given the previously generated word y i-1 as input as well as the hidden state vector h i which summarizes all past observations. to implement generation conditional upon the sentence embedding x, we concatenate the embedding x to each input embedding (y i-1 ). figure 1 illustrates our approach. figure 1: schematic illustration of our approach: a pre-trained sentence encoder e maps the input x to a vector x. this vector is fed into an rnn language model. the output @xmath2, y 2 , . . .) generated by the conditional rnn is finally compared to the original input sentence. in general, v2s translates from a continuous vector space to a discrete language space, while an embedding model performs the inverse operation: the continuous space in which x lies is 'opaque' (to humans) and requires probing tasks for introspection. the discrete space in which x lies can easily be introspected by humans (at least at small scale). an interesting application of the duality of e and v2s is that one can interpolate any two vectors x and y via z(α) = α • x + (1 -α)y-using v2s, one can then decode z(α) to derive its discrete representation for all sentences z(α) "between" x and y. analogously, we could decode sentence representations to find analogies akin the famous king-woman+man equation for word embeddings @xcite . ## discussion & conclusion the goal of probing tasks is to make the opaque embedding space r d "linguistically" observable to humans. a plethora of different probing tasks have been suggested @xcite @xcite , which @xcite classify into surface, syntactic, and semantic probing tasks. more recently, multilingual extensions of probing tasks @xcite @xcite have been considered, as well as word level probing for especially contextualized representations @xcite . in the latter context, @xcite discover an intriguing structural property of bert, viz., to contain whole syntax trees in its representations, possibly, as we show, at the expense of lexical information (at least sbert). we investigated v2s as an alternative, direct way of probing sentence encoders. we showed that v2s may be a good predictor of downstream task performance and, in particular, that one of two simple diagnostic tests had good predictive performance in all scenarios: whether an encoder can exactly retrieve the underlying sentence from an embedding (id) and whether the fraction of exactly retrieved sentences among all retrieved sentences that are permutations of the input sentence is high. thus, we recommend to report both of these diagnostic tests for v2s. we also showed that v2s allows to directly introspect for certain structural properties of the embedding space, e.g., sentence-level semantic analogies. v2s is an unsupervised probing task and, as such, we believe that a particularly interesting use case will be for low-resource languages and scenarios, for which our experiments suggests that it will be a much better predictor of downstream task performance than the equally unsupervised (and most closely related) wc probing task.