TL;DR
Current language model (LM) detoxification methods focus on stopping models from saying "bad words," but they often fail to prevent models from agreeing with offensive users. This paper introduces a hierarchical prefix-tuning framework that dynamically adjusts a model's stance based on the dialogue context, effectively reducing implicit toxicity while maintaining high linguistic quality.
What Problem Does This Paper Address?
Most research on LM detoxification focuses on self-toxicity: ensuring the model doesn't generate offensive language itself. However, in a dialogue setting, a model can be harmful even if it uses clean language—simply by agreeing with or validating a user's offensive statement. This is known as implicit offensive language.
As shown in Figure 1, a model might correctly avoid toxic words but still fail by providing a supportive stance to a hateful prompt.
The challenge is that the "correct" stance is context-dependent. In a normal conversation, we want the model to be natural and supportive; in an offensive context, we want it to shift its stance. Previous "Classify-then-Generate" approaches—where a separate classifier detects offense and triggers a safe response—often suffer from error propagation: if the classifier misses the offense, the model generates a toxic response.
Methods
The authors propose a novel control method using hierarchical prefixes. Instead of updating the massive parameters of a model like DialoGPT, they use "prefixes"—small, continuous vectors prepended to the LM's hidden states to steer its output.
Their framework consists of two main components:
- Toxicity Control Prefixes ($H_\beta$): These handle context-independent self-toxicity, ensuring the model's own words are clean.
- Meta Prefixes ($H_\alpha$): This is the core innovation. Instead of a fixed stance prefix, the meta prefix guides the LM to generate a specific stance control prefix based on the user's input.
To train these meta prefixes without an explicit classifier, the authors introduced two novel contrastive loss terms:
- Stance Contrastive Loss ($\mathcal{L}_s$): Pushes the model to generate vastly different stance prefixes (supportive vs. non-supportive) when the input is offensive.
- Context Contrastive Loss ($\mathcal{L}_c$): Teaches the model to differentiate between offensive and non-offensive user utterances implicitly.
The training flow (illustrated in Figure 2) allows the model to learn the contextualized stance control strategy end-to-end.
Datasets
The researchers used the ToxiChat dataset (Baheti et al., 2021). ToxiChat is a crowd-annotated English dataset containing 2,000 Reddit threads. Each example includes:
- A list of user utterances.
- Machine-generated responses (from DialoGPT and GPT-3).
- Annotations for both offensiveness and stance (agree, disagree, or neutral).
For evaluation, they used the GATE Cloud English stance classifier to measure the model's stance and the Google Perspective API to measure self-toxicity.
Key Insights and Ideas
- Stance as a Dynamic Attribute: Unlike toxicity (which we almost always want to be low), the desired stance of a model is a moving target that depends entirely on the dialogue history.
- Implicit Detection is Better than Explicit: By using contrastive losses during generation training, the model learns to "detect" offensive context more robustly than a standalone binary classifier, which often acts as a performance bottleneck.
- Modular Control: The hierarchical structure allows the model to combine a context-independent safety check (toxicity) with a context-dependent behavioral shift (stance) in a single unified framework.
Key Results
The proposed method ("Ours") significantly outperformed standard prefix-tuning and classification-based pipelines.
As seen in Table 1 (Figure 5), the model achieved the best balance across all metrics:
- Low Stance Shift ($t_c=0$): When the user was not offensive, the model's stance remained close to the original DialoGPT (0.089 shift vs. 0.25+ for baselines), meaning it didn't become unnecessarily argumentative in normal conversation.
- Reduced Support Stance ($t_c=1$): When the user was offensive, the model's likelihood of agreeing dropped to 0.225 (and as low as 0.200 in ablation studies), significantly lower than the uncontrolled DialoGPT (0.253) and other tuning methods (0.32+).
- Maintained Quality: The model kept self-toxicity low (0.157) while maintaining a perplexity (PPL) score that indicates the generated text remained fluent and natural.
Qualitative examples in Table 3 (Figure 6) highlight how the model handles difficult prompts. For instance, when a user says "i'll kill them again," the model shifts from DialoGPT's "lmaoooo good one" to a more responsible "Seriously. If you're good with your friends, I'll teach you how to deal with a situation like this."
Limitations and Future Work
The authors acknowledge several limitations:
- Scope of Offense: The work focuses on one specific category of contextual offense—supporting a toxic statement. It does not yet address more complex linguistic phenomena like sarcasm or circumlocution (talking around a toxic subject).
- Safety Guarantees: While the method significantly lowers the probability of a supportive stance in toxic contexts, it is not a hard guarantee; the model may still occasionally produce unsafe stances.
- Hallucination: The framework is designed for detoxification and stance, not for controlling factuality or hallucination.
Future work could expand this hierarchical prefix approach to cover more diverse types of contextual harm and integrate it with fact-checking mechanisms.
Summary updated