Fair Embedding Engine: A Library for Analyzing and Mitigating Gender Bias in Word Embeddings (2020)

Abstract: Non-contextual word embedding models have been shown to inherit human-like stereotypical biases of gender, race and religion from the training corpora. To counter this issue, a large body of research has emerged which aims to mitigate these biases while keeping the syntactic and semantic utility of embeddings intact. This paper describes Fair Embedding Engine (FEE), a library for analysing and mitigating gender bias in word embeddings. FEE combines various state of the art techniques for quantifying, visualising and mitigating gender bias in word embeddings under a standard abstraction. FEE will aid practitioners in fast track analysis of existing debiasing methods on their embedding models. Further, it will allow rapid prototyping of new methods by evaluating their performance on a suite of standard metrics.

## introduction non-contextual word embedding models such as word2vec @xcite , glove @xcite and fasttext @xcite have been established as the cornerstone of modern natural language processing (nlp) techniques. the ease of usage followed by performance improvements @xcite have made word embeddings pervasive across various nlp tasks. however, as with most things, the gains come at a cost, word embeddings also pose the risk of introducing unwanted stereotypical biases in the downstream tasks. @xcite showed that a word2vec model trained on the google news corpus, when evaluated for the analogy man:computer programmer :: woman:? results to the answer homemaker, reflecting the stereotypical biases towards woman. further, zhao * authors have contributed equally. et al. (2018a) showed that models operating on biased word embeddings can leverage stereotypical cues in downstream tasks like co-reference resolution as heuristics to make thier final predictions. addressing the issues of unwanted biases in learned word representations, recent years have seen a surge in the development of word embedding debiasing procedures. the fundamental aim of a debiasing procedure is to mitigate stereotypical biases while introducing minimal semantic offset, hence maintaining the usability of embeddings. based upon the mode of operation, the debiasing methods can be classified into two categories: first, post-processing methods, which operate upon pre-trained word vectors @xcite @xcite . second, learning based methods, which involve re-training the word embedding models by either making changes to the training data or to the training objective. @xcite @xcite . along with the development of debiasing procedures, numerous metrics to evaluate the efficacy of each debiasing procedure have also been proposed @xcite @xcite . although the domain has largely benefited from the contributions of different researchers, the domain still lacks open source software projects that unify such diverse but fundamentally similar methods in an organized and standard manner. therefore, the domain has a high barrier for newcomers to overcome, and the domain experts may still need to put in extra effort of building and maintaining their own codebases. to solve this problem, we introduce fair embedding engine (fee), a library which combines state of the art techniques for debiasing, quantifying and visualizing gender bias in non-contextual word embeddings for the english language. the goal of fee is to serve as a unified framework towards the analysis of biases in word embeddings and the efficient development of better debiasing and bias evaluation methods. conforming to the common style of implementation in some existing research works @xcite , we use numpy @xcite arrays to store word vectors while keeping an index mapping to the strings of corresponding words. further, we use the pytorch @xcite autograd engine for gradient based optimization and matplotlib @xcite for generating plots. fee is made available at: https://github . ## related work since the study of stereotypical biases in nlp has received attention only in the recent years, the domain has not been a part of open source efforts that attempt to integrate diverse sets of independent methods. the only relevant open source software (oss) that we came across during our investigation was word embedding fairness evaluation (wefe) framework @xcite . for a given collection of pre-trained word embedding and a set of fairness criteria, wefe ranks the embeddings based on their performance on an encapsulation of the fairness metrics. in order to achieve this ranking over an otherwise disparate set of fairness metrics (weat @xcite , rnd @xcite , and rnsb (sweeney and najafian, 2019)) wefe introduces an abstraction which generalizes over the metrics using a set of target (the intended social class for which fairness is to be evaluated) and attribute words (the traits over which bias might exist for the selected target words). fur-ther, @xcite conclude that while existing fairness metrics show a strong correlation when used for evaluating gender bias, only a weak correlation results when evaluating biases like religion and race. therefore, the focus of wefe is limited to the evaluation of pre-trained word vectors on a suite of fairness metrics, lacking any support for debiasing methods. further, only those evaluation metrics can be used which comply with the abstraction. fee, on the other hand, provides holistic functionality by equipping a suite of evaluation and debiasing methods, along with a flexible design to assist researchers in developing new solutions. fee currently offers three debiasing methods as a part of its debiasing module: harddebias @xcite , hsrdebias @xcite , and randebias @xcite . the bias metrics module consist of the following: sembias @xcite , direct and indirect bias @xcite , gender-basied illicit proximity estimate (gipe) and proximity bias (kumar et al., 2020), percent male neighbours (pmn) @xcite and word embedding association test (weat) @xcite . ## fair embedding engine the core functionality of fee is governed by five modules, namely loader, debias, bias metrics, visualization, and report. figure 1 illustrates the components for each module of fee. in the following subsections, we delineate upon the implementation of each of the modules along with the motivation for their development. ## developing new methods with fee despite the development of a large number of debiasing methods, the issue of bias in word representations still persists @xcite making it an active area of research. we believe that the design and wide variety of tools provided by fee can play a significant role in assisting practitioners and researchers to develop better debiasing and evaluation methods. figure 2 portrays fee assisted workflows which abstract the routing engineering tasks and allow users to invest more time on the intellectually demanding questions. ## conclusion and future work in this paper, we described fair embedding engine (fee), a python library which provides central access to the state-of-the-art techniques for quantifying, mitigating and visualizing gender bias in non-contextual word embedding models. we believe that fee will facilitate the development and testing of debiasing methods for word embeddings. further, it will make it easier to visualize the existing bias present in word vectors. in future, we would like to expand the capabilities of fee towards contextual word vectors and also provide support towards biases other than gender and language other than english. we also look forward to integrate oss such as wefe @xcite to enhance the bias evaluation capabilities of fee.