원시데이터 수집 시스템
선정목록으로

Parameter-Efficient Detoxification with Contrastive Decoding

관련 수소연료전지 · (5) 연료전지용 수분제어장치(가습기)

기본 정보

저자
  1. Tong Niu — Salesforce AI Research
  2. Caiming Xiong — Salesforce AI Research
  3. Yingbo Zhou — Salesforce AI Research
  4. Semih Yavuz — Salesforce AI Research
DOI
10.18653/v1/2024.hucllm-1.3
저널
–
발행년도
2024
발행기관
–
피인용수
1
라이선스
cc-by
논문 유형
–
언어
–
원문 페이지
http://dx.doi.org/10.18653/v1/2024.hucllm-1.3
토픽
Analytical Chemistry and Sensors
OpenAlex ID
W4402683184

평가 내용

관련도
관련
사업분야
수소연료전지 · (5) 연료전지용 수분제어장치(가습기)
부 분야
–
R&D 측면
–
확신도
–
근거 용어
–
판단 근거
임베딩 유사도 기반 평가로 '수소연료전지 > 연료전지용 수분제어장치(가습기)' 분야에 선정된 논문입니다.
R&D 활용 포인트
–
평가 입력
–

초록

The field of natural language generation has witnessed significant advancements in recent years, including the development of controllable text generation techniques.However, controlling the attributes of the generated text remains a challenge, especially when aiming to avoid undesirable behavior such as toxicity.In this work, we introduce Detoxification Generator (DETOXIGEN), an inference-time algorithm that steers the generation away from unwanted styles.DETOXIGEN is an ensemble of a pre-trained language model (generator) and a detoxifier.The detoxifier is trained intentionally on the toxic data representative of the undesirable attribute, encouraging it to generate text in that style exclusively.During the actual generation, we use the trained detoxifier to produce undesirable tokens for the generator to contrast against at each decoding step.This approach directly informs the generator to avoid generating tokens that the detoxifier considers highly likely.We evaluate DETOXIGEN on the commonly used REALTOXICITYPROMPTS benchmark (Gehman et al., 2020) with various language models as generators.We find that it significantly outperforms previous approaches in detoxification metrics while not compromising on the generation quality.Moreover, the detoxifier is obtained by soft prompt-tuning using the same backbone language model as the generator.Hence, DETOXIGEN requires only a tiny amount of extra weights from the virtual tokens of the detoxifier to be loaded into GPU memory while decoding, making it a promising lightweight, practical, and parameter-efficient detoxification strategy.

본문 49,020자

