A Mechanistic Understanding of Alignment Algorithms: A Case Study on DPO and Toxicity

Andrew Lee, Xiaoyan Bai, I. Pres, Martin Wattenberg, Jonathan K. Kummerfeld +1 more
1/1/2024
229 citations
rlhf-rlvr-dpo

Official code: ajyl/dpo_toxic (89 stars, Jupyter Notebook, MIT, last commit 2025-03-07).

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations(1)

ajyl/dpo_toxicOfficial100%
MIT

A Mechanistic Understanding of Alignment Algorithms: A Case Study on DPO and Toxicity.

8918Jupyter Notebook, PythonDec 21, 20231 years agoMIT

Similar Papers

Cite this paper

@article{lee2024mechanistic,
  title  = {A Mechanistic Understanding of Alignment Algorithms: A Case Study on DPO and Toxicity},
  author = {Andrew Lee and Xiaoyan Bai and I. Pres and Martin Wattenberg and Jonathan K. Kummerfeld and Rada Mihalcea},
  year   = {2024},
  eprint = {2401.01967},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2401.01967},
  journal = {ICML 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2401.01967.svg)](https://codeofpaper.com/paper/2401.01967)

Discussion