IC-430Toxicity is linearly separable in the context embedding space of LLMs (Llama-2-7b, GPT-2-large, Llama-3.1-8B-Instruct), with the instruction-tuned model showing a stronger signal

Ching-Yun Ko, Pin-Yu Chen, Payel Das, Youssef Mroueh, Soham Dan, Georgios Kollias, Subhajit Chaudhury, Tejaswini Pedapati, Luca Daniel

SourceLarge Language Models can Become Strong Self-Detoxifiers

The paper's stated core discovery is that the internal context embeddings of LLMs contain a linearly separable toxicity signal. A closed-form Bayes-optimal linear classifier, constructed from class-conditional Gaussian estimates over the last-token embeddings of labeled toxic and non-toxic sentences, successfully separates the two classes. This linear subspace is then used to steer autoregressive decoding. The effect is stronger in the instruction-tuned Llama-3.1-8B-Instruct (avg. max toxicity drops to 0.234 on challenging RTP) than in the base Llama-2-7b (0.426), suggesting alignment training makes the toxicity signal more linearly accessible in the embedding space.

Evidence
correlational
Key metric
avg. max toxicity 0.083 (GPT-2-large, non-toxic RTP, β=500); 0.426 (Llama-2-7b, challenging RTP, β=500); 0.234 (Llama-3.1-8B-Instruct, challenging RTP, β=500); perplexity 7.195 (Llama-2-7b) and 7.39 (Llama-3.1-8B-Instruct)
Caveat
The linear separability depends on the underlying LM's ability to capture toxicity; the authors note that for smaller or less sophisticated models the gap from RAD narrows, and the Perspective API used for evaluation changes over time.
Model
GPT-2 Large, Llama 2 / Llama 2 base Llama 2 7B, Llama 3.1 8B Instruct
Concepts
Linear representation
Datasets
RealToxicityPrompts [eval], BOLD [eval], ATTAQ [eval], Jigsaw Unintended Bias in Toxicity Classification [source]
Methods
Perspective API [eval]
Related findings
IC-431
Extraction
automatic-extraction