본문 펼치기
# Parameter-Efficient Detoxification with Contrastive Decoding Tong Niu, Caiming Xiong, Yingbo Zhou <sup>_∗_</sup> , Semih Yavuz <sup>*</sup> Salesforce AI Research Abstract The field of natural language generation has witnessed significant advancements in recent years, including the development of controllable text generation techniques. However, controlling the attributes of the generated text remains a challenge, especially when aiming to avoid undesirable behavior such as toxicity. In this work, we introduce _Detoxification Gener-_ _ator_ (DETOXIGEN), an inference-time algorithm that steers the generation away from unwanted styles. DETOXIGEN is an ensemble of a pre-trained language model ( _generator_ ) and a _detoxifier_ . The _detoxifier_ is trained intentionally on the toxic data representative of the undesirable attribute, encouraging it to generate text in that style exclusively. During the actual generation, we use the trained _detoxifier_ to produce undesirable tokens for the _generator_ to contrast against at each decoding step. This approach directly informs the _generator_ to avoid generating tokens that the _detoxifier_ considers highly likely. We evaluate DETOXIGEN on the commonly used REALTOXICITYPROMPTS benchmark (Gehman et al., 2020) with various language models as _generator_ s. We find that it significantly outperforms previous approaches in detoxification metrics while not compromising on the generation quality. Moreover, the _detoxifier_ is obtained by soft prompt-tuning using the same backbone language model as the _generator_ . Hence, DETOXIGEN requires only a tiny amount of extra weights from the virtual tokens of the _detoxifier_ to be loaded into GPU memory while decoding, making it a promising lightweight, practical, and parameter-efficient detoxification strategy. 1 Introduction Large language models (LLMs) have demonstrated remarkable promise in various generative tasks by first self-supervised pretraining on large text corpora and then finetuning with instruction data for - indicates corresponding authors. alignment (Mishra et al., 2022). Yet a wealth of previous work has demonstrated that pre-trained models inherit toxicity and biases from their training corpora (Zhao et al., 2019; May et al., 2019; Kurita et al., 2019; Basta et al., 2019). As a result, generative models (OpenAI, 2023; Touvron et al., 2023; Nijkamp et al., 2023) tend to degenerate into unsafe text even when conditioning on seemingly innocuous prompts (Wallace et al., 2019; Sheng et al., 2019; Gehman et al., 2020), which is difficult to resolve by prompt engineering alone (Zong and Krishnamachari, 2022; Liu et al., 2022b; Webson and Pavlick, 2022; Lou et al., 2023). To address this challenge, a plethora of approaches have been proposed, which usually require full-model finetuning of the underlying language model to build the _detoxifier_ (Dathathri et al., 2019; Gururangan et al., 2020; Krause et al., 2021; Liu et al., 2021a). However, nowadays the largest LLMs typically contain more than 100 billion parameters, making such resource-intensive tuning less viable. This trend calls for more parameterefficient approaches. In this work, we propose DETOXIGEN (Figure 1), a parameter-efficient framework that leverages the frozen weights of the language model itself and only introduces a tiny portion of new model parameters to detoxify generation. <sup>1</sup> During training, we use prompt tuning (Lester et al., 2021) to train a _detoxifier_ exclusively on toxic data with the nexttoken prediction objective. The resulting _detoxifier_ shares all the backbone model weights with the LLM (i.e., the _generator_ ). During inference, we build on top of the contrastive decoding (Li et al., 2023) paradigm and employ the _detoxifier_ to manipulate the output probability distribution of the LLM for each generation step. Intuitively, the _generator_ avoids outputting tokens that the _detoxifier_ considers highly probable. For example, in figure 1 the 1We will make our code publicly available. 30 _Proceedings of the 1st Human_ _Centered Large Language Modeling Workshop_ pages 30 40 _detoxifier_ considers the gender-biased word “his” very likely as the next token, helping the _generator_ to score down the probability of that token. We evaluate our framework on the REALTOXI CITYPROMPTS dataset (Gehman et al., 2020) and find that it outperforms previous approaches on the standard benchmark metrics by a significant margin, indicating that the text generated by our model is both safer and of higher quality. We also conduct ablation studies and pair models of different sizes from the same model family (e.g., the Llama-2 (Touvron et al., 2023) family). These studies show that pairing a _generator_ with a _detoxifier_ that shares the same backbone LLM is indeed the best-performing configuration. Our main contributions are: (1) Performance: Propose a detoxification framework that outperforms previous models by a large margin on commonly used detoxification benchmarks/metrics; (2) Efficiency: We apply parameter-efficient learning to controllable text generation for detoxification. Our model introduces the least amount of additional parameters (hence also requires less data to train) as compared to state-of-the-art models; (3) Transferability: Our _detoxifier_ model only requires toxic data and does not require any contrastive (non-toxic) data, making our approach transferable thanks to the easier and more manageable data curation. 2 Model 2.1 Task Formulation We consider controlled decoding-time approaches for open-ended text generation. A _generator_, in our case a language model, receives an unfinished input text as a prompt and aims to output a fluent and coherent continuation that avoids toxicity with the help of a _detoxifier_, which is another language model trained with data of the target attribute. 2.2 Model Components Generator Let _x<t_ = _x_ 1 _, x_ 2 _, ..., xt−_ 1 be a prompt consisting of ( _t −_ 1) tokens, where each _ti_ (1 _≤_ _i ≤_ _t_ _−_ 1) is a token in the vocabulary set _V_ of the language model (LM). The LM encodes _x<t_ in an autoregressive fashion and outputs z _t_ _∈_ R <sup>_|V |_</sup>, where z _t_ denotes the logits for the _t_ th token _xt_ and _|V |_ corresponds to the vocabulary size. The LM then obtains a probability distribution _PGEN_ over _V_ by computing the softmax of z _t_ 31 _PGEN_ ( _xt|x<t_ ) = softmax( z _t_ ) _,_ (1) and the next token is sampled from this distribution. Detoxifier The _detoxifier_ takes as input the same prompt fed to the _generator_ for each generation step and computes a probability distribution _PDE_ ( _Xt|x<t_ ) over _|V |_ in the same way. However, the _detoxifier_ is not a vanilla LM like the _generator_, but rather an LM specially trained to output toxic content. Intuitively, the _generator_ is discouraged from outputting tokens that the _detoxifier_ considers highly likely, thus avoiding toxic generations. In other words, the decoding process involves an ensemble of the two LMs to obtain the final output probability distribution _P_ ( _xt|x<t_ ): _P_ ( _xt|x<t_ ) = _PGEN_ + _α_ ∆ _P_ (2) ∆ _P_ = _PGEN_ _−_ _PDE,_ (3) where the hyperparameter _α_ denotes the _control_ _strength_ of the model and ∆ _P_ represents the _proba-_ _bility correction term_ determined by the difference between the two distributions. Intuitively, _α_ dictates how much we want to modify the _generator_ ’s probability distribution through the correction term ∆ _P_ . Since it is possible that _P_ ( _xt|x<t_ ) contains values that fall out of the [0 _._ 0 _,_ 1 _._ 0] range, making them invalid probabilities, we also clip them on both sides - i.e., setting any value that is below 0 _._ 0 to 0 _._ 0 and any value above 1 _._ 0 to 1 _._ 0. The resulting probability vector is then normalized by first computing its log probabilities and then taking the softmax. Our formulation is closely related to that in Contrastive Decoding (Li et al., 2023) and DExperts (Liu et al., 2021a), but we differ by manipulating in the probability space rather than the logits space because we found in our initial experiments that directly dealing with probability distributions result in better performance on the downstream task. Sampling To constrain the model to only generate plausible tokens, we first employ Nucleus (Top- _p_ ) Sampling (Holtzman et al., 2020) to limit the vocabulary _V_ to a subset _V_ <sup>(</sup> <sup>_p_</sup> <sup>)</sup> by only selecting the highest probability tokens whose cumulative probability mass exceeds some threshold _p_ _∈_ [0 _._ 0 _,_ 1 _._ 0]. More specifically, given the distribution _PGEN_ ( _xt|x<t_ ) in Equation 1, the top- _p_ Figure 1: Illustration of the DETOXIGEN pipeline that avoids generating a gender-biased next token. A prompt is fed into both the _generator_ and the _detoxifier_, which share the same underlying frozen weights from the backbone language model. Additionally, the _detoxifier_ contains virtual tokens whose embeddings are trainable. Such virtual tokens steer the _detoxifier_ toward generating only toxic continuations. Each model provides its own probability distribution for the next token, where DETOXIGEN combines the two distributions and performs the detoxification. vocabulary _V_ <sup>(</sup> <sup>_p_</sup> <sup>)</sup> _⊆_ _V_ is defined by the smallest vocabulary set such that _x∈_ - _V_ <sup>(</sup> <sup>_p_</sup> <sup>)</sup> _PGEN_ ( _x|x<t_ ) _≥_ _p._ (4) The Top-p sampling then truncates the less reliable tail of the distribution by setting _P_ <sup>_′_</sup> [ _x_ ] = _P_ [ _x_ ] _,_ if _x ∈_ _V_ <sup>(</sup> <sup>_p_</sup> <sup>)</sup> (5) �0 _,_ otherwise _._ The _detoxifier_ then comes in and only manipulates logits in the set _V_ <sup>(</sup> <sup>_p_</sup> <sup>)</sup> so that regardless of how _PGEN_ is modified, the generated tokens are guaranteed to be plausible as evaluated by the _gen-_ _erator_ . When applying this restriction, equation 1 becomes _P_ <sup>_′_</sup> ( _xt|x<t_ ) = _P_ <sup>_′_</sup> _GEN_ <sup>_′_</sup> <sup>+</sup> <sup>_α_</sup> <sup>(</sup> <sup>_P ′_</sup> <sup>_′_</sup> _GEN_ <sup>_−_</sup> <sup>_P ′_</sup> _DE_ <sup>_′_</sup> <sup>)</sup> <sup>_._</sup> (6) framework. Hence we adopt Prompt Tuning (Lester et al., 2021), a parameter-efficient training method, to train a language model exclusively on toxic data. This method learns soft prompts (or virtual tokens), whose embeddings are trainable parameters to condition frozen language models to perform the target downstream tasks. 3 Experimental Setup 3.1 Backbone Models Following Liu et al. (2021a), we use GPT2large (Radford et al., 2019) as the _generator_ and the backbone of the _detoxifier_ . We use GPT2-XL to evaluate the generation quality. For ablation studies reported in Section 4.3, we also consider GPT2 with small and medium sizes. It is worth noting that previous work selected the GPT2 family mostly because it was one of the strongest models at the time. To observe if the same trend of performance holds for the most recent LLMs, we also experiment with another family of Transformer-based (Vaswani et al., 2017) language models, namely Llama-2 (Touvron et al., 2023) because it satisfies the following three criteria: (1) It is publicly released so that it is easier for researchers to reproduce and compare with 2.3 Parameter-Efficient Training of Detoxifier As discussed in Section 1, due to the increasing size of large language models, we aim to introduce as few additional model parameters as possible to our 32 our work; (2) It achieves state-of-the-art performance on diverse benchmark datasets (Nijkamp et al., 2023); (3) It has three sizes so that we can evaluate whether larger models can be paired with smaller ones for detoxification – such is the setting when we prioritize reducing latency over minimizing GPU memory footprint. Hence we experiment with Llama-2 with 7B, 13B, and 70B parameters, respectively. Due to the large size of Llama-2-70B, for all our experiments we use bfloat16 for both training and inference to increase throughput and reduce GPU memory usage. We evaluate perplexity from the Llama-2 family with Llama-2-7B unless otherwise stated. 3.2 Training of Detoxifier We prompt tune the _detoxifier_ with the standard language modeling objective (Bengio et al., 2000) which learns the parameters of the conditional probability distribution of the next word given the preceding context. We extract the training data from the human-annotated Jigsaw Unintended Bias in Toxicity Classification (Borkan et al., 2019). An example is considered toxic if more than 50% of the annotators classify it as toxic. This threshold splits the corpus into around 160K toxic and 1 _._ 4 _M_ nontoxic examples. We only train our models with the toxic part of the data. For prompt tuning, we use 100 virtual tokens for each model with a learning rate of 0 _._ 1. To efficiently explore different parameter-efficient methods, we use the PEFT (Parameter-Efficient FineTuning), a library that wraps around HuggingFace Transformers (Wolf et al., 2020) model objects and provides out-of-the-box implementations for widely adopted PEFT approaches (Mangrulkar et al., 2022). Because we need to obtain logits from the _detoxifier_ for each generation step, we overwrite the PEFT model object to only prepend virtual tokens to the input for the first generation step. 3.3 Hyperparameter Tuning We tune the hyperparameter _α_ with a held-out val idation set and perform a grid search from 1 _._ 0 to 9 _._ 0 with a 1 _._ 0 increment. As will be shown in Section 4.1, we find that _α_ = 5 _._ 0 strikes the best balance between toxicity and generation quality. We thus adopt this value throughout all experiments. 3.4 Evaluation Data We follow Liu et al. (2021a) to use the REALTOXIC ITYPROMPTS dataset (Gehman et al., 2020) which contains 100K naturally occurring, sentence-level prompts derived from a large corpus of English web text. These prompts are annotated with toxicity scores and language models are known to degenerate into toxic continuation when conditioning on them. To determine the _detoxifier_ strength _α_, we randomly sample 1k prompts as the validation set and another disjoint 10k as the test set. 3.5 Metrics Toxicity Following Gehman et al. (2020), we use the Perspective API <sup>2</sup> to measure the toxicity of generations. This score is obtained from a CNN model (Lecun et al., 1998) trained on a non-public corpus of Wikipedia comments. We compute two metrics based on the toxicity scores following Liu et al. (2021a): (1) Average Maximum Toxicity: The average maximum toxicity over _k_ = 25 generations; (2) Toxicity Probability: The empirical probability of a generation with toxicity _≥_ 0 _._ 5 for at least once over _k_ = 25 generations. Quality The Quality metric consists of both fluency and diversity. Heeding both aspects makes it easier to spot cases where the generation is likely but generic, or diverse but unlikely. We use corpuslevel Perplexity to evaluate fluency and Distinct2 and -3 (Li et al., 2016) to evaluate diversity. Distinct-2 and distinct-3 correspond respectively to the number of distinct bigrams and trigrams divided by the total number of generated words. 3.6 Baseline Models We compare DETOXIGEN with a diverse set of previously reported baseline models (Gehman et al., 2020; Liu et al., 2021a), including Domain-Adaptive Pretraining (DAPT) (Gururangan et al., 2020), Plug-and-Play Language Models (PPLM) (Dathathri et al., 2019), Non-Toxic Expert (Liu et al., 2021a), Generative Discriminators (GeDi) (Krause et al., 2021), and Decoding-time Experts (DExperts) (Liu et al., 2021a). We follow these baselines to use Nucleus Sampling with _p_ = 0 _._ 9 for generation. [2https://perspectiveapi.com/](https://perspectiveapi.com/) 33 4 Results and Analysis 4.1 Hyperparameter Tuning through Validation Set As mentioned in Section 3.3, we perform a grid search of _α_ with values 1 _._ 0 _,_ 2 _._ 0 _, ...,_ 9 _._ 0. We show the results on both GPT2-large and Llama-2-7b so that we can observe the trend on both early and more recent models. From Table 2, we can see that for both models, there is a steady increase in Perplexity (last column) as _α_ grows, indicating a monotonic decrease in generation quality. Intuitively, this trend makes sense because the more we perturb the original output distribution, the more likely it is for the language model to generate less plausible tokens. To maintain a balance between toxicity and quality, we seek the tipping point where further increasing _α_ only brings a diminishing return on reducing toxicity. We observe that for both models, this tipping point happens at _α_ = 5 _._ 0. Hence we adopt this hyperparameter setting throughout all other experiments. 4.2 Results on GPT2-large We then compare with previous approaches on GPT2-large. From Table 1, we can see that our model DETOXIGEN outperforms previous frameworks by a large margin although only tuned on the toxic split of the training data. Among all models, DETOXIGEN (GPT2-large) achieves the lowest Average Maximum Toxicity and Toxicity Probability, while obtaining a Perplexity that is quite close to that of the vanilla GPT-2 large, indicating minimum compromise on generation quality. The Llama-2-7B version of DETOXIGEN achieves even better results. However, it is based on a much stronger backbone language model, hence not comparable to previous work. We still include Llama-2 results in this table to show the gap between earlier and more recent large language models. We also follow Liu et al. (2021a) and report Distinct-N metrics, which are intended to prevent the model from degenerating into dull and generic continuations. We observe that the Distinct-N results do not vary much across diverse kinds of models. Hence for the results reported afterwards, we skip this metric and only report Perplexity. 4.3 Ablation Studies on Model Sizes We also explore pairing models of different sizes as the _generator_ and the _detoxifier_, respectively. This setting targets the cases where either latency is the major concern such that we want one small _detoxifier_ to steer the generation of all other model sizes, or when we intend to train a _detoxifier_ once and plug-and-play it with all other model sizes. The results of such pairings are presented in the matrix-like tables (Table 3, 5, 4, and 6). We report toxicity and quality in separate tables to make the comparisons clearer. From the four tables, we can observe quite a few interesting patterns. Consistent Toxicity Reduction In the tables, we can observe that when comparing with the no_detoxifier_ setting (the column with _None_ as header), our approach consistently and significantly reduces the toxicity of the backbone model while not sacrificing much on generation quality. This trend is observed for both the GPT-2 and the Llama-2 model families. Entries along the Diagonal As shown in Table 3 and 4, entries on the diagonal of the result matrix (i.e., without the first column that has _None_ as the header) consistently outperform their neighbors in terms of toxicity. These are the settings where the _generator_ and the _detoxifier_ share exactly the same backbone language model. They also achieve the best row-wise Perplexity as compared to off-diagonal models (Table 5 and 6). We hypothesize that this is because the output probability distributions of the _generator_ and the _detoxifier_ with the same underlying backbone parameters are more compatible with each other than backbones of different sizes. Recall in Section 1 that one of our major goals is to introduce as few new model parameters as possible. Our cross-model results clearly show that sharing weights between the _gen-_ _erator_ and the _detoxifier_ turns out to be the best setting among all we have investigated. Entries symmetric to the diagonal Comparing entries that are symmetric to the diagonal (e.g., comparing GPT2-XL detoxified by GPT2-small with GPT2-small detoxified by GPT2-XL) in Table 3 and 4, we can observe a consistent pattern that given two models of different sizes, it is usually better to have the smaller model as the _generator_ and the larger model as the _detoxifier_ for detoxification. This indicates that larger models are more capable of capturing the distribution in the toxicity training corpus. Effect of Model Size Difference From the toxicity tables, we can also observe that the larger the 34 Table 1: Results on a random nontoxic 10K sample from the REALTOXICITYPROMPTS dataset. On the first row, the downward arrows indicate “the lower the better”, while the upward ones indicate the opposite. Avg. Max. Toxicity stands for “Average Maximum Toxicity”, PPL stands for “Perplexity”, and all models are evaluated with GPT2-XL. Dist-N stands for the Distinct-N metric. All models in this table use GPT2-large as the backbone model, except for the last row where Llama-2-7B is used. State-of-the-art results are boldfaced. Model <u>Toxicity</u> <u>(</u> _<u>↓</u>_ <u>)</u> <u>Fluency</u> <u>(</u> _<u>↓</u>_ <u>)</u> <u>Diversity</u> <u>(</u> _<u>↑</u>_ <u>)</u> <u>Avg.</u> <u>Max.</u> <u>Toxicity</u> <u>Toxicity Prob.</u> <u>PPL</u> <u>Dist-2</u> <u>Dist-3</u> <u>GPT2-large</u> <u>0.527</u> <u>0.520</u> <u>25.45</u> <u>0.85</u> <u>0.85</u> <u>PPLM</u> <u>0.520</u> <u>0.518</u> <u>32.58</u> <u>0.86</u> <u>0.86</u> Non-toxic Expert 0.485 0.464 40.61 0.86 0.86 DAPT 0.428 0.360 31.21 0.84 0.84 GeDi 0.363 0.217 60.03 0.84 0.83 <u>DExperts</u> <u>0.314</u> <u>0.128</u> <u>32.41</u> <u>0.84</u> <u>0.84</u> <u>DETOXIGEN (GPT</u> <u>2</u> <u>-large)</u> <u>0.254</u> <u>0.115</u> <u>27.54</u> <u>0.86</u> <u>0.86</u> <u>DETOXIGEN (Llama-</u> <u>2</u> <u>-7B)</u> <u>0.236</u> <u>0.103</u> <u>26.55</u> <u>0.85</u> <u>0.84</u> Table 2: Validation results obtained by varying the _detoxifier_ strength _α_ from 1 _._ 0 to 9 _._ 0 with GPT2-large and Llama-2-7b. Each setting is evaluated on a held-out validation set of size 1k from REALTOXICITYPROMPTS. The boldfaced rows indicate tipping points where further increasing _α_ starts to bring diminishing (sometimes even negative) returns on the balance between toxicity and fluency. Model Alpha <u>Toxicity</u> <u>(</u> _<u>↓</u>_ <u>)</u> <u>Fluency</u> <u>(</u> _<u>↓</u>_ <u>)</u> <u>Avg.</u> <u>Max.</u> <u>Toxicity</u> <u>Toxicity Prob.</u> <u>PPL</u> GPT2-large Llama-2-7b <u>1.0</u> <u>0.311</u> <u>0.172</u> <u>22.47</u> 2.0 0.284 0.145 23.54 3.0 0.276 0.146 24.66 4.0 0.261 0.127 25.83 5.0 0.258 0.115 26.65 6.0 0.261 0.128 27.54 7.0 0.256 0.121 28.19 8.0 0.257 0.125 28.82 <u>9.0</u> <u>0.258</u> <u>0.108</u> <u>29.59</u> <u>1.0</u> <u>0.290</u> <u>0.160</u> <u>19.88</u> 2.0 0.265 0.127 20.61 3.0 0.252 0.108 21.20 4.0 0.251 0.117 21.74 5.0 0.241 0.104 22.31 6.0 0.243 0.101 22.79 7.0 0.241 0.106 23.13 8.0 0.236 0.094 23.51 <u>9.0</u> <u>0.233</u> <u>0.097</u> <u>23.88</u> model size difference, the less effective the detoxification. For example, GPT2-XL detoxified by GPT2-small in Table 3 results in the worst toxicity among all settings, while we observe the same pattern where Llama-2-70B detoxified by Llama-2-7B has the highest toxicity among all settings. 5 Discussion It would be ideal if a _detoxifier_ could work out of the box (plug-and-play) and be readily applied to any LLM _generator_, even with a different tokenizer. To achieve this, one can take a common subset of the vocabulary sets between the _generator_ and the _detoxifier_, and only manipulate logits on this subset. We leave this as future work since the model families we investigate both already have diverse sizes. Throughout the paper, we have been focusing on avoiding undesired attributes. However, we note that our framework can also be used to generate text with any desired style (which could be a risk if that desire style happens to be _toxic_ ). All we need to do is flip the sign of the probability distribution correction term ∆ _P_ in Equation 2 and 3 as follows: _P_ ( _xt|x<t_ ) = _PGEN_ + _α_ ∆ _P_ (7) ∆ _P_ = _PDE_ _−_ _PGEN_ _._ (8) In addition, our approach could be applied to more general positive and negative attributes, including but not limited to politeness (DanescuNiculescu-Mizil et al., 2013; Niu and Bansal, 2018), hate speech (Golbeck et al., 2017), and microagressions (Breitfeller et al., 2019). In the case 35 Table 3: Toxicity results by pairing models of different sizes from the GPT-2 model family. All results are obtained on the validation set of size 1K. The column with the header _None_ indicates that no _detoxifier_ is used. _generator_ _<u>detoxifier</u>_ <u>[Avg.</u> <u>Max.</u> <u>Toxicity</u> _<u>|</u>_ <u>Toxicity Prob.]</u> _<u>None</u>_ <u>GPT2-small</u> <u>GPT2-medium</u> <u>GPT2-large</u> <u>GPT2-XL</u> <u>GPT2-small</u> <u>0.511</u> _|_ <u>0.413</u> <u>0.264</u> _|_ <u>0.119</u> <u>0.306</u> _|_ <u>0.161</u> <u>0.318</u> _|_ <u>0.183</u> <u>0.330</u> _|_ <u>0.195</u> GPT2-medium 0.514 _|_ 0.413 0.338 _|_ 0.195 0.280 _|_ 0.149 0.313 _|_ 0.182 0.331 _|_ 0.201 GPT2-large 0.499 _<u>|</u>_ 0.400 0.340 _<u>|</u>_ 0.215 0.322 _<u>|</u>_ 0.197 0.254 _<u>|</u>_ 0.115 0.314 _<u>|</u>_ 0.175 <u>GPT2-XL</u> <u>0.508</u> _<u>|</u>_ <u>0.432</u> <u>0.352</u> _<u>|</u>_ <u>0.230</u> <u>0.339</u> _<u>|</u>_ <u>0.202</u> <u>0.313</u> _<u>|</u>_ <u>0.177</u> <u>0.278</u> _<u>|</u>_ <u>0.124</u> Table 4: Toxicity results by pairing models of different sizes from the Llama-2 model family. All results are obtained on the validation set of size 1K. The column with the header _None_ indicates that no _detoxifier_ is used. _generator_ _<u>detoxifier</u>_ <u>[Avg.</u> <u>Max.</u> <u>Toxicity</u> _<u>|</u>_ <u>Toxicity Prob.]</u> _<u>None</u>_ <u>LLama-2-7B</u> <u>LLama-2-13B</u> <u>LLama-2-70B</u> <u>LLama-2-7B</u> <u>0.370</u> _|_ <u>0.285</u> <u>0.241</u> _|_ <u>0.104</u> <u>0.268</u> _|_ <u>0.131</u> <u>0.287</u> _|_ <u>0.155</u> LLama-2-13B 0.371 _<u>|</u>_ 0.275 0.285 _<u>|</u>_ 0.143 0.248 _<u>|</u>_ 0.112 0.295 _<u>|</u>_ 0.164 <u>LLama-2-70B</u> <u>0.371</u> _<u>|</u>_ <u>0.276</u> <u>0.295</u> _<u>|</u>_ <u>0.157</u> <u>0.293</u> _<u>|</u>_ <u>0.167</u> <u>0.277</u> _<u>|</u>_ <u>0.157</u> that we want to simultaneously control for multiple attributes, our framework is also compatible with mixed-batch inference (Liu et al., 2022a), where soft prompts of different attributes can be conditioned on in a single batch without increasing latency. 6 Related Work 6.1 Parameter-efficient Learning Parameter-efficient learning is a natural language processing paradigm to adapt a large language model to particular tasks or domains. It is usually used when fine-tuning the entire language model is prohibitively expensive. Among such approaches, LoRa (Hu et al., 2022) and AdaLoRa (Zhang et al., 2023) inject trainable rank decomposition matrices into each layer of the Transformer architecture, with the latter adaptively allocating the parameter budget among weight matrices according to their importance scores. Prefix Tuning (Li and Liang, 2021), P-Tuning (Liu et al., 2021b), and Prompt Tuning (Lester et al., 2021) prepend to the input sequence virtual tokens with trainable embeddings. Lastly, (IA) <sup>3</sup> scales activations by learned vectors. We choose Prompt Tuning in this work because it achieves competitive performance while involving no change in model architecture and not requiring any bootstrapping for the newly introduced model parameters. 6.2 Controllable Text Generation There have been multiple effective frameworks proposed for controllable text generation (Keskar et al., 2019; Sudhakar et al., 2019; Kurita et al., 2019; Welleck et al., 2020). 3 Among them, Domain-Adaptive Pretraining (DAPT) (Gururangan et al., 2020) and Self-Generation Enabled domain-Adaptive Training (SGEAT) (Wang et al., 2022) continues to finetune or apply parameterefficient tuning to the backbone language model with a non-toxic subset of OpenWebText to adapt it to the non-toxic style. Plug-and-Play Language Models (PPLM) (Dathathri et al., 2019) trains a toxicity classifier and leverages gradients from that classifier to update the language model’s hidden representations for each generation step. Generative Discriminators (GeDi) (Krause et al., 2021) prepends to the input a soft token serving as the label for the intended class of attribute. It can be viewed as prompt tuning with only one virtual token for each class (toxic and nontoxic). Decodingtime Experts (DExperts) (Liu et al., 2021a) train an expert and an anti-expert LM of opposing attributes with full finetuning. During inference, the logits difference between the two experts serves as the correction term for the logits of the base language model. Our work is different from the previous approaches in that we adopt parameter-efficient tuning that only introduces a few trainable parameters and our training only requires toxic examples rather than examples from both classes. 6.3 Contrastive Decoding Contrastive Decoding (Li et al., 2023; O’Brien and Lewis, 2023) is a search-based decoding method that optimizes a contrastive objective that returns 3We note that Inference-Time Policy Adapters (Lu et al., 2023) employs reinforcement learning for LM detoxification, but their approach assumes access to the Perspective API toxicity scores as a reward signal during training and hence not comparable to our work. 36 Table 5: Quality results by pairing models of different sizes from the GPT-2 model family. All results are obtained on the validation set of size 1K. The column with the header _None_ indicates that no _detoxifier_ is used. _generator_ _<u>detoxifier</u>_ <u>[PPL]</u> _<u>None</u>_ <u>GPT2-small</u> <u>GPT2-medium</u> <u>GPT2-large</u> <u>GPT2-XL</u> <u>GPT2-small</u> <u>49.90</u> <u>60.46</u> <u>76.83</u> <u>82.90</u> <u>91.02</u> GPT2-medium 36.91 38.38 39.73 51.00 58.64 GPT2-large 25.05 25.77 27.57 27.54 37.08 <u>GPT2-XL</u> <u>18.16</u> <u>18.54</u> <u>18.76</u> <u>19.77</u> <u>19.80</u> Table 6: Quality results by pairing models of different sizes from the Llama-2 model family. All results are obtained on the validation set of size 1K. The column with the header _None_ indicates that no _detoxifier_ is used. _generator_ _<u>detoxifier</u>_ <u>[PPL]</u> _<u>None</u>_ <u>LLama-2-7B</u> <u>LLama-2-13B</u> <u>LLama-2-70B</u> <u>LLama-2-7B</u> <u>19.65</u> <u>22.94</u> <u>23.12</u> <u>22.35</u> LLama-2-13B 21.69 28.38 25.47 26.90 <u>LLama-2-70B</u> <u>22.39</u> <u>29.68</u> <u>28.68</u> <u>26.55</u> the difference between the likelihood under a large and a small LM. Our algorithm is different from theirs in that we pair LMs of the same size (with the _detoxifier_ further tuned) and perform all manipulations in the probability space rather than directly in the logits space. 7 Conclusion We propose DETOXIGEN, a high-performing, parameter-efficient framework for detoxification during inference time. Our method only introduces a small portion of new parameters to train a _detoxi-_ _fier_ model that manipulates the output probability distribution of a generative model. On a standard detoxification benchmark, our approach outperforms all existing models in terms of both toxicity and quality. As language models grow ever larger in size, our controllable generation method shows the promise of quickly adapting to any language model without requiring additional computational resources or significant data curation efforts. 8 Limitations Although DETOXIGEN can work with models of different sizes, it is yet to show that a _generator_ with tokenizer A can be paired with a _detoxifier_ that uses tokenizer B with a different vocabulary set. We plan to address this limitation in future work where the _detoxifier_ can tokenize the generated text on the fly for each generation step, thus manipulating the logits of the _generator_ . Additionally, although leveraging the Perspective API makes our model readily comparable with previous work, such automatic evaluation may not capture the full spectrum of toxicity. Ideally, one would conduct human evaluations for each of the models under the same setting. Lastly, it would be helpful to show how our method generalizes to other styles and parameter-efficient tuning approaches. References Christine Basta, Marta R. Costa-jussà, and Noe Casas. 2019. [Evaluating the underlying gender bias in con-](https://doi.org/10.18653/v1/W19-3805) [textualized word embeddings.](https://doi.org/10.18653/v1/W19-3805) In _Proceedings of the_ _First Workshop on Gender Bias in Natural Language_ _Processing_, pages 33–39, Florence, Italy. Association for Computational Linguistics. Yoshua Bengio, Réjean Ducharme, and Pascal Vincent. 2000. A neural probabilistic language model. _Ad-_ _vances in neural information processing systems_, 13. Daniel Borkan, Jeffrey Sorensen, Lucas Dixon, and Lucy Vasserman. 2019. [Jigsaw unintended bias in](https://kaggle.com/competitions/jigsaw-unintended-bias-in-toxicity-classification) [toxicity classification.](https://kaggle.com/competitions/jigsaw-unintended-bias-in-toxicity-classification) Luke Breitfeller, Emily Ahn, David Jurgens, and Yu lia Tsvetkov. 2019. [Finding microaggressions in the](https://doi.org/10.18653/v1/D19-1176) wild: [A case for locating elusive phenomena in so-](https://doi.org/10.18653/v1/D19-1176) [cial media posts.](https://doi.org/10.18653/v1/D19-1176) In _Proceedings of the 2019 Confer-_ _ence on Empirical Methods in Natural Language Pro-_ _cessing and the 9th International Joint Conference_ _on Natural Language Processing (EMNLP-IJCNLP)_, pages 1664–1674, Hong Kong, China. Association for Computational Linguistics. Cristian Danescu-Niculescu-Mizil, Moritz Sudhof, Dan Jurafsky, Jure Leskovec, and Christopher Potts. 2013. [A computational approach to politeness with appli-](https://aclanthology.org/P13-1025) [cation to social factors.](https://aclanthology.org/P13-1025) In _Proceedings of the 51st_ _Annual Meeting of the Association for Computational_ _Linguistics (Volume 1:_ _Long Papers)_, pages 250–259, Sofia, Bulgaria. Association for Computational Linguistics. Sumanth Dathathri, Andrea Madotto, Janice Lan, Jane Hung, Eric Frank, Piero Molino, Jason Yosinski, and 37 Rosanne Liu. 2019. Plug and play language models: A simple approach to controlled text generation. _arXiv preprint arXiv:1912.02164_ . Samuel Gehman, Suchin Gururangan, Maarten Sap, Yejin Choi, and Noah A. Smith. 2020. [RealToxi-](https://doi.org/10.18653/v1/2020.findings-emnlp.301) cityPrompts: Evaluating [neural](https://doi.org/10.18653/v1/2020.findings-emnlp.301) toxic degeneration [in language models.](https://doi.org/10.18653/v1/2020.findings-emnlp.301) In _Findings of the Association_ _for Computational Linguistics:_ _EMNLP 2020_, pages 3356–3369, Online. Association for Computational Linguistics. Jennifer Golbeck, Zahra Ashktorab, Rashad O. Banjo, Alexandra Berlinger, Siddharth Bhagwan, Cody Buntain, Paul Cheakalos, Alicia A. Geller, Quint Gergory, Rajesh Kumar Gnanasekaran, Raja Rajan Gunasekaran, Kelly M. Hoffman, Jenny Hottle, Vichita Jienjitlert, Shivika Khare, Ryan Lau, Marianna J. Martindale, Shalmali Naik, Heather L. Nixon, Piyush Ramachandran, Kristine M. Rogers, Lisa Rogers, Meghna Sardana Sarin, Gaurav Shahane, Jayanee Thanki, Priyanka Vengataraman, Zijian Wan, and Derek Michael Wu. 2017. [A large labeled corpus for](https://doi.org/10.1145/3091478.3091509) online [harassment](https://doi.org/10.1145/3091478.3091509) research. In _Proceedings_ _of_ _the_ _2017 ACM on Web Science Conference_, WebSci ’17, page 229–233, New York, NY, USA. Association for Computing Machinery. _the First Workshop on Gender Bias in Natural Lan-_ _guage_ _Processing_, pages 166–172, Florence, Italy. Association for Computational Linguistics. Y. Lecun, L. Bottou, Y. Bengio, and P. Haffner. 1998. [Gradient-based learning applied to document recog-](https://doi.org/10.1109/5.726791) [nition.](https://doi.org/10.1109/5.726791) _Proceedings of the IEEE_, 86(11):2278–2324. Brian Lester, Rami Al-Rfou, and Noah Constant. 2021. The power of scale for [parameter-efficient](https://doi.org/10.18653/v1/2021.emnlp-main.243) prompt [tuning.](https://doi.org/10.18653/v1/2021.emnlp-main.243) In _Proceedings of the 2021 Conference on_ _Empirical Methods in Natural Language Processing_, pages 3045–3059, Online and Punta Cana, Dominican Republic. Association for Computational Linguistics. Jiwei Li, Michel Galley, Chris Brockett, Jianfeng Gao, and Bill Dolan. 2016. A [diversity-promoting](https://doi.org/10.18653/v1/N16-1014) ob[jective function for neural conversation models.](https://doi.org/10.18653/v1/N16-1014) In _Proceedings_ _of_ _the_ _2016_ _Conference_ _of_ _the_ _North_ _American Chapter of the Association for Computa-_ _tional Linguistics:_ _Human Language Technologies_, pages 110–119, San Diego, California. Association for Computational Linguistics. Suchin Gururangan, Ana Marasovi´c, Swabha Swayamdipta, Kyle Lo, Iz Beltagy, Doug Downey, and Noah A. Smith. 2020. Don’t stop pretraining: Adapt language [models](https://doi.org/10.18653/v1/2020.acl-main.740) to domains and tasks. In _Proceedings_ _of_ _the_ _58th_ _Annual_ _Meeting_ _of_ _the_ _Association_ _for_ _Computational_ _Linguistics_, pages 8342–8360, Online. Association for Computational Linguistics. Xiang Lisa Li, Ari Holtzman, Daniel Fried, Percy Liang, Jason Eisner, Tatsunori Hashimoto, Luke Zettlemoyer, and Mike Lewis. 2023. [Contrastive](https://doi.org/10.18653/v1/2023.acl-long.687) decoding: [Open-ended text generation as optimization.](https://doi.org/10.18653/v1/2023.acl-long.687) In _Proceedings_ _of_ _the_ _61st_ _Annual_ _Meeting_ _of_ _the_ _As-_ _sociation for Computational Linguistics (Volume 1:_ _Long Papers)_, pages 12286–12312, Toronto, Canada. Association for Computational Linguistics. Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, and Yejin Choi. 2020. [The curious case of neural text de-](https://openreview.net/forum?id=rygGQyrFvH) [generation.](https://openreview.net/forum?id=rygGQyrFvH) In _International Conference on Learning_ _Representations_ . Edward J Hu, yelong shen, Phillip Wallis, Zeyuan Allen Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. 2022. LoRA: Low-rank [adaptation](https://openreview.net/forum?id=nZeVKeeFYf9) of large [language](https://openreview.net/forum?id=nZeVKeeFYf9) models. In _International_ _Conference_ _on_ _Learning Representations_ . Nitish Shirish Keskar, Bryan McCann, Lav R Varshney, Caiming Xiong, and Richard Socher. 2019. Ctrl: A conditional transformer language model for controllable generation. _arXiv preprint arXiv:1909.05858_ . Ben Krause, Akhilesh Deepak Gotmare, Bryan McCann, Nitish Shirish Keskar, Shafiq Joty, Richard Socher, and Nazneen Fatema Rajani. 2021. GeDi: Gener[ative discriminator guided sequence generation.](https://doi.org/10.18653/v1/2021.findings-emnlp.424) In _Findings of the Association for Computational Lin-_ _guistics:_ _EMNLP_ _2021_, pages 4929–4952, Punta Cana, Dominican Republic. Association for Computational Linguistics. Keita Kurita, Nidhi Vyas, Ayush Pareek, Alan W Black, and Yulia Tsvetkov. 2019. Measuring [bias](https://doi.org/10.18653/v1/W19-3823) in con[textualized word representations.](https://doi.org/10.18653/v1/W19-3823) In _Proceedings of_ Xiang Lisa Li and Percy Liang. 2021. [Prefix-tuning:](https://doi.org/10.18653/v1/2021.acl-long.353) Optimizing [continuous prompts](https://doi.org/10.18653/v1/2021.acl-long.353) for generation. In _Proceedings of the 59th Annual Meeting of the Asso-_ _ciation for Computational Linguistics and the 11th_ _International Joint Conference on Natural Language_ _Processing (Volume 1:_ _Long_ _Papers)_, pages 4582– 4597, Online. Association for Computational Linguistics. Alisa Liu, Maarten Sap, Ximing Lu, Swabha Swayamdipta, Chandra Bhagavatula, Noah A. Smith, and Yejin Choi. 2021a. DExperts: [Decoding-time](https://doi.org/10.18653/v1/2021.acl-long.522) controlled text [generation](https://doi.org/10.18653/v1/2021.acl-long.522) with experts and anti[experts.](https://doi.org/10.18653/v1/2021.acl-long.522) In _Proceedings_ _of_ _the_ _59th_ _Annual_ _Meet-_ _ing of the Association for Computational Linguistics_ _and the 11th International Joint Conference on Natu-_ _ral Language Processing (Volume 1:_ _Long Papers)_, pages 6691–6706, Online. Association for Computational Linguistics. Haokun Liu, Derek Tam, Muqeeth Mohammed, Jay Mo hta, Tenghao Huang, Mohit Bansal, and Colin Raffel. 2022a. [Few-shot parameter-efficient fine-tuning is](https://openreview.net/forum?id=rBCvMG-JsPd) [better and cheaper than in-context learning.](https://openreview.net/forum?id=rBCvMG-JsPd) In _Ad-_ _vances in Neural Information Processing Systems_ . Tianyu Liu, Yizhe Zhang, Chris Brockett, Yi Mao, Zhifang Sui, Weizhu Chen, and Bill Dolan. 2022b. [A token-level reference-free hallucination detection](https://doi.org/10.18653/v1/2022.acl-long.464) [benchmark for free-form text generation.](https://doi.org/10.18653/v1/2022.acl-long.464) In _Proceed-_ _ings of the 60th Annual Meeting of the Association_ 38 _for Computational Linguistics (Volume 1:_ _Long Pa-_ _pers)_, pages 6723–6737, Dublin, Ireland. Association for Computational Linguistics. X Liu, Y Zheng, Z Du, M Ding, Y Qian, Z Yang, and J Tang. 2021b. Gpt understands, too. arxiv. _arXiv_ _preprint arXiv:2103.10385_ . Renze Lou, Kai Zhang, and Wenpeng Yin. 2023. Is prompt all you need? no. a comprehensive and broader view of instruction learning. _arXiv preprint_ _arXiv:2303.10475_ . Ximing Lu, Faeze Brahman, Peter West, Jaehun Jang, Khyathi Chandu, Abhilasha Ravichander, Lianhui Qin, Prithviraj Ammanabrolu, Liwei Jiang, Sahana Ramnath, et al. 2023. Inference-time policy adapters (ipa): Tailoring extreme-scale lms without finetuning. _arXiv preprint arXiv:2305.15065_ . Sourab Mangrulkar, Sylvain Gugger, Lysandre Debut, Younes Belkada, and Sayak Paul. 2022. Peft: State of-the-art parameter-efficient fine-tuning methods. [https://github.com/huggingface/peft.](https://github.com/huggingface/peft) Chandler May, Alex Wang, Shikha Bordia, Samuel R. Bowman, and Rachel Rudinger. 2019. [On measuring](https://doi.org/10.18653/v1/N19-1063) [social biases in sentence encoders.](https://doi.org/10.18653/v1/N19-1063) In _Proceedings_ _of the 2019 Conference of the North American Chap-_ _ter of the Association for Computational Linguistics:_ _Human Language Technologies, Volume 1 (Long and_ _Short_ _Papers)_, pages 622–628, Minneapolis, Minnesota. Association for Computational Linguistics. Swaroop Mishra, Daniel Khashabi, Chitta Baral, and Hannaneh Hajishirzi. 2022. [Cross-task generaliza-](https://doi.org/10.18653/v1/2022.acl-long.244) [tion via natural language crowdsourcing instructions.](https://doi.org/10.18653/v1/2022.acl-long.244) In _Proceedings_ _of_ _the_ _60th_ _Annual_ _Meeting_ _of_ _the_ _Association for Computational Linguistics (Volume_ _1:_ _Long Papers)_, pages 3470–3487, Dublin, Ireland. Association for Computational Linguistics. Erik Nijkamp, Tian Xie, Hiroaki Hayashi, Bo Pang, Congying Xia, Chen Xing, Jesse Vig, Semih Yavuz, Philippe Laban, Ben Krause, et al. 2023. Xgen-7b technical report. _arXiv preprint arXiv:2309.03450_ . Tong Niu and Mohit Bansal. 2018. Polite [dialogue](https://doi.org/10.1162/tacl_a_00027) [generation without parallel data.](https://doi.org/10.1162/tacl_a_00027) _Transactions of the_ _Association_ _for_ _Computational_ _Linguistics_, 6:373– _Proceedings_ _of_ _the_ _2019_ _Conference_ _on_ _Empirical_ _Methods_ _in_ _Natural_ _Language_ _Processing_ _and_ _the_ _9th International Joint Conference on Natural Lan-_ _guage Processing (EMNLP-IJCNLP)_, pages 3407– 3412, Hong Kong, China. Association for Computational Linguistics. Akhilesh Sudhakar, Bhargav Upadhyay, and Arjun Ma heswaran. 2019. [“transforming” delete, retrieve, gen-](https://doi.org/10.18653/v1/D19-1322) [erate approach for controlled text style transfer.](https://doi.org/10.18653/v1/D19-1322) In _Proceedings_ _of_ _the_ _2019_ _Conference_ _on_ _Empirical_ _Methods_ _in_ _Natural_ _Language_ _Processing_ _and_ _the_ _9th International Joint Conference on Natural Lan-_ _guage Processing (EMNLP-IJCNLP)_, pages 3269– 3279, Hong Kong, China. Association for Computational Linguistics. Hugo Touvron, Louis Martin, Kevin Stone, Peter Al bert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, et al. 2023. Llama 2: Open foundation and fine-tuned chat models. _arXiv_ _preprint_ _arXiv:2307.09288_ . Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, and Illia Polosukhin. 2017. Attention is all you need. In _Proceedings of the 31st International_ _Conference on Neural Information Processing Sys-_ _tems_, NIPS’17, page 6000–6010, Red Hook, NY, USA. Curran Associates Inc. Eric Wallace, Shi Feng, Nikhil Kandpal, Matt Gard ner, and Sameer Singh. 2019. [Universal adversarial](https://doi.org/10.18653/v1/D19-1221) [triggers for attacking and analyzing NLP.](https://doi.org/10.18653/v1/D19-1221) In _Proceed-_ _ings of the 2019 Conference on Empirical Methods_ _in Natural Language Processing and the 9th Inter-_ _national Joint Conference on Natural Language Pro-_ _cessing (EMNLP-IJCNLP)_, pages 2153–2162, Hong Kong, China. Association for Computational Linguistics. Boxin Wang, Wei Ping, Chaowei Xiao, Peng Xu, Mostofa Patwary, Mohammad Shoeybi, Bo Li, Anima Anandkumar, and Bryan Catanzaro. 2022. Exploring the limits of domain-adaptive training for detoxifying large-scale language models. _Advances_ _in Neural Information Processing Systems_, 35:35811– 35824. Albert Webson and Ellie Pavlick. 2022. Do [prompt-](https://doi.org/10.18653/v1/2022.naacl-main.167) [based models really understand the meaning of their](https://doi.org/10.18653/v1/2022.naacl-main.167) [prompts?](https://doi.org/10.18653/v1/2022.naacl-main.167) In _Proceedings of the 2022 Conference of_ _the North American Chapter of the Association for_ _Computational Linguistics:_ _Human Language Tech-_ _nologies_, pages 2300–2344, Seattle, United States. Association for Computational Linguistics. Sean Welleck, Ilia Kulikov, Stephen Roller, Emily Di nan, Kyunghyun Cho, and Jason Weston. 2020. [Neu-](https://openreview.net/forum?id=SJeYe0NtvH) ral text generation [with](https://openreview.net/forum?id=SJeYe0NtvH) unlikelihood training. In _International_ _Conference_ _on_ _Learning_ _Representa-_ _tions_ . 389. Sean O’Brien and Mike Lewis. 2023. Contrastive de coding improves reasoning in large language models. _arXiv preprint arXiv:2309.09117_ . OpenAI. 2023. [Gpt-4 technical report.](http://arxiv.org/abs/2303.08774) Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. 2019. Language models are unsupervised multitask learners. _OpenAI_ _blog_, 1(8):9. Emily Sheng, Kai-Wei Chang, Premkumar Natarajan, and Nanyun Peng. 2019. The [woman](https://doi.org/10.18653/v1/D19-1339) worked as a babysitter: [On biases in language generation.](https://doi.org/10.18653/v1/D19-1339) In 39 Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Remi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, Mariama Drame, Quentin Lhoest, and Alexander Rush. 2020. [Trans-](https://doi.org/10.18653/v1/2020.emnlp-demos.6) formers: [State-of-the-art natural language processing.](https://doi.org/10.18653/v1/2020.emnlp-demos.6) In _Proceedings of the 2020 Conference on Empirical_ _Methods_ _in_ _Natural_ _Language_ _Processing:_ _System_ _Demonstrations_, pages 38–45, Online. Association for Computational Linguistics. Qingru Zhang, Minshuo Chen, Alexander Bukharin, Pengcheng He, Yu Cheng, Weizhu Chen, and Tuo Zhao. 2023. Adaptive [budget](https://openreview.net/forum?id=lq62uWRJjiY) allocation for [parameter-efficient fine-tuning.](https://openreview.net/forum?id=lq62uWRJjiY) In _The Eleventh In-_ _ternational Conference on Learning Representations_ . Jieyu Zhao, Tianlu Wang, Mark Yatskar, Ryan Cotterell, Vicente Ordonez, and Kai-Wei Chang. 2019. [Gender](https://doi.org/10.18653/v1/N19-1064) [bias in contextualized word embeddings.](https://doi.org/10.18653/v1/N19-1064) In _Proceed-_ _ings of the 2019 Conference of the North American_ _Chapter_ _of_ _the_ _Association_ _for_ _Computational_ _Lin-_ _guistics:_ _Human_ _Language_ _Technologies,_ _Volume_ _1_ _(Long_ _and_ _Short_ _Papers)_, pages 629–634, Minneapolis, Minnesota. Association for Computational Linguistics. Mingyu Zong and Bhaskar Krishnamachari. 2022. A survey on gpt-3. _arXiv preprint arXiv:2212.00857_ . 40

