Skip to main content
QUICK REVIEW

[Paper Review] A Mechanistic Understanding of Alignment Algorithms: A Case Study on DPO and Toxicity

Andrew Lee, Bai Xiao-yan|arXiv (Cornell University)|Jan 3, 2024
Machine Learning and Data ClassificationComputer Science4 citations
TL;DR

This paper provides a mechanistic analysis of Direct Preference Optimization (DPO) in reducing model toxicity, revealing that DPO does not remove toxic capabilities but instead learns a distributed offset across value vectors to bypass toxic representations. The study demonstrates that alignment can be easily undone by scaling up key toxic vectors, explaining why jailbreaks are possible in aligned models.

ABSTRACT

While alignment algorithms are now commonly used to tune pre-trained language models towards a user's preferences, we lack explanations for the underlying mechanisms in which models become ``aligned'', thus making it difficult to explain phenomena like jailbreaks. In this work we study a popular algorithm, direct preference optimization (DPO), and the mechanisms by which it reduces toxicity. Namely, we first study how toxicity is represented and elicited in a pre-trained language model, GPT2-medium. We then apply DPO with a carefully crafted pairwise dataset to reduce toxicity. We examine how the resulting model averts toxic outputs, and find that capabilities learned from pre-training are not removed, but rather bypassed. We use this insight to demonstrate a simple method to un-align the model, reverting it back to its toxic behavior.

Motivation & Objective

  • To understand the mechanistic underpinnings of how DPO reduces toxicity in language models.
  • To investigate why aligned models remain vulnerable to jailbreaks despite successful alignment.
  • To examine whether toxic capabilities are removed or merely bypassed during DPO fine-tuning.
  • To develop and validate a method to reverse alignment by reactivating toxic vectors.
  • To provide a causal explanation for the fragility of alignment in preference-fine-tuned models.

Proposed method

  • Identified toxic representations in GPT2-medium using Singular Value Decomposition (SVD) on MLP activation vectors.
  • Crafted a pairwise dataset using PPLM to generate paired toxic and non-toxic continuations for Wikipedia prompts.
  • Applied DPO to fine-tune GPT2-medium using the curated pairwise data to reduce toxicity.
  • Tracked changes in model weights and residual stream dynamics before and after DPO to detect shifts in toxic vector activation.
  • Performed intervention by scaling key toxic vectors to reactivate toxic outputs, demonstrating unalignment.
  • Used SVD to isolate and analyze specific vectors responsible for promoting toxicity in the model.
Figure 1: Logit lens on GPT2 and $\text{GPT2}_{\text{DPO}}$ . Given 295 prompts that originally elicit “sh*t” as the next token, we plot the average probability of outputting “sh*t” from intermittent layers by applying the unembedding layer. Minor ticks indicate $\ell\_{mid}$ layers (after attention
Figure 1: Logit lens on GPT2 and $\text{GPT2}_{\text{DPO}}$ . Given 295 prompts that originally elicit “sh*t” as the next token, we plot the average probability of outputting “sh*t” from intermittent layers by applying the unembedding layer. Minor ticks indicate $\ell\_{mid}$ layers (after attention

Experimental results

Research questions

  • RQ1How is toxicity represented and elicited in the internal representations of a pre-trained language model like GPT2-medium?
  • RQ2What specific changes occur in the model’s weights and activations after DPO fine-tuning to reduce toxicity?
  • RQ3Does DPO remove the capability to generate toxic outputs, or does it merely bypass the toxic pathways?
  • RQ4Can the alignment learned via DPO be easily undone, and if so, through what mechanism?
  • RQ5What mechanistic explanation underlies the vulnerability of aligned models to jailbreak attacks?

Key findings

  • Toxicity in GPT2-medium is represented by multiple distinct vectors in MLP blocks, particularly in key and value vectors, which can be isolated via SVD.
  • Intervening on these toxic vectors by subtracting them from the residual stream significantly reduces toxic outputs, confirming their causal role.
  • After DPO fine-tuning, no major weight changes occur; instead, the model learns a distributed offset across value vectors to bypass toxic regions.
  • The DPO model preserves its pre-trained capabilities but avoids triggering toxic representations by routing through alternative pathways.
  • Alignment can be reversed by scaling up the key vectors associated with toxic representations, restoring the model’s original toxic behavior.
  • The fragility of alignment stems not from removal of toxic capabilities, but from the model learning to avoid them via minimal, distributed weight shifts.
Figure 2: Mean activations for toxic vectors before and after DPO.
Figure 2: Mean activations for toxic vectors before and after DPO.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.