[Paper Review] Be like a Goldfish, Don't Memorize! Mitigating Memorization in Generative LLMs
This paper introduces the goldfish loss, a simple training objective that randomly masks a subset of tokens during pretraining to prevent large language models from memorizing and regurgitating verbatim training data. By excluding these tokens from the loss computation, the model learns to generate alternatives, significantly reducing extractable memorization with minimal impact on downstream performance, even under strong adversarial attacks.
Large language models can memorize and repeat their training data, causing privacy and copyright risks. To mitigate memorization, we introduce a subtle modification to the next-token training objective that we call the goldfish loss. During training, randomly sampled subsets of tokens are excluded from the loss computation. These dropped tokens are not memorized by the model, which prevents verbatim reproduction of a complete chain of tokens from the training set. We run extensive experiments training billion-scale Llama-2 models, both pre-trained and trained from scratch, and demonstrate significant reductions in extractable memorization with little to no impact on downstream benchmarks.
Motivation & Objective
- To address the growing risk of large language models (LLMs) memorizing and regurgitating verbatim training data, including copyrighted or sensitive content.
- To develop a training-time solution that prevents memorization at the source, rather than relying on post-hoc unlearning or editing.
- To evaluate whether a simple, scalable modification to the next-token prediction objective can effectively reduce extractable memorization without degrading model utility.
- To assess the robustness of the method against adversarial data extraction attacks, such as beam search and membership inference.
Proposed method
- The goldfish loss randomly excludes a pseudo-random subset of tokens (e.g., 25%) from the next-token prediction loss during training.
- During the forward pass, all tokens are processed, but during the backward pass, gradients are not computed for the masked tokens, so the model never learns to reproduce them.
- The method relies on consistent hashing to ensure that identical training sequences are masked in the same way across multiple training epochs.
- At inference, when the model encounters a masked token, it must generate a new token based on context, breaking the chain of verbatim memorization.
- The approach is applied uniformly across all documents during pretraining, but can be selectively applied to high-risk or sensitive data sources.
- The method is evaluated using extractable memorization metrics (e.g., k-prefix exact match and RougeL), as well as adversarial attacks like beam search and membership inference.
Experimental results
Research questions
- RQ1Can a simple, non-differentially private modification to the training objective significantly reduce extractable memorization in LLMs without degrading utility?
- RQ2How effective is the goldfish loss in resisting adversarial data extraction attacks, such as beam search with high beam width?
- RQ3Does the goldfish loss remain effective when training data is repeated multiple times, a scenario that challenges differential privacy?
- RQ4To what extent does the goldfish loss reduce memorization compared to models trained with standard objectives or models that have never seen the data?
- RQ5Can the goldfish loss be selectively applied to high-risk data sources to minimize performance impact while maximizing privacy protection?
Key findings
- Goldfish-trained 7B Llama-2 models showed near-zero extractable memorization on repeated training data (e.g., 100 epochs on a single Harry Potter chapter), while standard models regurgitated the full text verbatim.
- On standard benchmarks like MMLU and GSM8K, goldfish models achieved performance within 1-2% of standard models, indicating minimal utility degradation.
- Even under aggressive beam search with 30 beams, goldfish models with k=3 and k=4 showed strong resistance to data extraction, with extractability dropping below 10% TPR@0.1% FPR.
- Membership inference attacks still succeeded on goldfish models, but with marginally lower accuracy, indicating that while memorization is reduced, some traces remain.
- The goldfish loss was effective even when training data was duplicated across multiple epochs, outperforming differentially private training in such high-repetition scenarios.
- The method remains effective when applied selectively to high-risk documents or code, suggesting practical applicability in industrial settings.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.