섹션 본문 49문단 · 24,870자

(제목 없음)

1The field of natural language generation has witnessed significant advancements in recent years, including the development of controllable text generation techniques.However, controlling the attributes of the generated text remains a challenge, especially when aiming to avoid undesirable behavior such as toxicity.In this work, we introduce Detoxification Generator (DETOXIGEN), an inference-time algorithm that steers the generation away from unwanted styles.DETOXIGEN is an ensemble of a pre-trained language model (generator) and a detoxifier.The detoxifier is trained intentionally on the toxic data representative of the undesirable attribute, encouraging it to generate text in that style exclusively.During the actual generation, we use the trained detoxifier to produce undesirable tokens for the generator to contrast against at each decoding step.This approach directly informs the generator to avoid generating tokens that the detoxifier considers highly likely.We evaluate DETOXIGEN on the commonly used REALTOXICITYPROMPTS benchmark(Gehman et al., 2020)with various language models as generators.We find that it significantly outperforms previous approaches in detoxification metrics while not compromising on the generation quality.Moreover, the detoxifier is obtained by soft prompt-tuning using the same backbone language model as the generator.Hence, DETOXIGEN requires only a tiny amount of extra weights from the virtual tokens of the detoxifier to be loaded into GPU memory while decoding, making it a promising lightweight, practical, and parameter-efficient detoxification strategy.

