Localizing Paragraph Memorization in Language Models

Niklas Stoehr, Mitchell Gordon, Chiyuan Zhang, Owen Lewis
3/28/2024
31 citations
cs.CLcs.CRcs.LG

Official code: googleinterns/localizing-paragraph-memorization (15 stars, Jupyter Notebook, Apache-2.0, last commit 2024-02-21).

Abstract

Can we localize the weights and mechanisms used by a language model to memorize and recite entire paragraphs of its training data? In this paper, we show that while memorization is spread across multiple layers and model components, gradients of memorized paragraphs have a distinguishable spatial pattern, being larger in lower model layers than gradients of non-memorized examples.

Show full abstract

Moreover, the memorized examples can be unlearned by fine-tuning only the high-gradient weights. We localize a low-layer attention head that appears to be especially involved in paragraph memorization. This head is predominantly focusing its attention on distinctive, rare tokens that are least frequent in a corpus-level unigram distribution. Next, we study how localized memorization is across the tokens in the prefix by perturbing tokens and measuring the caused change in the decoding. A few distinctive tokens early in a prefix can often corrupt the entire continuation. Overall, memorized continuations are not only harder to unlearn, but also to corrupt than non-memorized ones.

View on arXivView PDF

Code Implementations(1)

Apache-2.0
150Jupyter Notebook, PythonFeb 2, 20242 years agoApache-2.0

Similar Papers

Cite this paper

@article{stoehr2024localizing,
  title  = {Localizing Paragraph Memorization in Language Models},
  author = {Niklas Stoehr and Mitchell Gordon and Chiyuan Zhang and Owen Lewis},
  year   = {2024},
  eprint = {2403.19851},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2403.19851v1}
}

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/2403.19851.svg)](https://codeofpaper.com/paper/2403.19851)

Discussion