Screening Gender Transfer in Neural Machine Translation (2021)

Abstract: This paper aims at identifying the information flow in state-of-the-art machine translation systems, taking as example the transfer of gender when translating from French into English. Using a controlled set of examples, we experiment several ways to investigate how gender information circulates in a encoder-decoder architecture considering both probing techniques as well as interventions on the internal representations used in the MT system. Our results show that gender information can be found in all token representations built by the encoder and the decoder and lead us to conclude that there are multiple pathways for gender transfer.

## introduction the existence of translation divergences (i.e. crosslinguistic distinctions) raises many challenges for machine translation (mt) @xcite : when translating a sentence, some information or constructions are specific to the target language and, consequently, can only be inferred by the decoder from the target context; some are only found in the source language and have to be ignored; finally, some information has to be adapted and transferred from the encoder to the decoder. contrary to previous generations of mt engines where transfer rules were quite transparent, understanding this information flow within state-of-the-art neural mt systems is a challenging task, and a key step for their interpretability. to illustrate these alternatives and the difficulty they raise, we focus in this work on one specific translation problem: the transfer of gender information from french, where grammatical gender is a property of all nouns, and agreement rules exist within the noun phrase, to english, where gender is only overtly used in rare constructs involving human agents and pronoun coreference. 1 more specifically, we focus on the english translation of french sentences such as "l'actrice f a terminé son travail." (the actress f has finished her f job). 2 translating this kind of sentences is problematic for state-of-the-art mt systems, notably because i) the coreference has to be correctly identified and ii) it can result in gender-biased translations due to stereotypical associations such as nurses are always female. using a controlled test set, we are able to screen the different information flows at stake when transferring gender information from french into english using two families of methods. the first one relies on linguistic probes to find in which parts of the nmt system gender information is represented; the second one is based on causal models and consists in intervening on the different parts of the source sentence and of the decoder representations in order to reveal their impact on the predicted translations. while this work focuses on one translation phenomenon and on one translation direction only, we believe that our observations shed a new light on how translation systems work and that the methods we describe can be used to analyze other translation divergences. the rest of the paper is organized as follows. in section 2, we first introduce our controlled dataset and explain how gender is expressed in the two languages. then, in section 3 we describe our mt system and evaluate the system outputs in section 4 its capacity to translate gender information. to explain these results, we then describe two sets of experiments that rely on different ways to analyze neural networks: in section 5, we use linguistic probes to find out in which source and target tokens gender information is present and in section 6 we report experiments modifying the token rep-resentation to determine when this information is used. finally, in section 7, we relate our findings to previous research before summarizing our results in section 8. ## a controlled test set to study gender transfer between french and english corpus creation following (saunders and byrne, 2020), foot_3 we consider parallel sentences with the following pattern to study gender transfer between french and english: the motivations for using these fixed syntactic patterns are many. first, they limit the only source of variability between sentences to the [n] slots, allowing us to perform controlled experiments. second, they simplify the analysis and manipulation of the trained representations, as the position of each word is almost constant throughout the entire dataset. 6 despite its simplicity, this dataset enables rich analyses, as the large coverage of the set of nouns enables us to analyze the result with respect to the noun frequency, length, stereotypicality, and also with respect to the amount of gender information available in each language. furthermore, the asymmetry between the gender carrying words in french and english will be a facilitating factor for generating interesting contrasts. in this paper we focus on french to english translations, foot_7 using variations in french determiners to generate interesting contrasts in the source. the possessive marker son is similarly epicene if the following word begins with a vowel. it should also be noted that there are sociolinguistic implications beyond the remit of this paper, such as a debated preference to refer to women's occupations favouring the masculine form of the occupational noun or exclusive uses of the masculine form to express generic uses @xcite . contrary to case (iv), in situations [i-iii], the translation system has the information to predict the right pronoun. note that these three possibilities are not mutually exclusive, and gender may well be transferred through a combination of the three influences, and also through the representations computed for the other words in the sentence. our main objective in this paper is to explore various ways to assess these hypotheses and try to reach a conclusion regarding the way gender is actually transferred. ## experimental setting in all our experiments, we use joeynmt foot_9 @xcite , an educational implementation of a translation system based on the transformer model of @xcite . the simplicity of the codebase, which nonetheless allowed us to achieve near sota performance on our data, made it a perfect choice for our endeavor. in our system, encoder and decoder are composed of 6 layers, each with 8 attention heads; the feedforward layers have 2,048 parameters and the dimension of lexical embeddings is 512. our model comprises a grand total of 76,596,736 parameters. the system was trained with data from the 'news' task of the wmt'2015 evaluation campaign. 10 it includes the europarl, newscommentary and commoncrawl corpora, and altogether contains 4,813,682 sentences and nearly 141 million french running words. all the corpora were tokenized and segmented into sub-lexical units using the unigram model of sentencepiece @xcite ; the resulting vocabularies contain 32,000 units in each language. the model is trained by optimizing the cross-entropy using the adam strategy. this system achieves a bleu score of 34.0 for the french-english direction. ## probing representations in this section, we conduct an analysis of the representations computed by the encoder when translating from french into english. our goal is to evaluate how well the gender information spreads through the transformer network from the initial french occupational noun (either det, n or both of them) to the other french words, as well as to their english counterparts. following a standard practice, we use probing @xcite to analyze which words in the source and target sentence convey gender information: a probe (alain and bengio, 2017) is trained to predict linguistic properties (here the gender of the french subject) from the representations of language; achieving high accuracy at this task implies these properties were encoded in the representation. ## manipulating representations the probing experiments described in the previous section show that gender information is encoded in all tokens representations built by the encoder and the decoder. however, it is not possible to identify from these observations if and when this information is used. to answer this question, the second method we propose to analyze gender transfer in our mt system relies on an intervention. it consists in replacing the embedding of the french possessive pronoun (i.e. the son token that, intuitively triggers the generation of 'her' or 'his') at the output of the encoder by either a neutral version of this embedding, obtained by averaging the representations of son on the whole test set (it should be borne in mind that the design of our corpus ensures that genders are balanced) or a prototypical version of a masculine son embedding or a feminine son embedding. these embeddings are extracted from the encoder representations of these two sentences: these two sentences were chosen because, in both cases, gender information is carried by both the determiner and the noun and the translation of these sentences by our system is correct. after plugging the chosen representation in the last layer of the encoder and keeping the representation of the other tokens of the source sentence unchanged, the rest of the translation proceeds without any further modification. results of this manipulation are in ## related work our work is part of a very active line of research aiming to analyze, interpret, and evaluate neural networks used in nlp. @xcite present a detailed overview of these papers and of the different tools and methods that can be used to uncover the linguistic information represented in the hidden layers of neural networks. experiments reported in section 5 are based on the probing approach of @xcite and have been used in many works (see @xcite for an overview). this approach has also been used in several works to study the information flow within an encoder-decoder architecture: for instance, @xcite rely on probes to find which components of a nmt system encode linguistic information when translating morphologically rich languages. however, to the best of our knowledge, this work is the first to use the differences between gender expression in french and english to get insights into the inner representations used in nmt systems based on the transformer architecture. experiments reported in section 6 are inspired by causal analysis, a type of analysis that has been used by @xcite to analyze gender bias in neural monolingual nlp models. several studies have investigated gender bias using dedicated datasets, some of them presented at the acl workshop on gender bias in natural language processing @xcite @xcite . @xcite synthesizes the studies and datasets on gender bias for translation. in particular, the controlled test set considered in our work builds on the works of @xcite and @xcite , who both propose challenge test sets to evaluate gender bias in mt systems. the corresponding datasets consider the translation of occupational nouns with an anaphoric reference that makes gender explicit: the former contains instances of difficult translation patterns inspired by the winogender dataset of @xcite ; similar to our work, the latter contains a smaller set of simple sentences following a fixed template. working with a slightly more varied set of sentence templates chosen to unambiguously express the gender of the occupational noun, @xcite also found that a generic multilingual system translating out of english made more errors for feminine than for masculine nouns, a trend that is observed in 20 languages. noting the limitations of artificial datasets, (gonen and webster, 2020) develop a methodology to mine actual instances of likely biased translations in large corpora: these are found by automatically generating minimal contrasts in english source (e.g. replacing one noun by another) yielding a gender change in the target sentence. for instance, replacing 'doctor' by 'nurse' in the english might trigger a gender change in the corresponding translation in russian. other studies also investigated the influence of socio-professional parameters such as profession types and the importance and the correlation with qualifying adjectives. using the european multilingual classification of skills, competences and occupations (esco) data, @xcite suggests insufficient biodiversity of the data in the training sets of neural translation systems. focusing on 73 hypernyms from the 2,942 esco occupational nouns, she evidenced a gender gap by comparing the translations from google translate, deepl and microsoft translator in the two directions for the french/italian language pair. she built a dataset with respectively "competence" (i.e. intelligent) and "appearance" (i.e. beautiful) adjectives (adj) in the following @xmath0. the data was manually analyzed. adjectives seem to have no influence for the translation of masculine nouns, but competence adjectives affect the translation of feminine nouns more severely than appearance adjectives. @xcite studies gender bias in elmo embeddings using probing techniques. in this study, biases in the embeddings also implied biases in a pronoun reference resolution task using the wino-gender dataset. balancing data, and using averaged representations, to a certain extend, helped remove this bias. analyzing misclassified occupations in terms of gender, costa-jussà et al. (2020a) investigated the architectural bias for the translation of occupational nouns, suggesting that using language-specific encoders and decoder yields less bias than a shared encoder-decoder architecture. considering the attention patterns in the first two decoder layers, this paper shows that language-specific systems pay more attention to the determiner and occupational nouns, while bilingual models seem to rely more on the determiner. in the language-specific case, the embeddings are reported to encode more gender information. other architectural biases are considered by @xcite , who observed that gen-der bias is amplified when the system is optimised for speed. using a dictionary of occupations for english to spanish and english to german, they showed that correct translation rates degrade much faster than bleu scores when limiting the beamsize to 1 during beam search or using low-bit quantization. finally, another line of research focuses on mitigating gender bias. this can be either achieved by working on the system's internal represention (escudé font and costa-jussà, 2019), or by creating a more balanced training data where occupational roles are equally distributed between genders via counterfactual data augmentation @xcite . as discussed in @xcite , a cheaper, yet effective alternative to data augmentation, is to resort to domain adaptation techniques. ## discussion and conclusion our paper investigated the different pathways for gender transfer. we created a dataset inspired by previous research to test several hypotheses. our novel contribution is that we simultaneously mobilized several techniques, probing and manipulating. we extended the scope of the investigation of the locus of gender transfer beyond the determiner/noun analysis of @xcite and questioned the role of predicates and epicene determiners for french. our results show that gender information is present on the representation of all tokens built by the encoder and the decoder and suggest that the choice of the english possessive pronoun is distributed and is not based on the sole information contained in the representation of the french possessive pronoun. in our future research, we plan to identify how information is used to choose the form of the english pronoun and to generalize our observations to other languages and to other syntactic divergences.