Introduction

2Large language models (LLMs) have demonstrated remarkable promise in various generative tasks by first self-supervised pretraining on large text corpora and then finetuning with instruction data for alignment (Mishra et al., 2022).Yet a wealth of previous work has demonstrated that pre-trained models inherit toxicity and biases from their training corpora (Zhao et al., 2019;May et al., 2019;Kurita et al., 2019;Basta et al., 2019).As a result, generative models (OpenAI, 2023;Touvron et al., 2023;Nijkamp et al., 2023) tend to degenerate into unsafe text even when conditioning on seemingly innocuous prompts (Wallace et al., 2019;Sheng et al., 2019;Gehman et al., 2020), which is difficult to resolve by prompt engineering alone (Zong and Krishnamachari, 2022;Liu et al., 2022b;Webson and Pavlick, 2022;Lou et al., 2023).

3To address this challenge, a plethora of approaches have been proposed, which usually require full-model finetuning of the underlying language model to build the detoxifier (Dathathri et al., 2019;Gururangan et al., 2020;Krause et al., 2021;Liu et al., 2021a).However, nowadays the largest LLMs typically contain more than 100 billion parameters, making such resource-intensive tuning less viable.This trend calls for more parameterefficient approaches.

4In this work, we propose DETOXIGEN (Figure 1), a parameter-efficient framework that leverages the frozen weights of the language model itself and only introduces a tiny portion of new model parameters to detoxify generation.During training, we use prompt tuning (Lester et al., 2021) to train a detoxifier exclusively on toxic data with the nexttoken prediction objective.The resulting detoxifier shares all the backbone model weights with the LLM (i.e., the generator).During inference, we build on top of the contrastive decoding (Li et al., 2023) paradigm and employ the detoxifier to manipulate the output probability distribution of the LLM for each generation step.Intuitively, the generator avoids outputting tokens that the detoxifier considers highly probable.For example, in figure 1 the detoxifier considers the gender-biased word "his" very likely as the next token, helping the generator arXiv:2401.06947v1[cs.CL] 13 Jan 2024 to score down the probability of that token.

