Mitigating Memorization Where It Happens

Xuanqi Zhang, HaoYang Shang, Xiaoxiao LiNeurIPS 2026

TL;DR

Large language models (LLMs) occasionally act like tape recorders, regurgitating copyrighted text or private data verbatim. Current fixes tend to apply a blunt instrument at every single word, dulling the model's general intelligence in the process. This paper introduces Gated Subspace Steering (GSS), a lightweight inference-time switch that watches internal activations and nudges the model off-track only at the exact token positions where verbatim recall is kicking in—requiring zero weight updates and minimal compute.

What Problem Does This Paper Address?

Suppose an LLM has memorized "Alice’s phone number is 555-0142." Predicting "is" after "phone number" is basic English grammar; predicting "555-0142" is problematic memorization.

When we try to stop verbatim recall—whether by updating weights (machine unlearning) or nudging internal hidden states during generation (activation steering)—existing methods usually apply corrections uniformly across all tokens. Modifying hidden states when the model is just trying to output normal grammar ("is") degrades general utility and fluency. The core challenge is surgical precision: how do you suppress sequence-level reproduction on the fly without collateral damage to ordinary predictions, and without expensive retraining?

Methods

Instead of updating model weights, the authors propose Gated Subspace Steering (GSS), an intervention applied at a single hidden layer that separates where to intervene from how to intervene.

Figure 2: Gated Subspace Steering overview. (a) Direction estimation. The target–reference signal partitions positions into high- and low-signal subsets. Activation–gradient statistics from high-signal positions and a second moment from low-signal positions determine probe (uk) and steer (vk) directions through whitening and SVD. (b) Intervention. During generation, the gate applies a correction when the magnitude of a probe response exceeds its threshold. The response controls the signed correction along the steer. Gate decisions are not ground-truth memorization labels.
  1. Offline Calibration (Finding the Directions): First, the authors run training data through both the target model and a "reference" model (one that understands the domain/language, like an earlier checkpoint, but had less exposure to the specific sequences). By subtracting the reference’s token log-probabilities from the target’s, they get an excess log-likelihood signal ($\omega_t$). High-signal positions flag where exposure-driven recall likely happens. Next, they look at how hidden activations and loss gradients couple at those high-signal tokens, while normalizing ("whitening") against background low-signal tokens so the detector won't fire on normal text. Rather than running iterative gradient descent, the optimal probe ($u_k$) and steer ($v_k$) directions pop right out in closed form via Singular Value Decomposition (SVD).
  2. Online Generation (The Gate): At inference time, the reference model is no longer needed. At each token, GSS takes a tiny dot product between the hidden state and the probe ($u_k$). If—and only if—that response crosses a threshold $\epsilon$, the gate opens and subtracts a corrective vector along the steer direction ($v_k$). Otherwise, the hidden state passes through untouched. They also test a stricter gate requiring two consecutive high-probe tokens before firing.

Datasets

No new datasets are introduced, though the authors run controlled experiments across existing benchmarks spanning synthetic tasks, pretraining corpora, and fine-tuning domains:

  • TinyMem: A specialized memorization-mitigation suite featuring multiplicative math and language models under noise and backdoor triggers.
  • The Pile: Pretraining sequences used to test scalability on Pythia-2.8B and Pythia-6.9B.
  • GSM8K & UltraChat: Used to evaluate fine-tuned reasoning and dialogue models (Llama-3.2-1B, Qwen3-0.6B, Qwen2.5-7B).
  • Domain & PII sets: Healthcare, Finance, Academia, and synthetic Personally Identifiable Information (PII) fine-tuning tasks.

Key Insights and Ideas

  • Memorization is spiky, not uniform: Across 12 model-dataset pairs, the top 10% of token positions carry 30%–89% of the positive excess likelihood mass, often appearing in tiny bursts (averaging 1.64 tokens on Qwen-GSM8K). You don't need to steer every token because only a fraction of tokens drive verbatim recall.
