Measuring Biases of Word Embeddings: What Similarity Measures and Descriptive Statistics to Use? (2021)

Abstract: Word embeddings are widely used in Natural Language Processing (NLP) for a vast range of applications. However, it has been consistently proven that these embeddings reflect the same human biases that exist in the data used to train them. Most of the introduced bias indicators to reveal word embeddings’ bias are average-based indicators based on the cosine similarity measure. In this study, we examine the impacts of different similarity measures as well as other descriptive techniques than averaging in measuring the biases of contextual and non-contextual word embeddings. We show that the extent of revealed biases in word embeddings depends on the descriptive statistics and similarity measures used to measure the bias. We found that over the ten categories of word embedding association tests, Mahalanobis distance reveals the smallest bias, and Euclidean distance reveals the largest bias in word embeddings. In addition, the contextual models reveal less severe biases than the non-contextual word embedding models.

## introduction word embedding models including word2vec @xcite , glove @xcite , bert @xcite , @xcite , and gpt @xcite have become popular components of many nlp frameworks and are vastly used for many downstream tasks. however, these word representations preserve not only statistical properties of human language but also the human-like biases that exist in the data used to train them @xcite @xcite @xcite . it has also been shown that such biases propagate to the downstream nlp tasks and have negative impacts on their performance @xcite . there are studies investigating how to miti-gate biases of word embeddings @xcite . different approaches have been used to present and quantify corpus-level biases of word embeddings. @xcite proposed to measure the gender bias of word representations in word2vec and glove by calculating the projections into principal components of differences of embeddings of a list of male and female pairs. @xcite adapted the idea of "gender direction" of @xcite to be applicable to contextual word embeddings such as elmo. in @xcite first, the gender subspace of elmo vector representations is calculated and then, the presence of gender bias in elmo is identified. @xcite introduced a new gender bias indicator based on the percentage of sociallybiased terms among the k-nearest neighbors of a target term and demonstrated its correlation with the gender direction indicator. @xcite developed word embedding association test (weat) to measure bias by comparing two sets of target words with two sets of attribute words and documented that word2vec and glove contain human-like biases such as gender and racial biases. @xcite generalized the weat test to phrases and sentences by inserting individual words from weat tests into simple sentence templates and used them for contextual word embeddings. @xcite proposed a new method to quantify bias in bert embeddings based on its masked language model objective using simple template sentences. for each attribute word, using a simple template sentence, the normalized probability that bert assigns to that sentence for each of the target words is calculated, and the difference is considered the measure of the bias. @xcite demonstrated that this probabilitybased method for quantifying bias in bert was more effective than the cosine-based method. motivated by these recent studies, we comprehensively investigate different methods for bias exposure in word embeddings. particularly, we investigate the impacts of different similarity measures and descriptive statistics to demonstrate the degree of associations between the target sets and attribute sets in the weat. first, other than cosine similarity, we study euclidean, manhattan, and mahalanobis distances to measure the degree of association between a single target word and a single attribute word. second, other than averaging, we investigate minimum, maximum, median, and a discrete (gridbased) optimization approach to find the minimum possible association to report between a single target word and the two attribute sets in each of the weat tests. we consistently compare these bias measures for different types of word embeddings including non-contextual (word2vec, glove) and contextual ones (bert, elmo, gpt, gpt2). ## method implicit association test (iat) was first introduced by @xcite in psychology to demonstrate the enormous differences in response time when participants are asked to pair two concepts they deem similar, in contrast to two concepts they find less similar. for example, when subjects are encouraged to work as quickly as possible, they are much likely to label flowers as pleasant and insects as unpleasant. in iat, being able to pair a concept to an attribute quickly indicates that the concept and attribute are linked together in the participants' minds. the iat has widely been used to measure and quantify the strength of a range of implicit biases and other phenomena, including attitudes and stereotype threat @xcite @xcite . inspired by iat, @xcite introduced weat to measure the associations between two sets of target concepts and two sets of attributes in word embeddings learned from large text corpora. a hypothesis test is conducted to demonstrate and quantify the bias. the null hypothesis states that there is no difference between the two sets of target words in terms of their relative distance/similarity to the two sets of attribute words. a permutation test is performed to measure the null hypothesis's likelihood. this test computes the probability that target words' random permutations would produce a greater difference than the observed difference. let x and y be two sets of target word embeddings and a and b be two sets of attribute embeddings. the test statistics is defined as: in other words, s(w, a, b) quantifies the association of a single word w with the two sets of attributes, and s(x, y, a, b) measures the differential association of the two sets of targets with the two sets of attributes. denoting all the partitions of x ∪ y with (x i , y i ) i , the one-sided p-value of the permutation test is: the magnitude of the association of the two target sets with the two attribute sets can be measured with the effect size as: it is worth mentioning that d is a measure used to calculate how separated two distributions are and is basically the standardized difference of the means of the two distributions @xcite . controlling for the significance, a larger effect size reflects a more severe bias. weat and almost all the other studies inspired by it @xcite @xcite use the following approach to measure the association of a single target word with the two sets of attributes (equation 1). first, they use cosine similarity to measure the target word's similarity to each word in the attribute sets. then they calculate the average of the similarities over each attribute set. in this paper we investigate the impacts of other functions such as min(•), mean(•), median(•), or max(•) for function f (•) in equation (1) (originally only mean(•) has been used). also, in this paper in addition to cosine similarity, we consider euclidean and manhattan distances as well as the following measures for the s( -→ w , -→ a ) in equation (1). mahalanobis distance: introduced by p. c. mahalanobis @xcite this distance measures the distance of a point from a distribution: discrete optimization of the association measure: in equation ( 1 ), s(w, a, b) quantifies the association of a single target word w with the two sets of attributes. to quantify the minimum possible association of a target word w with the two sets of attributes, we first calculate the distance of w from all attribute words in a and b, then calculate all possible differences and find the minimum difference. we studied all ten bias categories introduced in iat @xcite and replicated in weat to measure the biases in word embeddings. the ten weat categories are briefly introduced in weat association 1 flowers vs insects with pleasant vs unpleasant 2 instruments vs weapons with pleasant vs unpleasant 3 eur.-american vs afr.-american names with pleasant vs unpleasant (greenwald et al., 1998b) 4 eur.-american vs afr.-american names (bertrand and mullainathan, 2004) with pleasant vs unpleasant (greenwald et al., 1998b) 5 eur.-american vs afr.-american names @xcite with pleasant vs unpleasant @xcite 6 male vs female names with career vs family 7 math vs arts with male vs female terms 8 science vs arts with male vs female terms 9 mental vs physical disease with temporary vs permanent 10 young vs old people's name with pleasant vs unpleasant ## results of experiments the discretely optimized association measure (eq. for example, in the cosine distance of word2vec, if we change the descriptive statistic from mean to minimum, the biases for weat 3 and weat 4 will become insignificant (no bias will be reported). in another example, in gpt model, while the result of mean cosine is not significant for weat 3 and weat 4, they become significant for median cosine. moreover, almost for all models, the effect size of the discretely optimized minimum distance is not significant. our intention for considering this statistic was to report the minimum possible association of a target word with the attribute sets. if this measure is used for reporting biases, one can misleadingly claim that there is no bias. ## conclusions we studied the impacts of different descriptive statistics and similarity measures on association tests for measuring biases in contextualized and non-contextualized word embeddings. our findings demonstrate that the detected biases depend on the choice of association measure. based on our experiments, mean reveals more severe biases and the discretely optimized version reveals fewer number of severe biases. in addition, cosine distance reveals more severe biases and the mahalanobis distance reveals less severe ones. reporting biases with mean of euclidean/mahalanobis distances identifies more/less severe biases in the models. furthermore, contextual models show less biases than the non-contextual ones across all 10 weat tests with gpt showing the fewest number of biases.