P ara D etox: Detoxification with Parallel Data (2022)

Abstract: We present a novel pipeline for the collection of parallel data for the detoxification task. We collect non-toxic paraphrases for over 10,000 English toxic sentences. We also show that this pipeline can be used to distill a large existing corpus of paraphrases to get toxic-neutral sentence pairs. We release two parallel corpora which can be used for the training of detoxification models. To the best of our knowledge, these are the first parallel datasets for this task. We describe our pipeline in detail to make it fast to set up for a new language or domain, thus contributing to faster and easier development of new parallel resources. We train several detoxification models on the collected data and compare them with several baselines and state-of-the-art unsupervised approaches. We conduct both automatic and manual evaluations. All models trained on parallel data outperform the state-of-the-art unsupervised models by a large margin. This suggests that our novel datasets can boost the performance of detoxification systems.

## introduction detection of toxicity @xcite and other undesirable content, e.g. microaggressions @xcite or patronizing speech @xcite , is a popular topic of research in nlp. however, detection of harmful messages does not offer any proactive ways of fighting them (besides deletion). we suggest that such messages could be automatically rewritten to keep the useful content intact and eliminate toxicity. the task of rewriting toxic messages (detoxification) has already been tackled by nlp researchers @xcite . it is considered a variant of style transfer task, the task of rewriting a text saving * equal contribution the content and changing the style (style is defined as a characteristic of text such as sentiment, level of formality, or politeness, author profile (gender, political preferences), etc.). as a sequence-tosequence task, style transfer can be performed with an encoder-decoder model trained on parallel data. however, there exist only a few parallel style transfer corpora @xcite . since they usually do not exist "naturally", they need to be written from scratch. this is an expensive and laborious process. thus, such parallel datasets are extremely rare. @xcite so why would anyone believe this moron? paraphrase so why would anyone believe this person? so why would anyone believe somebody like him? reddit dude ham sandwich is the good sh*t . paraphrase dude ham sandwich is the good thing the ham sandwich, buddy, is the bomb. dude ham sandwich is good. we aim at boosting the research in detoxification by collecting an english parallel corpus of toxic sentences and their non-toxic paraphrases. we suggest a new crowdsourcing pipeline for collecting parallel style transfer data. it does not employ experts, which makes the data collection faster and cheaper. in addition to generating the detoxified versions of texts, we consider a way to distill existing datasets of paraphrases for style-specific data. in particular, we find the pairs of toxic and non-toxic sentences in the paranmt dataset @xcite of english paraphrases and filter them using our crowdsourcing setup. the pipelines are described in detail to make them easy to replicate. thus, we suggest that by reusing these pipelines the new parallel style transfer datasets can be collected in a fast and affordable way. finally, we validate the usefulness of our datasets by training detoxification models on them and comparing their performance with state-of-theart methods. models trained on parallel data significantly outperform other models in terms of automatic metrics and human evaluation. the contributions of our work are three-fold: ## related work style transfer datasets when collecting nonparallel style transfer corpora, style labels often already exist in the data (e.g. positive and negative reviews @xcite ) or its source serves as a label (e.g. twitter, academic texts, legal documents, etc.). thus, data collection is reduced to fetching the texts from their sources, and the corpus size depends only on the available amount of text. conversely, parallel corpora are usually more difficult to get. there exist parallel style transfer datasets fetched from "naturally" available parallel sources: the bible dataset @xcite features multiple translations of the bible from different epochs, biased-to-neutral wikipedia corpus @xcite uses the information on article edits. besides these special cases, there exists a large style transfer dataset that was created from scratch. this is the gyafc dataset @xcite of informal sentences and their formal versions written by crowd workers and reviewed by experts. since toxic-neutral pairs also do not occur in the wild, we follow this data collection setup with a notable difference -we replace expert validation of crowdsourced sentences with crowd validation and additionally optimize the cost. ## data collection pipeline our goal is to yield pairs of sentences that have the same meanings and are contrasted in terms of rewrite this text so that it does not sound offensive and its meaning stays the same you realize that's stupid, don't you? your text i can't rewrite the text the text is meaningless the text is not offensive removing the offense will change the meaning other your reason offensiveness -one of the sentences is toxic and the other is neutral. we consider two scenarios: the manual rewriting of toxic sentences into neutral ones and the selection of toxic-neutral pairs from existing paraphrases. unlike a similar work of @xcite , we hire crowd workers not only for the generation of paraphrases but also for their validation, which reduces both time and cost. ## evaluation to evaluate the collected corpora, we use them to train several supervised detoxification models. we separate the paradetox dataset into training and test parts (11,939 and 671 sentence pairs, respectively). the test sentences have one reference per sentence. we manually validate the test set to exclude the appearance of non-detoxifiable sentences or sentences which stayed toxic after rewriting (we need to verify that since the corpus was generated via crowdsourcing only). we do not use the test set neither for training nor for parameter selection of the models. ## conclusions we present paradetox -an english parallel corpus for the detoxification task. it contains almost 12,000 user-generated toxic sentences manually rewritten by crowd workers. to the best of our knowledge, this is the first parallel detoxification dataset. we present a novel data collection pipeline and show that parallel data can be generated using only crowdsourcing. we also adopt this pipeline to the style-based distillation of paraphrase corpus. we confirm the usefulness of our datasets by training sequence-to-sequence models on them. the experiments show that the use of parallel data yields models which significantly outperform style transfer models trained on non-parallel data. besides that, we confirm that filtering the noisy parallel data can lead to considerable improvement. we see that it is enough to get 1,000 parallel sentences to perform detoxification with high quality. this suggests that our pipeline can be successfully applied to create useful parallel resources for style transfer even in cases of limited finance or lack of crowd workers because the cost of generating 1,000 examples is very low. finally, we investigate the relationship between metrics and find that automatic evaluation does not always match the manual judgments and referencebased bleu cannot replace human evaluation, because it measures content preservation.