Figure 1: Token-level excess likelihood on Qwen3-GSM8K. (a) The distribution of ωt is right- skewed (skewness 2.89), with some positions exhibiting much larger target–reference likelihood differences than others. (b) Consecutive runs of positions with ωt > 0 have a mean length of 1.64; 60.8% of runs contain one position. These statistics describe the likelihood signal, rather than the lengths of memorized spans or ground-truth transitions between recall and generalization. Cross- setting concentration measurements are reported in Appendix C.1.
  • Reading and writing are different jobs: Standard steering adds or subtracts the same vector used to detect a concept. GSS decouples the probe (which depends on where activations live in space) from the steer (which depends on how downstream layers react to changes), linked via activation-gradient statistics.
  • Suppressing memorization can slightly boost reasoning: On math reasoning tasks (GSM8K), moderate gated steering pushed test utility slightly above the unsteered baseline, suggesting memorized quirks were acting like overfitting noise.

Key Results

  • TinyMem: GSS drops verbatim reproduction to 0.00% across all math and language settings (including backdoor attacks where several pruning baselines revert to 100% memorization), keeping math accuracy at 96.98% (vs. 97.00% baseline) and running in milliseconds.
  • Pythia Scale-up: Reduces $(n, k)$-memorization from 89.31% to 6.96% on Pythia-6.9B (and 52.87% to 6.93% on 2.8B) in ~0.2 seconds—requiring 10–100$\times$ less compute than optimization-heavy baselines.
  • The Gating Dividend: Removing the gate (steering every token with the exact same vectors) degrades TinyMem language perplexity by 2.4–4.1 points, confirming that selective gating is what saves model utility.
  • Low-Rank Sufficiency: Subspace ranks under 5 preserve utility best, indicating memorization signals live in a remarkably compact subspace.

Limitations and Future Work

  • Pretrained Perplexity Tax: On pretrained Pythia models, test perplexity rises noticeably (+29.9% to +49.8%) because pretraining lacks a clean boundary between "things to forget" and "general knowledge."
  • Reference Dependency: Offline calibration relies on having a sensible, domain-competent reference model with lower exposure to the target data.
  • Ceiling on Total Unlearning: On Pareto frontiers for modern fine-tuned LLMs, weight-updating unlearning methods can push total memorization lower than GSS, albeit at a steeper cost to utility. Furthermore, under heavy repetition (e.g., 8 copies of PII), the gentler two-token consecutive gate fails to suppress recall. Future work is not explicitly outlined by the authors.

Summary updated

Abstract

Large language models (LLMs) can memorize and reproduce training sequences verbatim, raising privacy and copyright concerns. Existing mitigation methods apply interventions uniformly, often degrading predictions at the many positions unrelated to verbatim recall. We study a token-level log-likelihood ratio between a target model and a domain-competent reference with lower exposure to the evaluated sequences. Exposure-controlled experiments support its use for localizing positions associated with sequence-level verbatim recall. Across evaluated settings, a minority of positions carries a disproportionate share of the positive signal, motivating selective activation correction. From a first-order surrogate of the memorization-reduction objective, we derive a probe--steer framework, which decomposes intervention into a probe that flags high-signal activations and a steer that applies a correction only when the probe exceeds a threshold. We propose Gated Subspace Steering (GSS) as its practical instantiation: under a background normalization constraint, the probe--steer pairs that are optimal for this surrogate follow in closed form from the leading singular vectors of a whitened gradient-weighted activation matrix. Across four benchmarks, GSS achieves memorization suppression comparable to strong baselines, with favorable utility trade-offs in several settings, while requiring 10--100$\times$ less compute than optimization-based alternatives. Code is available at https://github.com/ubc-tea/Mitigating-Memorization-Where-It-Happens.
BibTeX
@inproceedings{zhang2026mitigating,
  author = {Xuanqi Zhang and HaoYang Shang and Xiaoxiao Li},
  title = {{Mitigating Memorization Where It Happens}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=hV2JIz6mgg},
}
Figure