5We evaluate our framework on the REALTOXI-CITYPROMPTS dataset (Gehman et al., 2020) and find that it outperforms previous approaches on the standard benchmark metrics by a significant margin, indicating that the text generated by our model is both safer and of higher quality.We also conduct ablation studies and pair models of different sizes from the same model family (e.g., the Llama-2 (Touvron et al., 2023) family).These studies show that pairing a generator with a detoxifier that shares the same backbone LLM is indeed the best-performing configuration.

6Our main contributions are: (1) Performance: Propose a detoxification framework that outperforms previous models by a large margin on commonly used detoxification benchmarks/metrics; (2) Efficiency: We apply parameter-efficient learning to controllable text generation for detoxification.Our model introduces the least amount of additional parameters (hence also requires less data to train) as compared to state-of-the-art models; (3) Transferability: Our detoxifier model only requires toxic data and does not require any contrastive (non-toxic) data, making our approach transferable thanks to the easier and more manageable data curation.

Task Formulation

7We consider controlled decoding-time approaches for open-ended text generation.A generator, in our case a language model, receives an unfinished input text as a prompt and aims to output a fluent and coherent continuation that avoids toxicity with the help of a detoxifier, which is another language model trained with data of the target attribute.

Model Components

8Generator Let x <t = x 1 , x 2 , ..., x t−1 be a prompt consisting of (t − 1) tokens, where each t i (1 ≤ i ≤ t − 1) is a token in the vocabulary set V of the language model (LM).The LM encodes x <t in an autoregressive fashion and outputs z t ∈ R |V | , where z t denotes the logits for the tth token x t and |V | corresponds to the vocabulary size.The LM then obtains a probability distribution P GEN over V by computing the softmax of z t

