Manuscript Offprint

arXiv:2610.20656

Unmasking the Secret Code: Using Canaries to Show How Masked Context Controls Memorization in SFT

Avi Schwarzschild, Om Thakkar, Sahra Ghalebikesabi, Congzheng Song, Vinnie Monaco

Avi Schwarzschild*, Om Thakkar*, Sahra Ghalebikesabi, Congzheng Song, Vinnie Monaco

OpenAI

{avis,om,sahra,congzheng,vinnie}@openai.com

Abstract—Canaries, or synthetic training records containing known secrets, are widely used to assess whether language models reveal information from their training data. But how much do these measurements depend on the canaries themselves? We study this question through controlled fine-tuning experiments with language and vision-language models, spanning synthetic tasks and tasks where training improves useful performance. Whether a secret is provided in the training input strongly changes what the model learns; for example, models can reproduce a secret in the input yet fail to recall it when it is removed, even after extensive repetition during training. When training instead requires predicting the secret from the surrounding context, later recall can become reliable. Repetition alone is therefore insufficient to characterize memorization. We also find that changing when a canary appears, or which other canaries accompany it, can substantially change measured memorization without increasing that canary's repetition count. These results show that canary measurements depend on how secrets are presented during training and tested afterward. Audits should test whether their conclusions hold across these choices before extending them to other training records.

I. INTRODUCTION

Training data extraction studies show that language models can reproduce training passages and personal information [8, 15, 23, 26]. When data owners release language models, even only through query access, a central privacy question is whether end users can later extract private information from their training data. This risk depends on how information is presented and used during training, as well as on the context supplied at evaluation. Directly measuring this risk is difficult because private training sets may contain many different kinds of sensitive information. The data owner may not know which records are most likely to be recovered under query access or how to determine this. Canary evaluations provide a controlled way to study when information encountered during training can later be recovered from a model [7]. An auditor inserts synthetic records containing secrets into training data and then attempts to extract those secrets from the final model. Because the auditor controls the canary records, they know what information was inserted, how often it appeared, where it appeared during training, and whether the final model exposes it. Research studies use canaries to measure leakage across language-model updates [40] and to audit leakage through LLM-generated synthetic text [24]. Canary-based memorization tests also appear in model-development reports. For example, the PaLM 2 release has evaluations of recovery of

*Equal contribution.

Input (masked)

SYSTEM: You are a helpful assistant.

USER: I have a record from Morgan Vale 7632, can you format this?

ASSISTANT:

Yes.

{ Name: Morgan Vale,

Code: 7632 }

Output

Training sample

Input

SYSTEM: You are a helpful assistant.

USER: I have a record from Morgan Vale 7632, can you format this?

ASSISTANT:

Yes.

{ Name: Morgan Vale,

Code: ...

Output

Canary test

Input

SYSTEM: You are a helpful assistant.

USER: I have a record from Morgan Vale [redacted], can you format this?

ASSISTANT:

Yes.

{ Name: Morgan Vale,

Code: ...

Output

Canary test

Fig. 1. When models are trained on samples that contain sensitive information, like the training sample on the left, model owners need to consider the risk of data extraction at test time. One standard canary audit takes the shape of the middle pane, where the test case has the prefix from the training sample verbatim and the auditor is testing for completion. We highlight that the context matters and completion from the verbatim prefix can sometimes indicate that the model knows how to determine the secret or the code from the context itself. In the right-most pane, we show how a canary audit can be shaped to isolate unintended memorization, or association of the secret with the surrounding context rather than copying or decoding it from the input. While our explorations relate to several other aspects of canary audit design too, we present the first study with an emphasis on how much the context matters for unintended memorization.

injected canaries [1] and related evaluations of Gemini 1.5 and Gemma 2 measure exact and approximate recovery of sampled training passages [13, 14]. The inference from canary recovery to the vulnerability of other training records remains uncertain.

The most compelling gap we find arises from how the canary's secret is represented in the input. When the input includes the secret, say a four-digit code or a social security number, then even when it also appears in the supervised output and we train directly on its generation, memorization signals are extremely weak. On the other hand, if the secret is encoded in the input with some complex transformation, or completely absent from the input altogether, then training over the secret in the output can lead to high memorization signal even with very few repetitions of that sample. In other words, the way a canary embeds its secret changes the prediction problem posed during training and consequently greatly changes the memorization risk. We refer to this axis of canary design as the predictive context, where verbatim copies of secrets in context are considered very predictive and redacted or absent information is not predictive at all. We show that this lever has a dramatic effect on the risk measurements and thus it is a canary design decision that practitioners should be careful matches the types of real data whose risk they hope to capture.

Along with how predictive the context is, we investigate three other axes of canary audit protocol and find that each can have large effects on the measurements. We consider the dosage, or the number of times a canary is repeated in the training set, and we corroborate widely shown effects that memorization risk increases with repetition. Further, we look at the placement among the training data and show that recency matters, to the point that very-late-in-training samples with low dose can show higher memorization signal than much higher dosage canaries that appear earlier. Finally, we study interaction effects where we ask how the insertion of new canaries can change the reading or the measured memorization of canaries. In all, these findings highlight that some widely held intuitions and some understudied axes of canary design pose challenges in interpreting canary audit findings in practice.

Our main findings can be summarized as follows.

  1. How easy it is to determine or decode the secret from the context controls how likely a secret is to get memorized.

  2. Dosage and timing jointly shape memorization risk and have outsized effects.

  3. Inserting additional canaries can dramatically increase unintended memorization, making it difficult to make claims about single samples and to generalize to real data where these interaction effects are hard to model.

For practitioners, low extraction risk under one protocol is insufficient evidence of low risk under another. We recommend evaluating with secrets visible, hidden, and substituted, testing plausible timing and population changes, and reporting rich sets of metrics like exposure in addition to exact recovery under sampling.

References (43)