Discovering Differences in the Representation of People using Contextualized Semantic Axes (2022)

Abstract: A common paradigm for identifying semantic differences across social and temporal contexts is the use of static word embeddings and their distances. In particular, past work has compared embeddings against “semantic axes” that represent two opposing concepts. We extend this paradigm to BERT embeddings, and construct contextualized axes that mitigate the pitfall where antonyms have neighboring representations. We validate and demonstrate these axes on two people-centric datasets: occupations from Wikipedia, and multi-platform discussions in extremist, men’s communities over fourteen years. In both studies, contextualized semantic axes can characterize differences among instances of the same word type. In the latter study, we show that references to women and the contexts around them have become more detestable over time.

## introduction warning: this paper contains content that may be offensive or upsetting. quantifying and describing the nature of language differences is key to measuring the impact of social and cultural factors on text. past work has compared english embeddings for people to adjectives or concepts @xcite @xcite , or projected embeddings against axes representing contrasting attributes @xcite @xcite @xcite @xcite @xcite . static representations for the same word can also be juxtaposed across corpora that reflect different time periods @xcite . this paradigm of using embedding distances to uncover socially meaningful patterns has also transferred over to studies that measure biases in contextualized embeddings, such as wolfe and caliskan (2021)'s finding that bert beautiful ugly … gorgeous equipage, ornately attired … … a grotesque, monster-like costume… … there are beautiful women who are willing … … literally filled with garbage women … figure 1 : an axis is constructed using embeddings of adjectives in selected contexts. these contexts are predictive of synonyms, but not antonyms, of the target adjective during masked language modeling. tokenlevel embeddings for people are then projected onto this axis. our work investigates the extension and application of semantic axes to contextualized embeddings. we present a novel approach for constructing semantic axes with english bert embeddings (figure 1 ). these axes are built to encourage selfconsistency, where antonymous poles are less conflated with each other. they are able to capture semantic differences across word types as well as variation in a single word across contexts. their ability to differentiate contexts makes them suitable for studying how a word changes across domains or across individual sentences. these axes are also more self-consistent and coherent than ones created using glove and other baseline approaches. we demonstrate the use of contextualized axes on two datasets: occupations from wikipedia, and people discussed in misogynistic online communities. we use the former as a case where terms appear in definitional contexts, and characteristics of people are well-known. in the latter longitudinal, cross-platform case study, we examine lexical choices made by communities whose attitudes towards women tend to be salient and extreme. we chose this set of online communities as a substantive use case of our method, in light of recent attention in web science on analyzing online extremism and hate at scale (e.g. @xcite . there, we analyze language change and variation along axes through a sociolinguistic lens, emphasizing that speakers use language that reflects their social identities and beliefs @xcite @xcite . our code, vocabularies, and other resources can be found in our github repo: https://github.c om/lucy3/context_semantic_axes . relying on single-word poles for axes can be unstable to the choice of each word @xcite ). @xcite creates a pole's set of words using the nearest neighbors of a seed word, which may risk conflating unintended meanings or antonymous neighbors @xcite . for example, one axis uses the opposite seed words green and experienced, but green's nearest neighbors include red rather than inexperienced. instead of using this nearest neighbors approach, we construct poles using wordnet antonym relations. each end of an axis aggregates synonymous and similar lemmas in wordnet synsets, which are expanded using the similar to relation @xcite . our type-based embedding baseline, glove, uses 300-dimensional glove vectors pretrained on wikipedia and gigaword @xcite . we only keep poles where both sides have at least three adjectives that appear in the glove vocabulary, and we also exclude acronyms, which are often more ambiguous in meaning. we start with 723 axes, where poles have on average 9.63 adjectives each. contextualized embeddings. static embeddings, however, present a number of limitations. such embeddings cannot easily handle polysemy or homonymy @xcite , and even when they are trained on different social or temporal contexts, they require additional steps to be aligned @xcite . context-specific embeddings also need enough training examples of target words to create usable representations. these limitations prevent the analysis of token-based semantic variation, such as measuring how one mention of a word is more or less beautiful than another. our main contribution of contextualized axes uses the same wordnet-based formulation as our glove baseline. rather than each word in s l or s r being represented by a single glove embedding, we obtain bert embeddings over multiple occurrences of each adjective. we use bert-base, as this model is small enough for efficient application on large datasets and is popular in previous work on semantic change and differences (e.g. @xcite @xcite @xcite . it is also used in tutorials for researchers outside of nlp, which means it has high potential use in computational social science and cultural analytics @xcite . for contextualized axes, we obtain a potential pool of contexts for adjectives sampled over all of wikipedia from december 21, 2021, preprocessed using @xcite 's text extractor. this sample contains up to 1000 sentences, or contexts, that contain each adjective, and we avoid contexts that are too short (over 10 tokens) or too long (over 150 tokens). 1 we experiment with two methods of obtaining contextualized bert embeddings for each adjective: a random "default" (bert-default) and one where contexts are picked based on word probabilities (bert-prob). for bert-default, we take a random sample of 100 contextualized embeddings across the adjectives in each pole. since words can be nearest neighbors with their antonyms in semantic space @xcite , our main approach, bert-prob, aggregates word embeddings over contexts that highlight contrasting meanings of axes' poles. to select contexts, we mask out the target adjective in each of its 1000 sentences, and have bert-base predict the probabilities of synonyms and antonyms for that masked token. we remove contexts where the average probability of antonyms is greater than that of synonyms, sort by average synonym probability, and take the top 100 contexts. one limitation of our approach is that predictions are restricted to adjectives that can be represented by one wordpiece token. if none of the words on a pole of an axis appear in bert's vocabulary, we backoff to bert-default to represent that axis. for each axis type, we also have versions where words' embeddings are z-scored, which has been shown to improve bert's alignment with humans' word similarity judgements @xcite . for z-scoring, we calculate mean and standard deviation bert embeddings from a sample of around 370k whole words from wikipedia. as recommended by @xcite , we use mean pooling over wordpieces to produce word representations when necessary, and we extend this approach to create bigram representations as well. these embeddings are a concatenation of the last four layers of bert, as these tend to capture more context-specific information @xcite . ## internal validation we internally validate our axes for self-consistency. for each axis, we remove one adjective's embeddings from either side, and compute its cosine similarity to the axis constructed from the remaining adjectives. for bert approaches, we average the adjective's multiple embeddings to produce only one before computing its similarity to the axis. in a "consistent" axis, a left-out adjective should be closer to the pole it belongs to. that is, if it belongs to s l , its similarity to the axis should be positive. we average these leave-one-out similarities for each pole, negating the score when the adjective belongs to s r , to produce a consistency metric, c. the best method for producing consistent axes is z-scored bert-prob, with a significant difference in c from z-scored bert-default and glove (mann-whitney u-test, @xmath1.001). it also produces the highest number of consistent axes. glove presents itself as a formidable baseline, foot_3 and bert-default struggles in comparison to it. ## external validation category occupation experiment person experiment writing creative, fanciful, fictive formal, logical, discursive + folksy, unceremonious, casual + ignoble, common, plebeian entertainment transcribed, taped, recorded structural, constructive, creative + trademarked, branded, copyrighted + emotional, soupy, slushy art unostentatious, aesthetic, artistic creative, fanciful, fictive + activist, active, hands-on + practiced, proficient, adept health unhealthy, pathologic, asthmatic rehabilitative, structural, constructive + confirmable, empirical, experiential + teetotal, dry, drug-free agriculture drifting, mobile, unsettled rustic, agrarian, bucolic + boneless, deboned, boned -rehabilitative, structural, constructive government amenable, answerable, responsible policy-making, political, governmental + respectful, deferential, honorific + amenable, answerable, responsible sports spry, gymnastic, sporty zealous, ardent, enthusiastic -amenable, answerable, responsible -subject, subservient, dependent engineering formal, logical, discursive rehabilitative, structural, constructive + coeducational, integrated, mixed + advanced, high, graduate science humanistic, humane, human-centered zealous, ardent, enthusiastic + humanistic, humane, human-centered + stoic, unemotional, chilly math & statistics enumerable, estimable, calculable formal, logical, discursive + enumerable, estimable, calculable -amenable, answerable, responsible social sciences humanistic, humane, human-centered relational, relative, comparative + significant, portentous, probative + humanistic, humane, human-centered ## measuring change and variation now that we have contextualized semantic axes that can measure differences across words and contexts, we apply them onto a domain that can showcase salient and socially meaningful variation. nlp research on harmful language often employs methods that focus on the target group, such as measuring their association with other words @xcite @xcite , or with biases in models @xcite . we illustrate the application of self-consistent z-scored bert-prob axes onto the manosphere, which is a collection of communities with mostly male users who hold alternative beliefs around relationships and gender. we use the same axes we presented earlier, which were created using wikipedia data, because wikipedia provides more normative coverage of a variety of adjectives than topic-specific communities. this way, we examine how entities in the manosphere orient themselves against typical adjectival uses and meanings. the manosphere has been linked to acts of violence in the physical world @xcite , and most members believe that men are systemically disadvantaged in society ( @xcite @xcite . these communities focus on heterosexual relationships and masculinity, and feature a dynamic linguistic landscape. much prior work on the manosphere has been qualitative, such as ethnographies @xcite @xcite . there have been a few quantitative analyses of their language, usually focusing on phrase and word frequencies in a few communities @xcite @xcite . as an example involving word vectors, @xcite uses static embeddings identify the meanings of incels' neologisms by inspecting words' nearest neighbors. our case study extends beyond prior work with its methodology and scale. we use contextualized semantic axes to tackle one question: how have references to women and contexts around them changed over fourteen years? ## conclusion in this work, we examine the capability of contextualized embeddings for discovering differences among words and contexts. our method uses predicted word probabilities to pinpoint which contexts to include when aggregating bert embeddings to construct axes. this approach creates more self-consistent axes that better fit different occupation categories, in comparison to baselines. we further demonstrate the use of these axes in a longitudinal, cross-platform case study. overall, contextualized embeddings offer more flexibility and granularity compared to static ones for the analysis of content across time and communities. that is, rather than train static word embeddings for various subsets of data, we can characterize change and variation at the token-level. though we focus on analyzing associations between adjectives and people, our approach can generalize to other types of entities as well. measuring and comparing the contexts of other entity types should include many of the same considerations we did, such as reducing the conflation of antonyms, controlling for word identity by replacing target words with a shared hypernym, and experimenting with z-scoring. future work includes understanding why some opposing concepts are conflated in large language models, and how a word embed-ding's identity influences its encoding of contexts.