English

Distributional Surgery for Language Model Activations

Machine Learning 2025-11-11 v2 Computation and Language Optimization and Control

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.

Keywords

Cite

@article{arxiv.2501.15758,
  title  = {Distributional Surgery for Language Model Activations},
  author = {Bao Nguyen and Binh Nguyen and Duy Nguyen and Viet Anh Nguyen},
  journal= {arXiv preprint arXiv:2501.15758},
  year   = {2025}
}

Comments

3 figures

R2 v1 2026-06-28T21:18:52.190Z