HW5 Part II + Bias in NLP Spring 2019 Caleb Kaiji Lu
HW5PartII+Bias inNLP
Spring2019CalebKaijiLu
HW5PartII:Debiasing WordEmbeddings[Bolukabasi 2016]
• Man:King::Woman:Queen• Paris:France::Tokyo:Japan
• He:Brother ::She:Sister• He:Blue ::She:Pink• He:Doctor ::She:Nurse• He:Realist ::She:Feminist• She:Pregnancy ::He:Kidney Stone• She:Baking::He:Roasting• She:Blonde::He:Blond
HW5PartII:Debiasing WordEmbeddings[Bolukabasi 2016]
• Tobereleasedtoday• Threesteps
• Identifygendersubspace(PCAusingSVD)• Neutralize• Equalize
• Evaluation• Analogycompletionforhe—she• AnalogycompletionforaWEevaluationdataset
• Threewordfiles:• Gender-definitionalwords(foridentifying thegendersubspace)• Gender-specificwords(foridentifyingwordstoneutralize)• Equalizedpairs(wordstoequalize)
TheGeometryofGender
she
he
her
his woman
man
female
maleMary
John
Gender(he-she) AxisFirst Principal Component
PrincipalComponentAnalysis
• PrincipalComponents(PC)areorthogonaldirectionsthatcapturemostofthevarianceinthedata.• 1st PC– direction ofgreatestvariabilityindata
• 2nd PC– Next orthogonal(uncorrelated)direction ofgreatestvariability(removeallvariability infirstdirection,thenfindnextdirectionofgreatestvariability)
• Andsoon…
PrincipalComponentAnalysis(PCA)
• Letv1,v2,…,vd denotethedprincipalcomponents.• Visorthonormal
• LetX=[x1,x2,…,xn](columnsarethedatapoints)• Datapointsarecentered
• Findvectorthatmaximizessamplevarianceofprojecteddata• Findvectorthatminimizes theaveragereconstruction error
PrincipalComponentAnalysis(PCA)
• Blackboard
Identify GenderSubspace
Neutralizeandequalize
NeutralizeandEqualize
• B:gendersubspace• w_B:projectionofwonB• BlackBoard
Agenda
• Introduction• GenderBiasinNLPtasks• CounterfactualData-Augmentation• GenderBiasinRNNLanguageModels• NeuralCoreference ResolutionBasics• GenderBiasinCoreference Resolution
NaturalQuestions• Doesbiasexistdownstreamtasks?• Doesmitigatingbiasinwordembeddings alsomitigatebiasinthedownstreamtasks?• Doesmitigatingbiasinwordembeddings impacttheperformanceofthedownstreamtasks?
12
BiasinNLPtasks
• Biasinlanguagemodeling • BiasinCoreference resolution
BiasinNLPtasks[Lu,18]
• Definitionofbias:• CausalTesting• DefineMatchedpairsofindividuals(instances) thatdifferinonlyatargetedconcept(gender)
• Calculatedifference inoutcomes(conditional log-likelihood)
• Causal influence oftheconcept inthescrutinizedmodel
14
Figure:TwomatchedPairs
BiasinNLPtasks[Lu,18]
• MatchedPairs• Templates: He/She isa/an|[OCCUPATION]• Aggregatetemplates• Aggregateoccupationwords(crosslistedfromUSlabordataandlanguagemodelvocabulary)
15
Figure:TwomatchedPairs
HowtoEliminatetheBias
• Simplestsolution:Collectunbiaseddata• Notrealizable
• Changethemodelparameters/Changetheobjectivefunction
16
Previously:Debiasing bychanging trainingobjective[Zhang,2018]
• Foreachanalogyinthedataset,weletx=(x1,x2,x3)• x1=he;x2=doctor;x3=doctor;x4=?
• OriginalModel(Lp)• Groundtruthforthefourthword• Estimate forthefourthword:
• AdversarialModel(LA)• Estimate forAdversarial network:• Ground truth forAdversarial Network:
Previously:Debiasing bychanging themodelparameters
• Debiasing theembeddinglayer?
18
WordEmbeddings:TrainableorFixed?
WordEmbedding canbeusedtoreplacewordsasinputstothemodel• Pros
• Efficient• HandleOOVcases ifthetrainingdataset issmall
• Cons:• Cannottailortothetask
• Debiasing wordembeddingmaybehelpful
WordEmbedding canbetrainedaspartofthemodel• Pros:
• LearnUseful representations specific tothetask
• Cons:• Expensive• Datasetmight betoosmall tolearn useful
representations• Datasetmight notcover allthevocabularies
• DebiasingWordembeddingmaynotbehelpful• Destroy themodel• Biasisrelearned
19
HowtoEliminatetheBias
• Simplestsolution:Collectunbiaseddata• Notrealizable
• Fixthemodel/Changetheobjectivefunction• Invasive,couldhurtperformance• Model-dependent
• SynthesizeUnbiaseddata• Model-agnostic• Counterfactual DataAugmentation
20
Debiasing bySynthesizingdata:CounterfactualDataAugmentation
21
• Generateanewsentencebyflippinggender-specificwordstotheircounterpartsofoppositegender• Addthenewsentencestothetrainingdata• Trainanewmodel
CounterfactualDataAugmentation
• Identifythelistofgenderedwordpairs• (he,she), (man,woman),(actor,actress), (monk,nun),(actors,actresses),…..
• Makesurethattheflippedsentencesaregrammaticallycorrect• “BillClinton’swifeisHillary."
• Can’tflip!BillClinton’shusband isHillary.• Rule:Ifthegenderedwordreferstothesameperson/entitywithapropernoun,weshallnotflip.
• Handleothercornercases• Ex:her(his/him)
• CouldbeappliedtootherNLPtasks
22
Experiment1:LanguageModeling
• Models:• AbenchmarkLSTM
• Embeddingsize:1500• LSTMcellsize:1500
• Debiasing :• Debias thetrainedembedding[baseline]()• CDA(naïve):Flipeverygender-specificwordswithout anygrammaticalconstraints• CDA(grammar):CDA(naïve)+grammaticalconstraint• Initializetheembedding layerfrombaselineandtrainonaugmenteddataset()
• Data:• Wiki-text2dataset• 36718sentences, atleast7579sentences withonegender-specific word
23
Results
• OccupationBias• Negativeoccupation bias:biased towardsfemale;Positiveoccupationbias:biased towardsmale• Thebiasintheoriginal model roughlyaligns withexpectations ongender-occupation stereotypesintherealworld
• ApplyingCDAconsistentlymitigatebiasforalmostalloccupations.
24
Results
25
• AOB:AggregateOccupationBias;TestPerp:TestPerplexity• BothCDAmitigatebiaswhilepreservingtheperformance
• CDA(naïve)hassurprisinglybetterperformance
Results
26
• Apply wordembeddingdebiasing afterthemodel istrained()greatlyreducesbias,butalsodestroysthemodelperformance• Reasonforlowbias:lowvarianceoftheoutputscoredistribution
• Applywordembeddingdebiasing ()andcontinuetrainingontheaugmenteddataset:• Reintroducebiasback
BiasinCoreference Resolution
27
Coreference ResolutionBasics
• Identifyallmentionsthatrefertothesamerealworldentity• Mentions:words/phrases thatreferstoarealentity intheworld• Antecedent ofamention:othermention/mentions thatprecedes saidmention,whichreferstothesame entity
Coreference ResolutioninTwoSteps
• Detectthementions(easy)
• Clusterthementions(hard)
AMentionRankingSystem[clark &Manning,2016]
• Assigneachmentionitshighestscoringcandidateantecedentaccordingtothemodel• DummyNAmentionallowsmodeltodecline linkingthecurrentmentiontoanything(“singleton”or“first”mention)
AMentionRankingSystem[clark &Manning,2016]
AMentionRankingSystem[clark &Manning,2016]
AMentionRankingSystem[clark &Manning,2016]
• TestTime:• Clusterthepairs
NeuralCoref Model[clark &Manning,2016]
CDAforNeuralCoref Resolution
BiasinCoreference Resolution
36
• OccupationBias• Negativeoccupation bias:biased towardsfemale;Positiveoccupationbias:biased towardsmale• Thebiasintheoriginal model roughlyaligns withexpectations ongender-occupation stereotypesintherealworld
• ApplyingCDAconsistentlymitigatebiasforalmostalloccupations.
BiasinCoreference Resolution
37
• Pretrained Embedding(Word2vec)• AdditiveEffectof:
• Fixingtheembeddings usingdebiasing• Fixingotherparametersusingcounterfactualdataaugmentation
BiasinCoreference Resolution
38
Summary
• Genderbiasexistsindownstreamtasks• LanguageModels• Coreference Resolution
• Caneffectivelyreducebiasbytrainingonaugmenteddataset• Previousmethodsofaddressingbiasinwordembeddings
• Hurtsperformance ifdoneafteramodel istrained• Reintroduces thebiasbackifinitialized beforeamodel istrained• Additiveeffect iftheembedding ispretrained
39
Questions?
• References:• T.Bolukbasi,K.-W.Chang,J.Y.Zou,V.Saligrama,andA.T.Kalai,“Manistocomputerprogrammeraswomanistohomemaker? debiasing wordembeddings,” inAdvances inneuralinformationprocessingsystems, 2016,pp.4349–4357.
• K.Lu,P.Mardziel,F.Wu,P.Amancharla,andA.Datta,“Genderbias inneuralnaturallanguage processing,”arXiv preprintarXiv:1807.11714,2018.
• KevinClarkandChristopherDManning.Deepreinforcement learningformention-ranking corefer- ence models.arXiv preprintarXiv:1609.08667,2016b.
• KentonLee,Luheng He,MikeLewis,andLukeZettlemoyer. End-to-endneuralcoreference resolution.arXiv preprintarXiv:1707.07045,2017.
40