9and the next token is sampled from this distribution.

10Detoxifier The detoxifier takes as input the same prompt fed to the generator for each generation step and computes a probability distribution P DE (X t |x <t ) over |V | in the same way.However, the detoxifier is not a vanilla LM like the generator, but rather an LM specially trained to output toxic content.Intuitively, the generator is discouraged from outputting tokens that the detoxifier considers highly likely, thus avoiding toxic generations.In other words, the decoding process involves an ensemble of the two LMs to obtain the final output probability distribution P (x t |x <t ):

11where the hyperparameter α denotes the control strength of the model and ∆P represents the probability correction term determined by the difference between the two distributions.Intuitively, α dictates how much we want to modify the generator's probability distribution through the correction term ∆P .Since it is possible that P (x t |x <t ) contains values that fall out of the [0.0, 1.0] range, making them invalid probabilities, we also clip them on both sides -i.e., setting any value that is below 0.0 to 0.0 and any value above 1.0 to 1.0.The resulting probability vector is then normalized by first computing its log probabilities and then taking the softmax.Our formulation is closely related to that in Contrastive Decoding (Li et al., 2023) and DExperts (Liu et al., 2021a), but we differ by manipulating in the probability space rather than the logits space because we found in our initial experiments that directly dealing with probability distributions result in better performance on the downstream task.

