Representation of Lexical Stylistic Features in Language Models’ Embedding Space (2023)

Abstract: The representation space of pretrained Language Models (LMs) encodes rich information about words and their relationships (e.g., similarity, hypernymy, polysemy) as well as abstract semantic notions (e.g., intensity). In this paper, we demonstrate that lexical stylistic notions such as complexity, formality, and figurativeness, can also be identified in this space. We show that it is possible to derive a vector representation for each of these stylistic notions from only a small number of seed pairs. Using these vectors, we can characterize new texts in terms of these dimensions by performing simple calculations in the corresponding embedding space. We conduct experiments on five datasets and find that static embeddings encode these features more accurately at the level of words and phrases, whereas contextualized LMs perform better on sentences. The lower performance of contextualized representations at the word level is partially attributable to the anisotropy of their vector space, which can be corrected to some extent using techniques like standardization.

## introduction the style of a text is often reflected in its grammatical and discourse properties, but also in local word choices made by the author. the choice of one from a set of synonyms or paraphrases with different connotations can define the style of a text in terms of complexity (e.g., help vs. assist), formality (e.g., dad vs. father), figurativeness (e.g., fall vs. plummet), and so on @xcite . these lexical stylistic features can be useful in various scenarios, such as analyzing the style of authors or texts of different genres, and determining the appropriate word usage in language learning applications. previous approaches to formality detection relied on word length, frequency, as well as on the presence of specific prefixes and suffixes (e.g., intra-, -ation) @xcite . such features have also been used for complexity detection, often combined with information regarding the number of word senses and synonyms @xcite . recent studies have shown that the representation space of pretrained lms encodes a wealth of lexical semantic information, including similarity, polysemy, and hypernymy @xcite @xcite @xcite . in particular, abstract semantic notions such as intensity (e.g., @xmath0. in this paper, we explore whether lexical stylistic features can also be identified in the vector space built by pretrained lms. to do this, we extend the method of garí soler and @xcite to address complexity, formality, and figurativeness. we first construct a vector representation for each of these features using a small number of seed pairs shown in we experiment with various static and contextualized embeddings on five datasets, containing words and phrases (doctor vs. medical practitioner), or sentences (those recommendations were unsolicited and undesirable. vs. that's the stupidest suggestion ever.). our results show that both types of representations can capture these stylistic features reasonably well, although static embeddings perform better at the word and phrase level, and contextualized lms at the sentence level. we hypothesize that the sub-optimal performance of contextualized lms on short texts might be partially due to the high anisotropy of their embedding space. anisotropic word representations occupy a narrow cone instead of being uniformly distributed in the vector space, resulting in highly positive correlations even for unrelated words, thus negatively impacting the quality of the similarity estimates that can be drawn from the space @xcite @xcite . we verify this hypothesis by implementing different anisotropy correction strategies @xcite and discuss the observed improvements in contextualized representations' performance on short texts. overall, our findings contribute to the big picture of probing literature, showing that stylistic features like complexity, formality, and figurativeness can be decoded from the embedding space of pretrained representations using simple calculations, without any supervision. our lightweight method can be easily integrated into downstream applications like authorship attribution and style transfer. ## related work there has been an extensive body of literature on probing techniques aimed at identifying the linguistic and world knowledge encoded in lm representations. for example, given a machine translation model, does it implicitly capture the syntax structure of the source text? existing work addresses such questions with methods like auxiliary classifiers (a.k.a. probing/diagnostic classifiers) @xcite @xcite , information-theoretic probing @xcite , behavioral tests @xcite @xcite , geometric probing @xcite @xcite , visualization of model-internal structures @xcite , and so on. using these methods, researchers have found that pretrained lms do encode various types of knowledge, including syntactic @xcite , semantic @xcite @xcite , pragmatic @xcite , as well as factual and commonsense knowledge @xcite . our work is along the line of probing for lexical semantics with simple geometry-based methods @xcite , which uncovers the target knowledge encoded in the semantic space of lm representations with simple geometric computations @xcite . compared to the most widely used auxiliary classifier method, geometric probing does not rely on any external model. thus, it requires no annotated training data and avoids the potential issue of the external model itself learning the target knowledge @xcite . directly related to our work, garí soler and apidianaki (2020) proposed a method to detect the intensity of scalar adjectives, where an "intensity" dimension is identified in the vector space built by the bert model. the method draws inspiration from word analogies in gender bias work, where a gender subspace is identified in the embedding space by calculating the main direction spanned by the differences between vectors of gendered word pairs (e.g., -→ he --→ she, --→ man ------→ woman) @xcite . similarly, garí soler and apidianaki (2020) view intensity as a direction in the embedding space which is calculated by subtracting the vector of a low-intensity adjective from that of a high-intensity adjective on the same scale (e.g., ------→ awesome ---→ good, -----→ horrible --→ bad). intuitively, this subtraction cancels out the adjectives' common denotation and retains their variance in intensity, which is represented by the resulting difference vector ( ---→ dv ec). this vector can then be used to determine the intensity of new adjectives by simply taking the cosine similarity of their vector to ---→ dv ec. we extend this method to other lexical stylistic notions, and address words of different part-of-speech (pos) and longer texts. ## method we adopt the definitions for the three stylistic features of interest (complexity, formality, and figurativeness) proposed by previous work. simple language is "used to talk to children or non-native english speakers", whereas more complex language is "used by academics or domain experts" @xcite . formal language is defined as "the way one talks to a superior", whereas casual language is "used with friends" @xcite . figurative language is defined by @xcite as utterances "in which the intended meaning differs from the literal compositional meaning", while literal language exhibits no such difference. unlike the previous two features, figurativeness is often a contextual instead of lexical feature (e.g., the word adhere is used in a metaphorical sense in the expression "adhere to the rules" and in its literal sense in "adhere to the wall"). 2 we explore the usability of our method for studying figurativeness by using a small seed 2 in the literature, figurativeness is generally studied at the level of utterances @xcite @xcite . some studies also look at the semantic properties of words and phrases as indicators for metaphor identification @xcite @xcite . set of synonyms and paraphrases that have literal and figurative connotations (e.g., @xmath1. these pairs are only used for constructing our figurativeness vector representation, while our evaluation is performed on a dataset containing full sentences (see section 4 for details). our method involves two steps: (a) feature vector generation, where we construct a vector representation for each feature; and (b) feature value prediction, where we predict how strongly a new piece of text exhibits some target feature using the constructed feature vector. we illustrate the two steps below. feature vector generation. we collect a small number of seed pairs to illustrate each notion, shown in ## experimental setup evaluation task and metrics. we evaluate the representation of the target features in a binary classification task: given a pair of texts (words, phrases, or sentences) t 0 and t 1 that are semantically similar but stylistically different in terms of some feature f (e.g., figurativeness), the task is to decide which text exhibits the feature more strongly (e.g., is more figurative). for example, given two sentences "you must adhere to the rules." (t 0 ) and "you must obey the rules." (t 1 ), the ground truth is that t 0 is more figurative. we use accuracy as our evaluation metric. seed pairs. for each feature, we use seven seed pairs for vector generation, as shown in the seeds for complexity are examples from the paper describing simpleppdb @xcite , and the seeds for formality are from the paper on lexical style properties of paraphrases @xcite . for figurativeness, we manually compile a set of seven seed pairs. datasets. the datasets used in our feature value prediction experiments (described in for each dataset, we select the optimal configuration (see the configuration paragraph below) using the validation set, and report its performance on the test set. to make the label distribution balanced, we randomly shuffle the order of the two pieces of text in each pair and re-assign the gold label accordingly. this ensures that a majority baseline only performs around chance. figure 2 shows the distribution of token frequency in each dataset. 4 baselines. we compare our method to two simple baselines. the majority baseline always predicts the majority label in the dataset. the frequency baseline consults the frequency counts of each token in the google n-gram corpus @xcite and considers more frequent tokens to be simpler, more casual, and more literal. frequency has been a strong baseline for complexity and formality in previous work, given that rare words tend to be more complex than frequently used words @xcite . ## results and discussion we observe that our method outperforms the majority and frequency baselines with both static and contextualized lms. furthermore, mean pooling generally works better than max pooling, although there is still room for improvement. taking a closer look at the optimal configuration for each feature, for complexity, roberta-large and mbert-base are the dominant best-performing models, yet there are no consistently dominant layers; for formality, bert-base and mbert-base perform the best on short texts and surprisingly with the initial layers (0 or 1), while roberta-large is the best model for long texts with middle or final layers; for figurativeness, bert-large is consistently the best model across all settings. interestingly, contextualized lms far outperform static embeddings on long text sin almost all cases, yet on short texts, static embeddings perform on par or sometimes even better than contextualized lms. this is the case, for example, with formality "short" (with both pooling strategies) and with complexity "short" (with max pooling). this finding sounds counter-intuitive, given the generally higher performance of contextualized models in various nlp tasks. in our probing setting, we suspect that this might be due to two factors. first, the input in short-text datasets consists of isolated, rather than contextualized, instances of words. this is not natural input for a contextualized lm. second, previous work has demonstrated that the word-level similarity estimates obtained from the vector space of contextualized lms might be distorted due to the anisotropy of the space @xcite . concretely, anisotropic word representations occupy a narrow cone instead of being uniformly distributed in the vector space, resulting in excessively positive correlations even for unrelated word instances. this has a negative impact on the informativeness of measures such as the cosine and the euclidean distance, often used for estimating representation similarity (apidianaki, 2023). these measures are dominated by a small subset of "rogue dimensions" which drive anisotropy and the drop in representational quality in later layers of the models @xcite . in section 6, we investigate more closely the impact of anisotropy on our results through a series of experiments involving different anisotropy reduction methods. finally, comparing the single layer and layer aggregation settings, their respective optimal configurations result in mostly similar performance across datasets, as shown in in the next two subsections, we analyze the influence of two more factors on our method: layer depth and text length. for conciseness, we only report the results for the layer aggregation setting. results for the single layer setting are given in appendix c. ## anisotropy reduction experiments as explained in the previous section, the anisotropy of contextualized lms' representation space degrades the quality of the similarity estimates that can be drawn from it @xcite . to see if this has an impact on our method, we apply three post-processing anisotropy reduction methods discussed by @xcite , which can be used to correct for rogue dimensions and reveal underlying representational quality. we apply each of these methods to our feature vector construction and feature value prediction processes. given that our stylistic characterization of new text relies on similarity measurement, we expect that a space that allows us to draw higherquality similarity estimates would better represent these stylistic features and would also improve feature value prediction. the three methods used in our experiments are: ## conclusion we have shown that the embedding space of pretrained lms encodes abstract stylistic notions such as formality, complexity, and figurativeness. using a geometry-based method, we construct a vector representation for each of these features, which can be used to characterize new texts. we find that these notions are present in the space of both static and contextualized representations, and that static embeddings are better at capturing the style of short texts (words and phrases) whereas contextual embeddings at longer texts (sentences). by correcting the anisotropy of contextualized lms' representation space, we show that it is possible to close the performance gap from static embeddings on short texts. our unsupervised and lightweight method is expected to be applicable for stylistic analysis in other languages and for other stylistic notions, such as concreteness, sentiment, and political stance, which we plan to address in future work. furthermore, we plan to experiment with anisotropy correction methods on a larger corpus, and to adapt the method for style prediction on longer text (e.g., whole documents). the stylistic measurements obtained using this method can be useful in the creation of lexical style lexicons as well as in downstream applications, for authorship attribution and style transfer.