Distributional Surgery for Language Model Activations
Bao Nguyen, Binh Nguyen, Duy Nguyen, Viet Anh Nguyen
TL;DR
This work introduces RADIANT, a two-stage inference-time framework to reduce undesirable outputs from language models by intervening on activations rather than updating weights. It combines layerwise risk-aware probes (per-head linear logistic classifiers with a smooth risk surrogate over FPR and FNR) to detect problematic content and select an optimal layer, with headwise distributional interventions (linear maps) that transform undesirable activations into desirable ones using semidefinite programming to guarantee probabilistic effectiveness while minimizing perturbations. The method achieves strong improvements on TruthfulQA across a range of models and datasets, while maintaining small distribution shifts as evidenced by KL and CE metrics, and it generalizes to various architectures, including sparse Mixtures of Experts. Its inference-time, parameter-free edits offer a lightweight, scalable alternative to fine-tuning or weight editing, with broad applicability to truthfulness, toxicity mitigation, and other controllable-generation tasks. The combination of risk-aware probing and SDP-guided interventions provides principled guarantees and practical performance gains, making RADIANT a versatile tool for safer and more reliable text generation.
Abstract
Language models, while capable of generating remarkably coherent and seemingly accurate text, can occasionally produce undesirable content, including harmful or toxic outputs. In this paper, we present a new two-stage approach to detect and mitigate undesirable content generations by rectifying activations. First, we train an ensemble of layerwise classifiers to detect undesirable content using activations by minimizing a smooth surrogate of the risk-aware score. Then, for detected undesirable contents, we propose layerwise distributional steering policies that transform the attention heads. These policies are computed through principled semidefinite programming, which aims to minimally perturb the attention distribution while probabilistically guaranteeing the effectiveness of the editions. Empirical evaluations across multiple language models and datasets show that our method outperforms baselines in reducing the generation of undesirable output.
