Investigating the Frequency Distortion of Word Embeddings and Its Impact on Bias Metrics (2023)

Abstract: Recent research has shown that static word embeddings can encode words’ frequencies. However, little has been studied about this behavior. In the present work, we study how frequency and semantic similarity relate to one another in static word embeddings, and we assess the impact of this relationship on embedding-based bias metrics. We find that Skip-gram, GloVe and FastText embeddings tend to produce higher similarity between high-frequency words than between other frequency combinations. We show that the association between frequency and similarity also appears when words are randomly shuffled, and holds for different hyperparameter settings. This proves that the patterns we find are neither due to real semantic associations nor to specific parameters choices, and are an artifact produced by the word embeddings. To illustrate how frequencies can affect the measurement of biases related to gender, ethnicity, and affluence, we carry out a controlled experiment that shows that biases can even change sign or reverse their order when word frequencies change.

## introduction static word embeddings have proven to encode semantic information of words and are therefore useful to solve tasks such as synonym selection and analogical reasoning @xcite . more recent contextualized representations have achieved better results @xcite , specially in tasks where the local context of words is important @xcite . however, static word embeddings are still widely used in computational social science studies that examine global aspects of corpora. for example, embeddings are trained on specific corpora and are used to compute metrics that quantify societal biases and stereotypes that might be present in the text @xcite @xcite @xcite . static embeddings are also used in a wide range of applications like topic coherence evaluation @xcite , dream theory analysis @xcite , literature studies @xcite , and cognitive science studies @xcite . previous research has found static word embeddings appear to be associated with word frequency in various ways: word frequency correlates with embedding norm @xcite , the nearest neighbors of the embeddings of medium-frequency english words are more unstable @xcite , there are frequency-related differences in the distribution of the inner products between target and context vectors @xcite , embeddings can accurately predict whether a word is frequent or rare @xcite , and the visual inspection of their top principal components suggest they encode frequency @xcite . when it comes to using embeddings to measure bias in text, @xcite found that gender embedding-based bias metrics can spuriously depend on word frequency. our work addresses several gaps in the existing literature regarding the frequency distortion of static word embeddings and its impact on the quantification of biases in corpora. even if it has been pointed out that embeddings can encode frequency, this is the first study that: 1. comprehensively investigates the association between frequency and similarity in commonly used embeddings. 2. examines whether embeddings encode frequency due to undesirable properties of embed-dings or actual properties of corpora. 3. explores the persistence of the frequency distortion under different hyperparameter settings. 4. assesses the impact on a computational social science application, namely bias measurement. ## the dependence of word embeddings on frequency as a first step, we seek to describe the association between word frequency and cosine similarity, commonly used to measure semantic closeness. we use the 2021 english wikipedia as a corpus to train embeddings with word2vec with skip-gram with negative-sampling (sgns, @xcite , glove @xcite and fast-text @xcite with default hyperparameters (see details in appendix a). we group all words by their log 10 frequency, and use matrices to represent the mean cosine similarity of 500 randomly sampled pairs of words for each combination of bins, excluding comparisons between the same word. in the three methods the mean cosine similarity is higher between high frequency words than between any other combination of frequencies (figure 1 ). unlike sgns and fasttext, the glove mean similarity is moderate to high between words of the same frequency range (the matrix diagonal) and low between words of different frequencies (e.g. words with 10 6 vs 10 2 frequencies). these results seem to imply that word frequencies influence how similar two words are, raising the following questions: is this due to an artifact of the embeddings? or does it reveal actual properties of the corpus; for example, that high-frequency words are actually semantically closer on average to one another than the rest of the vocabulary? we conduct the following study to answer this. ## assessing the impact in computational social science, static word embeddings are typically used to measure societal biases and stereotypes potentially present in corpora. here we study the effect of the dependence of embeddings on frequency on this type of studies. we highlight that this is different from measuring or mitigating biases in nlp models. our goal is to assess how much the individual frequency of words might distort the estimates of biases in specific corpora when using word embeddings. to measure the bias of a target word x we use the difference between the mean similarity of words of context groups a and b with respect to x: here we use the same bias metric as in lewis and lupyan (2020) and @xcite for its simplicity. other similar metrics have been used @xcite @xcite and have shown to yield similar results @xcite . ## discussion and conclusions static word embeddings are useful for computing semantic similarity between words since they capture the semantics of words. to assess biases in texts, computational social scientists frequently use word embedding similarity as a metric. static word embeddings can encode information on word frequency, according to earlier research. we examine the relationship between frequency and semantic similarity in sgns, fasttext, and glove embeddings in greater detail in this work. we find that the frequency of the words being compared affects their similarity score. this dependence is also present when words in the training corpus are randomly shuffled, demonstrating that the behavior is an artifact of the embeddings and not a result of actual associations found in the text. moreover, we find that this frequency distortion persists under different hyperparameter settings. in computational social science applications like bias measurement, the propensity of embeddings to encode frequency hampers their ability to measure semantic closeness. we conduct a controlled experiment that illustrates how measuring gender, affluence or ethnicity biases using embedding-based metrics might produce inaccurate results. the results indicate that the frequency of words can have a significant impact on the answers to questions like "what are the most gender biased terms?" as biases can change sign or ranking when word frequencies are changed. a way to mitigate the frequency distortion in embedding-based bias metrics could involve creating context groups a and b with words that have similar average frequencies, if possible. when doing this, frequency does not have a systematic effect in the sign of the subtraction of cosine similarities. another approach is to randomly replicate documents prior to training embeddings so that the frequencies of a and b are balanced. however, it is worth noting that when measuring bias with context groups a and b with multiple words each, it can be challenging to achieve balanced frequencies for all words simultaneously.