The Blessing and Curse of Dimensionality in Safety Alignment

Rachel S.y. Teo, Laziz Abdullaev, Tan Minh Nguyen

TL;DR

This paper explores the "curse of dimensionality" in large language models (LLMs), showing how their high-dimensional internal representations, while enabling powerful capabilities, also create vulnerabilities for safety alignment. The authors propose and validate dimensionality reduction techniques as a defense against "jailbreaking" attacks that exploit these linear structures, demonstrating improved safety without significant loss of utility.

What Problem Does This Paper Address?

Large Language Models (LLMs) have become incredibly capable, but their widespread adoption raises critical safety concerns. Ensuring these models refuse harmful instructions while remaining helpful for benign ones is known as "safety alignment." A key challenge is that as LLMs grow in size (more parameters, larger hidden dimensions), they become susceptible to "jailbreaking" attacks. These attacks exploit how concepts like "safety" are represented internally within the model's activations. Specifically, the paper addresses how the linear structure of these internal representations, which emerges with increased dimensionality, can be leveraged by attackers to bypass safety mechanisms. The core problem is understanding and mitigating this dual nature of high dimensionality: it's a "blessing" for capability but a "curse" for safety.

Methods

The paper's core contribution lies in analyzing and mitigating the impact of dimensionality on LLM safety.

  • Activation Visualization and Linear Probing: The authors use Principal Component Analysis (PCA) to visualize the internal representations of LLMs. They project activations from prompts designed to elicit positive or negative emotions (as a proxy for safety concepts) onto the top two principal components. They also employ linear probes (simple linear classifiers) to quantitatively assess how linearly separable these concepts are within the activation space.
  • Dimensionality Reduction for Defense: To counter jailbreaking attacks that exploit linear structures, the paper proposes two novel fine-tuning methods:
  • Fast Johnson-Lindenstrauss Transform (FJLT): This technique projects the query and key matrices in the multi-head attention mechanism of LLMs into a lower-dimensional subspace. This aims to disrupt the linear separability of safety concepts.
  • Bottleneck: This method inserts a linear autoencoder between consecutive layers of the LLM. This autoencoder compresses and then reconstructs the representation, effectively creating a bottleneck that can filter out linearly encoded information.
  • Theoretical Analysis: The paper provides theoretical insights into why linear structures emerge in high-dimensional spaces and how dimensionality reduction can weaken these structures, making them harder to exploit for jailbreaking. They use Rademacher complexity to bound the capacity of linear hypothesis classes.

Datasets

The paper utilizes several datasets for training and evaluation:

  • JailbreakBench: Used for evaluating harmful instruction refusal and safety scores.
  • Alpaca dataset: Used for evaluating benign instruction refusal and perplexity.
  • THE PILE: Used for utility evaluations.
  • SQL Create Context: Used for utility evaluations.
  • Samsum: Used for utility evaluations.
  • GSM8k: Used for utility evaluations.
  • Red-teaming data (from Ganguli et al., 2022): Used for fine-tuning the FJLT model on harmful prompts.
  • Model-specific responses to benign prompts: Used as anchor datasets for fine-tuning the Bottleneck model.

No new benchmarks were introduced; existing ones were leveraged to assess both safety and utility.

Key Insights and Ideas

  • The "Paradox of Linear Separability": As LLMs scale up and their internal representations become more complex (higher dimensions), they gain capabilities but also become more vulnerable to attacks that exploit these linear structures. This creates a trade-off that needs careful management.
  • Dimensionality as a Double-Edged Sword: High dimensionality is crucial for LLMs' success, enabling them to learn complex concepts. However, this same dimensionality fosters the emergence of linear structures that can be exploited for jailbreaking.
  • Dimensionality Reduction as a Defense: Projecting LLM representations into lower-dimensional subspaces (via FJLT or Bottleneck) effectively disrupts the linear separability of safety concepts, making them harder for attackers to target.
  • Bottleneck Preserves Utility Better: While both FJLT and Bottleneck reduce linear safety representations, the Bottleneck method appears to preserve the model's general utility (performance on various tasks) more effectively than FJLT, which can sometimes lead to a significant drop in performance on specialized tasks.
  • Safety Alignment is Not Necessarily Linear: The research suggests that strong safety alignment doesn't require concepts like "safety" to be represented in a strictly linear fashion. By disrupting this linearity, models can remain safe without losing their ability to perform tasks.

Key Results

  • Reduced Jailbreak Success: The proposed FJLT and Bottleneck models significantly reduced the success rate of ActAdd jailbreak attacks. For instance, on Llama2-7B-Chat, the Bottleneck model achieved a refusal score of 0.95 and a safety score of 0.97 on harmful instructions after the ActAdd attack, compared to a baseline refusal of 0.97 and safety of 0.03.
  • Preservation of Safety: The defended models maintained high refusal and safety scores on harmful instructions, often close to baseline levels, while also showing good performance on benign instructions.
  • Utility Trade-offs: While the Bottleneck model generally maintained good utility across various benchmarks (THE PILE, Alpaca, SQL Create Context, Samsum, GSM8k), the FJLT model sometimes showed a significant drop in performance on specialized tasks like SQL Create Context and GSM8k, suggesting potential information loss due to aggressive dimensionality reduction.
  • Linear Probing Accuracy Drop: Linear probe accuracy for safety concepts decreased in the FJLT and Bottleneck models compared to the baseline, indicating that these concepts are less linearly represented, which is the desired outcome for defense.

Limitations and Future Work

  • Non-linear Attacks: The defense mechanisms are primarily designed against linear jailbreak attacks. The paper acknowledges that performance against non-linear attacks (like GCG) is mixed, with the FJLT method even showing degraded performance in some cases. This suggests that a comprehensive safety framework needs to address non-linear safety representations.
  • Linearity Assumption: The methods rely on the assumption that safety-relevant concepts are linearly separable. This might not hold for more nuanced safety concepts, limiting the direct applicability of the current approach.
  • Data Requirements: The fine-tuning approach, especially for the Bottleneck method, requires specific anchor datasets (benign responses from the same model family), which can limit transferability across different model architectures.
  • Future Work: The authors suggest exploring principled semantics-based projection methods that can better preserve abstract concepts while still disrupting linear structures. They also highlight the need for complementary approaches to address non-linear safety representations.

Summary updated

BibTeX
@inproceedings{teo2025blessing,
  author = {Rachel S.Y. Teo and Laziz Abdullaev and Tan Minh Nguyen},
  title = {{The Blessing and Curse of Dimensionality in Safety Alignment}},
  booktitle = {COLM},
  year = {2025},
  url = {https://openreview.net/forum?id=TiTk6VDz2H},
}
Figure