Gender bias amplification during Speed-Quality optimization in Neural Machine Translation (2021)

Abstract: Is bias amplified when neural machine translation (NMT) models are optimized for speed and evaluated on generic test sets using BLEU? We investigate architectures and techniques commonly used to speed up decoding in Transformer-based models, such as greedy search, quantization, average attention networks (AANs) and shallow decoder models and show their effect on gendered noun translation. We construct a new gender bias test set, SimpleGEN, based on gendered noun phrases in which there is a single, unambiguous, correct answer. While we find minimal overall BLEU degradation as we apply speed optimizations, we observe that gendered noun translation performance degrades at a much faster rate.

## introduction optimizing machine translation models for production, where it has the most impact on society at large, will invariably include speed-accuracy trade-offs, where accuracy is typically approximated by bleu scores @xcite on generic test sets. however, bleu is notably not sensitive to specific biases such as gender. even when speed optimizations are evaluated in shared tasks, they typically use bleu @xcite to approximate quality, thereby missing gender bias. furthermore, these biases probably evade detection in shared tasks that focus on quality without a speed incentive @xcite because participants would not typically optimize their systems for speed. hence, it is not clear if neural machine translation (nmt) speed-accuracy optimizations amplify biases. this work attempts to shed light on the algorithmic choices made during speed-accuracy optimizations source that physician is a funny lady! reference ¡esa médica/doctora es una mujer graciosa! system a ¡ese ::::: médico es una dama graciosa! system b ¡ese ::::: médico es una dama divertida! system c ¡ese ::::: médico es una mujer divertida! system d ¡ese ::::: médico es una dama divertida! all of these systems fail to consider the token "lady" when translating the occupation-noun, rendering it in with the masculine gender "doctor/médico". and their impact on gender biases in an nmt system, complementing existing work on data bias. we explore optimizations choices such as (i) search (changing the beam size in beam search); (ii) architecture configurations (changing the number of encoder and decoder layers); (iii) model based speedups (using averaged attention networks @xcite ); and (iv) 8-bit quantization of a trained model.. prominent prior work on gender bias evaluation forces the system to "guess" the gender @xcite of certain occupation nouns in the source sentence. consider, the english source sentence "that physician is funny.", containing no information regarding the physician's gender. when translating this sentence into spanish (where the occupation nouns are explicitly specified for gender), an nmt model is forced to guess the gender of the physician and choose between masculine forms, doctor/médico or feminine forms doctora/médica. while investigating bias in these settings is valuable, in this paper, we hope to highlight that the problem is much worse -despite an explicit gender reference in the sentence, nmt systems still generate the wrong gender in translation (see templates that f/m-occ-sg is a funny f/m-n-sg! my f/m-rel is a f/m-occ-sg. keywords f-occ-@xmath0, nanny...} m-occ-@xmath1, mechanic...} f-@xmath2, mother..} m-@xmath3, father...} f-n-@xmath4, gal, lady...} m-n-@xmath5, guy...} pro. momc that engineer is a funny guy! my father is a mechanic. generated fofc that nanny is a funny lady! my mother is a nurse. anti. mofc that mechanic is my funny woman! my sister is a physician. fomc that nurse is funny man! my brother is a nanny. a key differentiating characterization of our test set is that there is no ambiguity about the gender of the occupation-noun. we achieve this by using carefully constructed templates such that there is enough contextual evidence to unambiguously specify the gender of the occupation-noun. our templates specify a "scaffolding" for sentences with keywords acting as placeholders for values (see to evaluate the translations of nmt models on simplegen, we also create an occupation-noun bilingual dictionary, that considers the number and gender as well as synonyms for the occupations. for example for the en-es direction, the english occupation term 'physician", has corresponding entries for its feminine forms in spanish as "doctora" and "médica" and for its masculine forms "doctor" and "médico" (see table a8 for our full dictionary). by design, non-occupation keywords such as f-rel and f-n-sg specify the expected gender of the occupation-noun on the target side, enabling dictionary based correctness verification. ## speeding up nmt there are several "knobs" that can be tweaked to speed up inference for nmt models. setting the beam-size (bs) to 1 during beam search is likely the simplest approach to obtain quick speedups. lowbit quantization (int8) is another recent approach which improves decoding speed and reduces the memory footprint of models @xcite . for model and architecture based speedups, we focus our attention on transformer based nmt models which are now the work-horses in nlp and mt @xcite . while transformers are faster to train compared to their predecessors, recurrent neural network (rnn) encoderdecoders @xcite , transformers suffer from slower decoding speed. subsequently, there has been interest in improving the decoding speed of transformers. shallow decoders (sd): shallow decoder models simply reduce the decoder depth and increase the encoder depth in response to the observation that decoding latency is proportional to the number of decoder layers @xcite @xcite ). alternatively, one can employ sd models without increasing the encoder layers resulting in smaller (and faster) models. average attention networks (aan): average attention networks reduce the quadratic complexity of the decoder attention mechanism to linear time by replacing the decoder-side self-attention with an average-attention operation using a fixed weight for all time-steps @xcite . this results in a ≈ 3-4x decoding speedup over the standard transformer. ## experimental setup our objective is not to compare the various optimization methods against each other, but rather surface the impact of these algorithmic choices on gender biases. we treat all the optimization choices described in section 3 as data points available to conduct our analysis. to this end, we train models with all combinations of optimizations described in section 3 using the fairseq toolkit @xcite . our baseline is a standard large transformer with a (6, 6) encoder-decoder layer configuration. for our sd models we use the following encoder-decoder layer configurations {(8, 4), (10, 2), (11, 1)}. we also train smaller shallow decoder (ssd) models without increasing the encoder depth {(6, 4), (6, 2), (6, 1)}. for each of these 7 configurations, we train aan versions. next, we save quantized and non-quantized versions for the 14 models, and decode with beam sizes of 1 and 5. we repeat our analysis for english to spanish and english to german directions, using wmt13 en-es and wmt14 en-de data sets, respectively. for the en-es we limited the training data to 4m sentence pairs (picked at random without replacement) to ensure that the training for the two language directions have comparable data sizes. we apply byte-pair encoding (bpe) with 32k merge operations to the data @xcite . we measure decoding times and bleu scores for the model's translations using the wmt test sets. next, we evaluate each model's performance on simplegen, specifically calculating the percent of correctly gendered nouns, incorrectly gendered nouns as well as inconclusive results. ## analysis while while tables 4a and 4b show select models, we illustrate and further confirm our findings using all the data points (56 models trained) using scatter plots shown in fig. 1 . we see that relative % drop in bleu aligns closely with the relative % drop in gendered translation in the pro-stereotypical setting. in the case of german, the two trendlines are virtually overlapping. however, we see a steep drop for the anti-stereotypical settings, suggesting that bleu scores computed using a typical test set only captures the stereotypical cases and even small reduction in bleu could result in more instances of biased translations, especially in female context sentences. ## related work previous research investigating gender bias in nmt has focused on data bias, ranging from assessment to mitigation. for example, @xcite adapted an evaluation data set for co-reference resolution to measure gender biases in machine translation. the sentences in this test set were created with ambiguous syntax, thus forcing the nmt model to "guess" the gender of the occupations. in contrast, there is always an unambiguous signal specifying the occupation-noun's gender in simplegen. similar work in speech-translation also studies contextual hints, but their work uses real-world sentences with complicated syntactic structures and sometimes the contextual hints are across sentence boundaries resulting in genderambiguous sentences @xcite . @xcite create a counterfactual data-augmentation scheme by converting between masculine and feminine inflected sentences. thus, with the additional modified sentences, the augmented data set equally represents both genders. @xcite and @xcite propose a dataannotation scheme in which the nmt model is trained to obey gender-specific tags provided with the source sentence. while escudé @xcite employ pre-trained wordembeddings which have undergone a "debiasing" process @xcite . @xcite and costa-jussà and de jorge (2020) propose domain-adaptation on a carefully curated data set that "corrects" the model's misgendering problems. costa-jussà et al. (2020) consider variations involving the amount of parameter-sharing between different language directions in multilingual nmt models. ## conclusion with the current mainstreaming of machine translation, and its impact on people's everyday lives, bias mitigation in nmt should extend beyond data modifications and counter bias amplification due to algorithmic choices as well. we focus on algorithmic choices typically considered in speed-accuracy trade offs during productionization of nmt models. our work illustrates that such trade offs, given current algorithmic choice practices, result in significant impact on gender translation, namely amplifying biases. in the process of this investigation, we construct a new gender translation evaluation set, simplegen, and use it to show that modern nmt architectures struggle to overcome gender biases even when translating source sentences that are syntactically unambiguous and clearly marked for gender. table a5 : keywords and the values they can take. occupation keywords values f-occ-sg clerk, designer, hairdresser, housekeeper, nanny, nurse, secretary m-occ-sg director, engineer, truck driver, farmer, laborer, mechanic, physician, president, plumber, carpenter, groundskeeper f-occ-pl clerks, designers, hairdressers, housekeepers, nannies, nurses, secretaries m-occ-pl directors, engineers, truck drivers, farmers, laborers, mechanics, physicians, presidents, plumbers, carpenters, groundskeepers f-occ-sg-c clerk, designer, hairdresser, housekeeper, nanny, nurse, secretary m-occ-sg-c director, truck driver, farmer, laborer, mechanic, physician, president, plumber, carpenter, groundskeeper f-occ-pl-c clerks, designers, hairdressers, housekeepers, nannies, nurses, secretaries m-occ-pl-c directors, truck drivers, farmers, laborers, mechanics, physicians, presidents, plumbers, carpenters, groundskeepers table a6 : occupation keywords and the values they can take. the prefix "m-" and "f-" indicate that according to the u.s department of labor these occupations have a higher percentage of male and female works, respectively. table a7 shows the template we use to generate our source sentences in simplegen. we can generate sentences in one of the four sub-categories (momc, mofc, fofc, fomc) by setting occupation keywords with the prefix m-or f-from our terminology set table a6 ). for example, to generate mofc sentences, we set occupation-keywords with prefix m-and non-occupation keywords with prefix f-.