Table of Contents
Fetching ...

SCAR: Sparse Conditioned Autoencoders for Concept Detection and Steering in LLMs

Ruben Härle, Felix Friedrich, Manuel Brack, Björn Deiseroth, Patrick Schramowski, Kristian Kersting

TL;DR

This work tackles the challenge of toxic and unsafe content in large language models by proposing SCAR, a conditioned sparse autoencoder attached to transformer feed-forward activations to isolate and control a target concept. SCAR trains an SAE with a reconstruction loss and a conditioning loss on a latent neuron $h_0$, enabling both detection and steerability via a tunable factor $\alpha$ while keeping the base model untouched during inference. Empirical results on toxicity, safety, and writing style demonstrate that SCAR achieves interpretable concept detection and effective toxicity steering (average ~15% reduction, up to ~30% for highly toxic prompts) with negligible impact on standard benchmarks, and superior feature isolation compared to unconditioned SAEs. The framework supports safer deployment of LLMs and offers a path toward flexible, inspectable alignment controls, with future work exploring multi-concept conditioning and broader generalization.

Abstract

Large Language Models (LLMs) have demonstrated remarkable capabilities in generating human-like text, but their output may not be aligned with the user or even produce harmful content. This paper presents a novel approach to detect and steer concepts such as toxicity before generation. We introduce the Sparse Conditioned Autoencoder (SCAR), a single trained module that extends the otherwise untouched LLM. SCAR ensures full steerability, towards and away from concepts (e.g., toxic content), without compromising the quality of the model's text generation on standard evaluation benchmarks. We demonstrate the effective application of our approach through a variety of concepts, including toxicity, safety, and writing style alignment. As such, this work establishes a robust framework for controlling LLM generations, ensuring their ethical and safe deployment in real-world applications.

SCAR: Sparse Conditioned Autoencoders for Concept Detection and Steering in LLMs

TL;DR

This work tackles the challenge of toxic and unsafe content in large language models by proposing SCAR, a conditioned sparse autoencoder attached to transformer feed-forward activations to isolate and control a target concept. SCAR trains an SAE with a reconstruction loss and a conditioning loss on a latent neuron , enabling both detection and steerability via a tunable factor while keeping the base model untouched during inference. Empirical results on toxicity, safety, and writing style demonstrate that SCAR achieves interpretable concept detection and effective toxicity steering (average ~15% reduction, up to ~30% for highly toxic prompts) with negligible impact on standard benchmarks, and superior feature isolation compared to unconditioned SAEs. The framework supports safer deployment of LLMs and offers a path toward flexible, inspectable alignment controls, with future work exploring multi-concept conditioning and broader generalization.

Abstract

Large Language Models (LLMs) have demonstrated remarkable capabilities in generating human-like text, but their output may not be aligned with the user or even produce harmful content. This paper presents a novel approach to detect and steer concepts such as toxicity before generation. We introduce the Sparse Conditioned Autoencoder (SCAR), a single trained module that extends the otherwise untouched LLM. SCAR ensures full steerability, towards and away from concepts (e.g., toxic content), without compromising the quality of the model's text generation on standard evaluation benchmarks. We demonstrate the effective application of our approach through a variety of concepts, including toxicity, safety, and writing style alignment. As such, this work establishes a robust framework for controlling LLM generations, ensuring their ethical and safe deployment in real-world applications.

Paper Structure

This paper contains 14 sections, 5 equations, 9 figures, 1 table.

Figures (9)

  • Figure 1: Scar overview. (left) The training procedure (red) of Scar illustrating the reconstruction ($\mathcal{L}_r$) and condition ($\mathcal{L}_c$) optimization. Our latent conditioning (orange) ensures an isolated feature representation by aligning it with ground truth labels. (right) During inference (blue), the Feed Forward connection (purple) is dropped and replaced with the SAE. $h_0$ can now be used for detection or for steering, when scaled factor $\alpha$ enables model steerability. Otherwise, the transformer and its parameters remain untouched.
  • Figure 2: Feature detection analysis.
  • Figure 3: Concept steering results.
  • Figure 4: Tree stumps for Scar and unconditioned SAE on RTP.
  • Figure 5: Scar vs. unconditioned feature analysis on decision tree.
  • ...and 4 more figures