SYSTEMATIC RECTIFICATION OF LANGUAGE MODELS VIA DEAD-END ANALYSIS

Abstract

With adversarial or otherwise normal prompts, existing large language models (LLM) can be pushed to generate toxic discourses. One way to reduce the risk of LLMs generating undesired discourses is to alter the training of the LLM. This can be very restrictive due to demanding computation requirements. Other methods rely on rule-based or prompt-based token elimination, which are limited as they dismiss future tokens and the overall meaning of the complete discourse. Here, we center detoxification on the probability that the finished discourse is ultimately considered toxic. That is, at each point, we advise against token selections proportional to how likely a finished text from this point will be toxic. To this end, we formally extend the dead-end theory from the recent reinforcement learning (RL) literature to also cover uncertain outcomes. Our approach, called rectification, utilizes a separate but significantly smaller model for detoxification, which can be applied to diverse LLMs as long as they share the same vocabulary. Importantly, our method does not require access to the internal representations of the LLM, but only the token probability distribution at each decoding step. This is crucial as many LLMs today are hosted in servers and only accessible through APIs. When applied to various LLMs, including GPT-3, our approach significantly improves the generated discourse compared to the base LLMs and other techniques in terms of both the overall language and detoxification performance.

1. INTRODUCTION

Large-scale Transformer-based (Vaswani et al., 2017) language models (LMs) have shown tremendous progress and grown in importance across various NLP downstream tasks, often providing stateof-the-art performances over the last few years (Devlin et al., 2019; Yang et al., 2019; Raffel et al., 2020; Peters et al., 2018) . Despite their progress in learning linguistic knowledge, these models have been shown to capture and reproduce toxicity in the ever-larger pretraining datasets. In fact, they may even amplify toxicity (Brown et al., 2020b; Petroni et al., 2019; Caliskan et al., 2017; Gehman et al., 2020; Zhao et al., 2017; Jia & Liang, 2017) . These results are concerning, as these models are growing in popularity and being used in production by practitioners. Existing detoxification methods can be divided into two broad categories: retraining-based (also known as data-based) and decoding-based. Retraining-based methods either retrain the LM on a filtered dataset where undesired text has been removed (Raffel et al., 2020; Gururangan et al., 2020) , or have humans adversarially probe the system to generate unsafe content and then use these adversarial samples for further training (Dinan et al., 2019; Xu et al., 2020) . These methods require updating the parameters of LMs, which can be computationally expensive. Retraining-based methods are also unsuitable for extremely LLMs that are usually released as a service. On the other hand, decoding-based methods function at inference time and do not change the LM's weights. Examples include Plug and Play Language Models (PPLM; Dathathri et al. ( 2020)), word-filtering (Gehman