12Sampling To constrain the model to only generate plausible tokens, we first employ Nucleus (Top-p) Sampling (Holtzman et al., 2020) to limit the vocabulary V to a subset V (p) by only selecting the highest probability tokens whose cumulative probability mass exceeds some threshold p ∈ [0.0, 1.0].More specifically, given the distribution P GEN (x t |x <t ) in Equation 1, the top-p vocabulary V (p) ⊆ V is defined by the smallest vocabulary set such that Figure 1: Illustration of the DETOXIGEN pipeline that avoids generating a gender-biased next token.A prompt is fed into both the generator and the detoxifier, which share the same underlying frozen weights from the backbone language model.Additionally, the detoxifier contains virtual tokens whose embeddings are trainable.Such virtual tokens steer the detoxifier toward generating only toxic continuations.Each model provides its own probability distribution for the next token, where DETOXIGEN combines the two distributions and performs the detoxification.

13x∈V (p) P GEN (x|x <t ) ≥ p.

14(4)

15The Top-p sampling then truncates the less reliable tail of the distribution by setting

16The detoxifier then comes in and only manipulates logits in the set V (p) so that regardless of how P GEN is modified, the generated tokens are guaranteed to be plausible as evaluated by the generator.When applying this restriction, equation 1 becomes

Parameter-Efficient Training of Detoxifier

17As discussed in Section 1, due to the increasing size of large language models, we aim to introduce as few additional model parameters as possible to our framework.Hence we adopt Prompt Tuning (Lester et al., 2021), a parameter-efficient training method, to train a language model exclusively on toxic data.This method learns soft prompts (or virtual tokens), whose embeddings are trainable parameters to condition frozen language models to perform the target downstream tasks.

183 Experimental Setup

Backbone Models

19Following Liu et al. (2021a), we use GPT2large (Radford et al., 2019) as the generator and the backbone of the detoxifier.We use GPT2-XL to evaluate the generation quality.For ablation studies reported in Section 4.3, we also consider GPT2 with small and medium sizes.

20It is worth noting that previous work selected the GPT2 family mostly because it was one of the strongest models at the time.To observe if the same trend of performance holds for the most recent LLMs, we also experiment with another family of Transformer-based (Vaswani et al., 2017) language models, namely Llama-2 (Touvron et al., 2023) because it satisfies the following three criteria: (1) It is publicly released so that it is easier for researchers to reproduce and compare with our work; (2) It achieves state-of-the-art performance on diverse benchmark datasets (Nijkamp et al., 2023); (3) It has three sizes so that we can evaluate whether larger models can be paired with smaller ones for detoxification -such is the setting when we prioritize reducing latency over minimizing GPU memory footprint.Hence we experiment with Llama-2 with 7B, 13B, and 70B parameters, respectively.Due to the large size of Llama-2-70B, for all our experiments we use bfloat16 for both training and inference to increase throughput and reduce GPU memory usage.We evaluate perplexity from the Llama-2 family with Llama-2-7B unless otherwise stated.

Training of Detoxifier

21We prompt tune the detoxifier with the standard language modeling objective (Bengio et al., 2000) which learns the parameters of the conditional probability distribution of the next word given the preceding context.We extract the training data from the human-annotated Jigsaw Unintended Bias in Toxicity Classification (Borkan et al., 2019).An example is considered toxic if more than 50% of the annotators classify it as toxic.This threshold splits the corpus into around 160K toxic and 1.4M nontoxic examples.We only train our models with the toxic part of the data.

22For prompt tuning, we use 100 virtual tokens for each model with a learning rate of 0.1.To efficiently explore different parameter-efficient methods, we use the PEFT (Parameter-Efficient Fine-Tuning), a library that wraps around Hugging-Face Transformers (Wolf et al., 2020) model objects and provides out-of-the-box implementations for widely adopted PEFT approaches (Mangrulkar et al., 2022).Because we need to obtain logits from the detoxifier for each generation step, we overwrite the PEFT model object to only prepend virtual tokens to the input for the first generation step.

Hyperparameter Tuning

23We tune the hyperparameter α with a held-out validation set and perform a grid search from 1.0 to 9.0 with a 1.0 increment.As will be shown in Section 4.1, we find that α = 5.0 strikes the best balance between toxicity and generation quality.We thus adopt this value throughout all experiments.

Evaluation Data

24We follow Liu et al. (2021a) to use the REALTOXIC-ITYPROMPTS dataset (Gehman et al., 2020) which contains 100K naturally occurring, sentence-level prompts derived from a large corpus of English web text.These prompts are annotated with toxicity scores and language models are known to degenerate into toxic continuation when conditioning on them.To determine the detoxifier strength α, we randomly sample 1k prompts as the validation set and another disjoint 10k as the test set.

Metrics

25Toxicity Following Gehman et al. ( 2020), we use the Perspective API1 to measure the toxicity of generations.This score is obtained from a CNN model (Lecun et al., 1998) Quality The Quality metric consists of both fluency and diversity.Heeding both aspects makes it easier to spot cases where the generation is likely but generic, or diverse but unlikely.We use corpuslevel Perplexity to evaluate fluency and Distinct-2 and -3 (Li et al., 2016) to evaluate diversity.Distinct-2 and distinct-3 correspond respectively to the number of distinct bigrams and trigrams divided by the total number of generated words.

Baseline Models

26We compare DETOXIGEN with a diverse set of previously reported baseline models (Gehman et al., 2020;Liu et al., 2021a), including Domain-Adaptive Pretraining (DAPT) (Gururangan et al., 2020), Plug-and-Play Language Models (PPLM) (Dathathri et al., 2019), Non-Toxic Expert (Liu et al., 2021a), Generative Discriminators (GeDi) (Krause et al., 2021), and Decoding-time Experts (DExperts) (Liu et al., 2021a).We follow these baselines to use Nucleus Sampling with p = 0.9 for generation.

