Lune

NeurIPS2025Top-tier venue

TokenSwap: A Lightweight Method to Disrupt Memorized Sequences in LLMs

Parjanya Prajakta Prashant, Kaustubh Ponkshe, Babak Salimi

Abstract

As language models scale, their performance improves dramatically across a wide range of tasks, but so does their tendency to memorize and regurgitate parts of their training data verbatim. This tradeoff poses serious legal, ethical, and safety concerns, especially in real-world deployments. Existing mitigation techniques, such as differential privacy or model unlearning, often require retraining or access to internal weights making them impractical for most users. In this work, we introduce TOKENSWAP, a lightweight, post-hoc defense designed for realistic settings where the user can only access token-level outputs. Our key insight is that while large models are necessary for high task performance, small models (e.g., DistilGPT-2) are often sufficient to assign fluent, grammatically plausible probabilities to common function words -and crucially, they memorize far less. By selectively swapping token probabilities between models, TOKENSWAP preserves the capabilities of large models while reducing their propensity for verbatim reproduction. Evaluations on Pythia-6.9B and Llama-3-8B show up to a 10× drop in exact memorization with negligible task degradation. Our method offers a practical, accessible solution for mitigating memorized generation in deployed LLMs. Code is available at https://github.com/parjanya20/verbatim-llm.

Write a story about a magical world

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

1 top-tier paper has cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Pythia: A Suite for Analyzing Large Language Models Across Training and Scaling cites Extracting Training Data from Large Language Models
  • Anchored Decoding: Provably Reducing Copyright Risk for Any Language Model cites Fast Inference from Transformers via Speculative Decoding
  • Anchored Decoding: Provably Reducing Copyright Risk for Any Language Model cites Extracting Training Data from Large Language Models
  • Extracting Training Data from Large Language Models cites Deep Learning with Differential Privacy
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers1

  1. Anchored Decoding: Provably Reducing Copyright Risk for Any Language ModelJacqueline He, Jonathan Hayase, Scott Yih, Sewoong Oh et al.ICML 2026

Builds on28

  1. Deep Learning with Differential PrivacyMartín Abadi, Andy Chu, Ian J. Goodfellow, H. Brendan McMahan et al.CCS 2016 · 7,620 citations
  2. WinoGrande: An Adversarial Winograd Schema Challenge at ScaleKeisuke Sakaguchi, Ronan Le Bras, Chandra Bhagavatula, Yejin ChoiAAAI 2020 · 3,037 citations
  3. Extracting Training Data from Large Language ModelsNicholas Carlini, Florian Tramèr, Eric Wallace, Matthew Jagielski et al.USENIX Security 2021 · 2,866 citations
  4. Pythia: A Suite for Analyzing Large Language Models Across Training and ScalingStella Biderman, Hailey Schoelkopf, Quentin Gregory Anthony, Herbie Bradley et al.ICML 2023 · 1,822 citations
  5. Fast Inference from Transformers via Speculative DecodingYaniv Leviathan, Matan Kalman, Yossi MatiasICML 2023 · 1,472 citations

Related papers

  1. Duwak: Dual Watermarks in Large Language ModelsChaoyi Zhu, Jeroen Galjaard, Pin-Yu Chen, Lydia Y. ChenACL Findings 2024 · 7 citations
  2. Be like a Goldfish, Don't Memorize! Mitigating Memorization in Generative LLMsAbhimanyu Hans, John Kirchenbauer, Yuxin Wen, Neel Jain et al.NeurIPS 2024 · 65 citations
  3. SPaR: Self-Play with Tree-Search Refinement to Improve Instruction-Following in Large Language ModelsJiale Cheng, Xiao Liu, Cunxiang Wang, Xiaotao Gu et al.ICLR 2025
  4. Mitigating Memorization in Language ModelsMansi Sakarvadia, Aswathy Ajith, Arham Mushtaq Khan, Nathaniel C. Hudson et al.ICLR 2025
  5. Learning syntax without semantics: Disentangled tiny language modelsEzra Winston, Zico KolterICML 2026
Dusk over the sea between two cliffs drawn in fine vertical lines