Spectral Editing of Activations for Large Language Model Alignment

Yifu Qiu, Zheng Zhao, Yftah Ziser, Anna Korhonen, Edoardo M. Ponti +1 more
5/15/2024
cs.CLcs.AIcs.LG

No official code found. Best implementation: yfqiu-nlp/sea-llm (31 stars, MIT, last commit 2024-12-20).

Abstract

Large language models (LLMs) often exhibit undesirable behaviours, such as generating untruthful or biased content. Editing their internal representations has been shown to be effective in mitigating such behaviours on top of the existing alignment methods. We propose a novel inference-time editing method, namely spectral editing of activations (SEA), to project the input representations into directions with maximal covariance with the positive demonstrations (e.g., truthful) while minimising covariance with the negative demonstrations (e.g., hallucinated). We also extend our method to non-linear editing using feature functions. We run extensive experiments on benchmarks concerning truthfulness and bias with six open-source LLMs of different sizes and model families. The results demonstrate the superiority of SEA in effectiveness, generalisation to similar tasks, as well as computation and data efficiency. We also show that SEA editing only has a limited negative impact on other model capabilities.

View on arXivView PDF

Code Implementations(1)

yfqiu-nlp/sea-llmCommunity100%
MIT

Code for the paper "Spectral Editing of Activations for Large Language Model Alignments"

310Shell, PythonApr 26, 20241 years agoMIT

Similar Papers

Cite this paper

@article{qiu2024spectral,
  title  = {Spectral Editing of Activations for Large Language Model Alignment},
  author = {Yifu Qiu and Zheng Zhao and Yftah Ziser and Anna Korhonen and Edoardo M. Ponti and Shay B. Cohen},
  year   = {2024},
  eprint = {2405.09719},
  archivePrefix = {arXiv},
  doi    = {10.48550/arXiv.2405.09719},
  url    = {http://arxiv.org/abs/2405.09719v3},
  journal = {NEURIPS 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/2405.09719.svg)](https://codeofpaper.com/paper/2405.09719)

Discussion