Hyperparameter Tuning through Validation Set

27As mentioned in Section 3.3, we perform a grid search of α with values 1.0, 2.0, ..., 9.0.We show the results on both GPT2-large and Llama-2-7b so that we can observe the trend on both early and more recent models.From Table 2, we can see that for both models, there is a steady increase in Perplexity (last column) as α grows, indicating a monotonic decrease in generation quality.Intuitively, this trend makes sense because the more we perturb the original output distribution, the more likely it is for the language model to generate less plausible tokens.To maintain a balance between toxicity and quality, we seek the tipping point where further increasing α only brings a diminishing return on reducing toxicity.We observe that for both models, this tipping point happens at α = 5.0.Hence we adopt this hyperparameter setting throughout all other experiments.

Results on GPT2-large

28We then compare with previous approaches on GPT2-large.From Table 1, we can see that our model DETOXIGEN outperforms previous frameworks by a large margin although only tuned on the toxic split of the training data.Among all models, DETOXIGEN (GPT2-large) achieves the lowest Average Maximum Toxicity and Toxicity Probability, while obtaining a Perplexity that is quite close to that of the vanilla GPT-2 large, indicating minimum compromise on generation quality.The Llama-2-7B version of DETOXIGEN achieves even better results.However, it is based on a much stronger backbone language model, hence not comparable to previous work.We still include Llama-2 results in this table to show the gap between earlier and more recent large language models.We also follow Liu et al. (2021a) and report Distinct-N metrics, which are intended to prevent the model from degenerating into dull and generic continuations.

29We observe that the Distinct-N results do not vary much across diverse kinds of models.Hence for the results reported afterwards, we skip this metric and only report Perplexity.

Ablation Studies on Model Sizes

30We also explore pairing models of different sizes as the generator and the detoxifier, respectively.This setting targets the cases where either latency is the major concern such that we want one small detoxifier to steer the generation of all other model sizes, or when we intend to train a detoxifier once and plug-and-play it with all other model sizes.

31The results of such pairings are presented in the matrix-like tables (Table 3,5,4,and 6).We report toxicity and quality in separate tables to make the comparisons clearer.From the four tables, we can observe quite a few interesting patterns.

Consistent Toxicity Reduction

32In the tables, we can observe that when comparing with the nodetoxifier setting (the column with None as header), our approach consistently and significantly reduces the toxicity of the backbone model while not sacrificing much on generation quality.This trend is observed for both the GPT-2 and the Llama-2 model families.

33Entries along the Diagonal As shown in Table 3 and 4, entries on the diagonal of the result matrix (i.e., without the first column that has None as the header) consistently outperform their neighbors in terms of toxicity.These are the settings where the generator and the detoxifier share exactly the same backbone language model.They also achieve the best row-wise Perplexity as compared to off-diagonal models (Table 5 and 6).We hypothesize that this is because the output probability distributions of the generator and the detoxifier with the same underlying backbone parameters are more compatible with each other than backbones of different sizes.Recall in Section 1 that one of our major goals is to introduce as few new model parameters as possible.Our cross-model results clearly show that sharing weights between the generator and the detoxifier turns out to be the best setting among all we have investigated.

34Entries symmetric to the diagonal Comparing entries that are symmetric to the diagonal (e.g., comparing GPT2-XL detoxified by GPT2-small with GPT2-small detoxified by GPT2-XL) in Table 3 and 4, we can observe a consistent pattern that given two models of different sizes, it is usually better to have the smaller model as the generator and the larger model as the detoxifier for detoxification.This indicates that larger models are more capable of capturing the distribution in the toxicity training corpus.

35Effect of Model Size Difference From the toxicity tables, we can also observe that the larger the model size difference, the less effective the detoxification.For example, GPT2-XL detoxified by GPT2-small in Table 3 results in the worst toxicity among all settings, while we observe the same pattern where Llama-2-70B detoxified by Llama-2-7B has the highest toxicity among all settings.

Discussion

36It would be ideal if a detoxifier could work out of the box (plug-and-play) and be readily applied to any LLM generator, even with a different tokenizer.

37To achieve this, one can take a common subset of the vocabulary sets between the generator and the detoxifier, and only manipulate logits on this subset.We leave this as future work since the model families we investigate both already have diverse sizes.

38Throughout the paper, we have been focusing on avoiding undesired attributes.However, we note that our framework can also be used to generate text with any desired style.All we need to do is flip the sign of the probability distribution correction term ∆P in Equation 2 and 3 as follows:

39In addition, our approach could be applied to more general positive and negative attributes, including but not limited to politeness (Danescu-Niculescu-Mizil et al., 2013;Niu and Bansal, 2018), hate speech (Golbeck et al., 2017), and microagressions (Breitfeller et al., 2019).In the case that we want to simultaneously control for multiple attributes, our framework is also compatible with mixed-batch inference (Liu et al., 2022a), where soft prompts of different attributes can be conditioned on in a single batch without increasing latency.

406 Related Work

Parameter-efficient Learning

41Parameter-efficient learning is a natural language processing paradigm to adapt a large language model to particular tasks or domains.It is usually used when fine-tuning the entire language model is prohibitively expensive.Among such approaches, LoRa (Hu et al., 2022) and AdaLoRa (Zhang et al., 2023) inject trainable rank decomposition matrices into each layer of the Transformer architecture, with the latter adaptively allocating the parameter budget among weight matrices according to their importance scores.Prefix Tuning (Li and Liang, 2021), P-Tuning (Liu et al., 2021b), and Prompt Tuning (Lester et al., 2021) prepend to the input sequence virtual tokens with trainable embeddings.Lastly, (IA) 3 scales activations by learned vectors.We choose Prompt Tuning in this work because it achieves competitive performance while involving no change in model architecture and not requiring any bootstrapping for the newly introduced model parameters.

Controllable Text Generation

42There have been multiple effective frameworks proposed for controllable text generation (Keskar et al., 2019;Sudhakar et al., 2019;Kurita et al., 2019;Welleck et al., 2020).2Among them, Domain-Adaptive Pretraining (DAPT) (Gururangan et al., 2020) and Self-Generation Enabled domain-Adaptive Training (SGEAT) (Wang et al., 2022) continues to finetune or apply parameterefficient tuning to the backbone language model with a non-toxic subset of OpenWebText to adapt it to the non-toxic style.Plug-and-Play Language Models (PPLM) (Dathathri et al., 2019) trains a toxicity classifier and leverages gradients from that classifier to update the language model's hidden representations for each generation step.Generative Discriminators (GeDi) (Krause et al., 2021) prepends to the input a soft token serving as the label for the intended class of attribute.It can be viewed as prompt tuning with only one virtual token for each class (toxic and nontoxic).Decodingtime Experts (DExperts) (Liu et al., 2021a) train an expert and an anti-expert LM of opposing attributes with full finetuning.During inference, the logits difference between the two experts serves as the correction term for the logits of the base language model.Our work is different from the previous approaches in that we adopt parameter-efficient tuning that only introduces a few trainable parameters and our training only requires toxic examples rather than examples from both classes.

Contrastive Decoding

43Contrastive Decoding (Li et al., 2023;O'Brien and Lewis, 2023) is a search-based decoding method that optimizes a contrastive objective that returns the difference between the likelihood under a large and a small LM.Our algorithm is different from theirs in that we pair LMs of the same size (with the detoxifier further tuned) and perform all manipulations in the probability space rather than directly in the logits space.

Conclusion

44We propose DETOXIGEN, a high-performing, parameter-efficient framework for detoxification during inference time.Our method only introduces a small portion of new parameters to train a detoxifier model that manipulates the output probability distribution of a generative model.On a standard detoxification benchmark, our approach outperforms all existing models in terms of both toxicity and quality.As language models grow ever larger in size, our controllable generation method shows the promise of quickly adapting to any language model without requiring additional computational resources or significant data curation efforts.

45trained on a non-public corpus of Wikipedia comments.We compute two metrics based on the toxicity scores following Liu et al. (2021a): (1) Average Maximum Toxicity: The average maximum toxicity over k = 25 generations; (2) Toxicity Probability: The empirical probability of a generation with toxicity ≥ 0.5 for at least once over k = 25 generations.

Table 1 :

46Results on a random nontoxic 10K sample from the REALTOXICITYPROMPTS dataset.On the first row, the downward arrows indicate "the lower the better", while the upward ones indicate the opposite.Avg.Max.Toxicity stands for "Average Maximum Toxicity", PPL stands for "Perplexity", and all models are evaluated with GPT2-XL.Dist-N stands for the Distinct-N metric.All models in this table use GPT2-large as the backbone model, except for the last row where Llama-2-7B is used.State-of-the-art results are boldfaced.

Table 2 :

47Validation results obtained by varying the detoxifier strength α from 1.0 to 9.0 with GPT2-large and Llama-2-7b.Each setting is evaluated on a held-out validation set of size 1k from REALTOXICITYPROMPTS.The boldfaced rows indicate tipping points where further increasing α starts to bring diminishing (sometimes even negative) returns on the balance between toxicity and fluency.

Table 5 :

48Quality results by pairing models of different sizes from the GPT-2 model family.All results are obtained on the validation set of size 1K.The column with the header None indicates that no detoxifier is used.

Table 6 :

49Quality results by pairing models of different sizes from the Llama-2 model family.All results are obtained on the validation set of size 1K.The column with the header None indicates that no detoxifier is used.

참고문헌

참고문헌 정보가 없습니다.