FairFil: Contrastive Neural Debiasing Method for Pretrained Text Encoders

1 INTRODUCTION . Text encoders , which map raw-text data into low-dimensional embeddings , have become one of the fundamental tools for extensive tasks in natural language processing ( Kiros et al. , 2015 ; Lin et al. , 2017 ; Shen et al. , 2019 ; Cheng et al. , 2020b ) . With the development of deep learning , largescale neural sentence encoders pretrained on massive text corpora , such as Infersent ( Conneau et al. , 2017 ) , ELMo ( Peters et al. , 2018 ) , BERT ( Devlin et al. , 2019 ) , and GPT ( Radford et al. , 2018 ) , have become the mainstream to extract the sentence-level text representations , and have shown desirable performance on many NLP downstream tasks ( MacAvaney et al. , 2019 ; Sun et al. , 2019 ; Zhang et al. , 2019 ) . Although these pretrained models have been studied comprehensively from many perspectives , such as performance ( Joshi et al. , 2020 ) , efficiency ( Sanh et al. , 2019 ) , and robustness ( Liu et al. , 2019 ) , the fairness of pretrained text encoders has not received significant research attention . The fairness issue is also broadly recognized as social bias , which denotes the unbalanced model behaviors with respect to some socially sensitive topics , such as gender , race , and religion ( Liang et al. , 2020 ) . For data-driven NLP models , social bias is an intrinsic problem mainly caused by the unbalanced data of text corpora ( Bolukbasi et al. , 2016 ) . To quantitatively measure the bias degree of models , prior work proposed several statistical tests ( Caliskan et al. , 2017 ; Chaloner & Maldonado , 2019 ; Brunet et al. , 2019 ) , mostly focusing on word-level embedding models . To evaluate the sentence-level bias in the embedding space , May et al . ( 2019 ) extended the Word Embedding Association Test ( WEAT ) ( Caliskan et al. , 2017 ) into a Sentence Encoder Association Test ( SEAT ) . Based on the SEAT test , May et al . ( 2019 ) claimed the existence of social bias in the pretrained sentence encoders . Although related works have discussed the measurement of social bias in sentence embeddings , debiasing pretrained sentence encoders remains a challenge . Previous word embedding debiasing methods ( Bolukbasi et al. , 2016 ; Kaneko & Bollegala , 2019 ; Manzini et al. , 2019 ) have limited assistance to sentence-level debiasing , because even if the social bias is eliminated at the word level , ∗Equal contribution . the sentence-level bias can still be caused by the unbalanced combination of words in the training text . Besides , retraining a state-of-the-art sentence encoder for debiasing requires a massive amount of computational resources , especially for large-scale deep models like BERT ( Devlin et al. , 2019 ) and GPT ( Radford et al. , 2018 ) . To the best of our knowledge , Liang et al . ( 2020 ) proposed the only sentence-level debiasing method ( Sent-Debias ) for pretrained text encoders , in which the embeddings are revised by subtracting the latent biased direction vectors learned by Principal Component Analysis ( PCA ) ( Wold et al. , 1987 ) . However , Sent-Debias makes a strong assumption on the linearity of the bias in the sentence embedding space . Further , the calculation of bias directions depends highly on the embeddings extracted from the training data and the number of principal components , preventing the method from adequate generalization . In this paper , we proposed the first neural debiasing method for pretrained sentence encoders . For a given pretrained encoder , our method learns a fair filter ( FairFil ) network , whose inputs are the original embeddings of the encoder , and outputs are the debiased embeddings . Inspired by the multi-view contrastive learning ( Chen et al. , 2020 ) , for each training sentence , we first generate an augmentation that has the same semantic meaning but in a different potential bias direction . We contrastively train our FairFil by maximizing the mutual information between the debiased embeddings of the original sentences and corresponding augmentations . To further eliminate bias from sensitive words in sentences , we introduce a debiasing regularizer , which minimizes the mutual information between debiased embeddings and the sensitive words ’ embeddings . In the experiments , our FairFil outperforms Sent-Debias ( Liang et al. , 2020 ) in terms of the fairness and the representativeness of debiased embeddings , indicating our FairFil not only effectively reduces the social bias in the sentence embeddings , but also successfully preserves the rich semantic meaning of input text . 2 PRELIMINARIES . Mutual Information ( MI ) is a measure of the “ amount of information ” between two variables ( Kullback , 1997 ) . The mathematical definition of MI is I ( x ; y ) : = Ep ( x , y ) [ log p ( x , y ) p ( x ) p ( y ) ] , ( 1 ) where p ( x , y ) is the joint distribution of two variables ( x , y ) , and p ( x ) , p ( y ) are respectively the marginal distributions of x , y . Recently , mutual information has achieved considerable success when applied as a learning criterion in diverse deep learning tasks , such as conditional generation ( Chen et al. , 2016 ) , domain adaptation ( Gholami et al. , 2020 ) , representation learning ( Chen et al. , 2020 ) , and fairness ( Song et al. , 2019 ) . However , the calculation of exact MI in ( 1 ) is well-recognized as a challenge , because the expectation w.r.t p ( x , y ) is always intractable , especially when only samples from p ( x , y ) are provided . To this end , several upper and lower bounds have been introduced to estimate the MI with samples . For MI maximization tasks ( Hjelm et al. , 2018 ; Chen et al. , 2020 ) , Oord et al . ( 2018 ) derived a powerful MI estimator , InfoNCE , based on noise contrastive estimation ( NCE ) ( Gutmann & Hyvärinen , 2010 ) . Given a batch of sample pairs { ( xi , yi ) } Ni=1 , the InfoNCE estimator is defined with a learnable score function f ( x , y ) : INCE : = 1 N N∑ i=1 log exp ( f ( xi , yi ) ) 1 N ∑N j=1 exp ( f ( xi , yj ) ) . ( 2 ) For MI minimization tasks ( Alemi et al. , 2017 ; Song et al. , 2019 ) , Cheng et al . ( 2020a ) introduced a contrastive log-ratio upper bound ( CLUB ) based on a variational approximation qθ ( y|x ) of conditional distribution p ( y|x ) : ICLUB : = 1 N N∑ i=1 [ log qθ ( yi|xi ) − 1 N N∑ j=1 log qθ ( yj |xi ) ] . ( 3 ) In the following , we use the above two MI estimators to induce the sentence encoder , eliminating the biased information and preserving the semantic information from the original raw text . 3 METHOD . SupposeE ( · ) is a pretrained sentence encoder , which can encode a sentence x into low-dimensional embedding z = E ( x ) . Each sentence x = ( w1 , w2 , . . . , wL ) is a sequence of words . The embedding space of z has been recognized to have social bias in a series of studies ( May et al. , 2019 ; Kurita et al. , 2019 ; Liang et al. , 2020 ) . To eliminate the social bias in the embedding space , we aim to learn a fair filter network f ( · ) on top of the sentence encoder E ( · ) , such that the output embedding of our fair filter d = f ( z ) can be debiased . To train the fair filter , we design a multi-view contrastive learning framework , which consists of three steps . First , for each input sentence x , we generate an augmented sentence x′ that has the same semantic meaning as x but in a different potential bias direction . Then , we maximize the mutual information between the original embedding z = f ( x ) and the augmented embedding z′ = f ( x′ ) with the InfoNCE ( Oord et al. , 2018 ) contrastive loss . Further , we design a debiasing regularizer to minimize the mutual information between d and sensitive attribute words in x . In the following , we discuss these three steps in detail . 3.1 DATA AUGMENTATIONS WITH SENSITIVE ATTRIBUTES . We first describe the sentence data augmentation process for our FairFil contrastive learning . Denote a social sensitive topic as T = { D1 , D2 , . . . , DK } , where Dk ( k = 1 , . . . , K ) is one of the potential bias directions under the topic . For example , if T represents the sensitive topic “ gender ” , then T consists two potential bias directions { D1 , D2 } = { “ male ” , “ female ” } . Similarly , if T is set as the major “ religions ” of the world , then T could contain { D1 , D2 , D3 , D4 } = { “ Christianity ” , “ Islam ” , “ Judaism ” , “ Buddhism ” } as four components . For a given social sensitive topic T = { D1 , . . .DK } , if a word w is related to one of the potential bias direction Dk ( denote as w ∈ Dk ) , we call w a sensitive attribute word of Dk ( also called bias attribute word in Liang et al . ( 2020 ) ) . For a sensitive attribute word w ∈ Dk , suppose we can always find another sensitive attribute word u ∈ Dj , such that w and u has the equivalent semantic meaning but in a different bias direction . Then we call u as a replaceable word of w in direction Dj , and denote as u = rj ( w ) . For the topic “ gender ” = { “ male ” , “ female ” } , the word w = “ boy ” is in the potential bias direction D1 = “ male ” ; a replaceable word of “ boy ” in “ female ” direction is r2 ( w ) = “ girl ” ∈ D2 . With the above definitions , for each sentence x , we generate an augmented sentence x′ such that x′ has the same semantic meaning as x but in a different potential bias direction . More specifically , for a sentence x = ( w1 , w2 , . . . , wL ) , we first find the sensitive word positions as an index set P , such that each wp ( p ∈ P ) is a sensitive attribute words in direction Dk . We further make a reasonable assumption that the embedding bias of direction Dk is only caused by the sensitive words { wp } p∈P in x . To sample an augmentation to x , we first select another potential bias direction Dj , and then replace all sensitive attribute words by their replaceable words in the direction Dj . That is , x′ = { v1 , v2 , . . . , vL } , where vl = wl if l /∈ P , and vl = rj ( wl ) if l ∈ P . In Table 1 , we provide an example for sentence augmentation under the “ gender ” topic .

Summary: This paper introduces a novel technique for debiasing pretrained contextual embedding models. Their approach trains a 2 layer fully-connected neural network which takes as input the output from the pretrained model and outputs a new, "debiased" representation. This model is trained by minimizing the InfoNCE between the representation produced of original sentence and the representation of that same sentence with some tokens replaced with differently-biased tokens (e.g. "his" -> "hers"). This paper also introduces a regularizer which minimizes the CLUB between the generated representation and a word embedding for a biased token.