Manuscript Offprint

arXiv:2610.22988

Surprise Masking: Private Data Filtering with Model Likelihoods

Riya Tyagi, Sahra Ghalebikesabi, Vinnie Monaco, Avi Schwarzschild, Om Thakkar

ABSTRACT

Data useful for language model (LM) training can contain private or unwanted information that is at risk of being learned or memorized. We propose Surprise Masking (SM), a simple form of perplexity filtering that uses a publicly available reference model to identify unwanted spans and suppress learning from them while preserving the rest of each example. On synthetic code benchmarks, we show SM improves the privacy-utility tradeoff over standard masking methods and PII filtering. In fine-tuning experiments, SM reduces approximate extraction of private values from revealed prefixes from 66.3% to 2.3% and the reproduction of stylistic coding quirks from 23.6% to 1.3%, both while preserving performance on the evaluated coding tasks. We also evaluate SM for sanitizing datasets by directly removing unwanted content. Here, SM outperforms DePA, a perplexity-based defense for detecting poisoned dead code, while specialized detectors perform better on broader credential and PII benchmarks. Across eleven settings, we find that SM's downstream success is predictable from the separation of unwanted and useful content in the distribution, and it is particularly useful with code data. Ultimately, SM is an inexpensive, adaptable method to preserve valuable examples while reducing the learning of unwanted information.

1 INTRODUCTION

Training samples that are valuable for learning can also contain undesirable content, including private information. This leaves practitioners with limited options. They can discard these samples, reducing leakage risk but sacrificing useful information, or train on them with safeguards that have their own costs and limitations. Alternatively, training-time interventions offer a way to alter how models learn from risky data (Hans et al., 2024; Wichers et al., 2025; Tan et al., 2025). These methods tend not to offer explicit or theoretical guarantees, so their privacy protections need empirical testing. Another approach is post-training unlearning methods, which typically localize information within a model before removing it (Merullo et al., 2025; Maini et al., 2023; Stoehr et al., 2024). These tools can all

∗^{*}Work done while the author was an intern at OpenAI.

Figure

Figure 1: Overview of Surprise Masking, illustrated with Global SM. A reference model scores token spans, and sufficiently surprising spans are masked from the training loss.

be costly and have unpredictable effects on model behavior. We aim to improve safeguards that mask unwanted portions of data samples before training on them.

In this work, we revisit perplexity filtering, a method that uses a reference language model's perplexity scores to filter data (see Figure 1 for an overview). Prior work uses perplexity to select useful training data (Ankner et al., 2024; Marion et al., 2023; Thrush et al., 2025) and Wu et al. (2025) use it to mask high-perplexity tokens from the fine-tuning loss to mitigate forgetting. We investigate this same principle for suppressing the learning of private and other unwanted content. Our approach, Surprise Masking (SM), masks token spans that are unlikely under a publicly available reference model.

The intuition is that private content may be unfamiliar to the reference model and therefore surprising, so masking these spans can reduce how much a model trained on the masked data learns about private information. Note the difference between private content and sensitive content: the reference model might know sensitive content, like email addresses appearing in public datasets; however, the presence of such information makes it not private. SM aims to reduce the leakage of private content, especially high-entropy secrets such as API keys, passwords or account numbers.

We first evaluate SM as a training-time intervention. We mask selected tokens from the training loss while retaining the rest of each example. In this setting, we evaluate SM on private content by generating synthetic training datasets with sensitive information that is unavailable to the reference model. We evaluate utility using downstream model performance. The following two existing observations suggest SM may be particularly effective here. First, perplexity can sometimes predict memorization when other properties of the data are held constant (Meeus et al., 2024). Second, false positives—surprising spans that are erroneously masked—might contain poor quality content, such as gibberish, and thus have little effect on downstream model performance.

We additionally evaluate SM as a data sanitization method. These benchmark tasks test whether reference model surprise can localize sensitive content while preserving the surrounding data. Sanitization might be useful when sensitive information must be removed from data, for instance before releasing a dataset. Here, we measure privacy by how much sensitive content is removed and utility by how much other content is preserved.

Our results show that during pretraining and fine-tuning, SM extends the privacy–utility frontier beyond existing baselines (see Section 3). In the sanitization setting, SM remains useful on some narrow distributions. Ultimately, it performs well on mitigating dead code poisoning, but specialized detectors are generally stronger on broader credential and PII benchmarks (see Section 4). In Section 5, we characterize when SM succeeds and fails, and show how practitioners can cheaply assess its suitability for a new setting. Ultimately, we see SM as an inexpensive, adaptable complement to scrubbers, rewriters, and other tools in a robust privacy suite.

References (84)