What it is
PII — personally identifiable information — is any data that identifies a person: an email address, a phone number, a national ID, a bank account. Chat logs are full of it, because people paste their details when asking for help. Secrets such as API keys and passwords end up there for the same reason. This step finds them in the training data and decides what happens to them before the data leaves for training.
Why a model can leak training data
Training pushes the model to make each target reply more likely. For most text that means learning patterns, but for rare, exact strings — an IBAN, an email address, a key — the only way to predict them is to memorise them. That memorised text can then come back out when a later prompt resembles the original context.
This is not hypothetical. Carlini et al. (2020) extracted hundreds of verbatim sequences from GPT-2's training data, including names, phone numbers and email addresses, by prompting the model and filtering its outputs. Later work found memorisation grows with model size and with how often an example repeats, and Lukas et al. (2023) showed that common scrubbing methods reduce but do not eliminate PII leakage. Fine-tuning data is a much smaller set seen several times over (each epoch is another pass), which makes it easier, not harder, to memorise.
How it works
Detection scans the conversation text for identifiers with a recognisable structure: email addresses, phone numbers, payment card numbers, IBANs, national ID numbers and API keys. Each match is then handled according to the mode you choose. With Redact, the value is replaced by a placeholder of the same type:
Email dana.k@example.com → [EMAIL]
Phone +44 20 7946 0958 → [PHONE]
Card number 4111 1111 1111 1111 → [CARD]
IBAN GB33 BUKB 2020 1555 5555 55 → [IBAN]
API key sk_live_… → [API_KEY]userHi, I'm Dana. Please send the refund to GB33 BUKB 2020 1555 5555 55 and confirm at dana.k@example.com or +44 20 7946 0958.
userHi, I'm Dana. Please send the refund to [IBAN] and confirm at [EMAIL] or [PHONE].
Placeholders keep the training signal intact. The model still learns that a refund request mentions an account and that a good reply asks to confirm by email; it simply never sees a real account. In use, it will sometimes write [EMAIL] where a value would go, which is a far better failure than writing a real customer's address.
Replace each detected value with a typed placeholder such as [EMAIL] or [IBAN]. The recommended default: the model learns the pattern, not the data.
Keep the values but report how many were found and where. Use it to audit a dataset before deciding, or when the identifiers are synthetic test data and you need the model to reproduce their exact format.
Do nothing. Only appropriate when the data is known to contain no real personal information, for example fully synthetic conversations.
- The user writes: “Refund to GB33 BUKB 2020 1555 5555 55, confirm at dana.k@example.com.” The assistant replies: “Done — a confirmation is on its way to dana.k@example.com.”
- Detection finds one IBAN and the same email address twice, once in the user message and once in the target reply.
- With Redact, both messages are rewritten: the target becomes “Done — a confirmation is on its way to
[EMAIL].” - The email in the target is the dangerous one: target text is what the model is trained to produce. Unredacted, a future user asking about refunds could receive Dana's address.
- With Flag, the report would show 3 items in 1 conversation, and the training file would keep them.
What detection cannot catch
Pattern detection is reliable for identifiers with a fixed shape. It is much weaker on free text: a person's name, a street address written in prose, a diagnosis, or a detail that identifies someone only in combination (“the CFO of our Lyon office”). Treat redaction as a safety net, not a guarantee, and read a sample of the dataset with this in mind — especially when chats cover health, finance, HR or legal matters.
Common mistakes
- Redacting only user messages: assistant replies are the targets the model is trained to reproduce, so they matter most.
- Treating automatic redaction as complete. Names, addresses and sensitive facts in prose are not structured identifiers.
- Using Flag “just for now” and training on the flagged file anyway.
- Forgetting secrets: API keys pasted into a support chat are as dangerous in a model's output as personal data.
- Changing the redaction mode between two preps and then comparing the resulting models as if only the training settings differed.
References and further reading
External sources open in a new tab.
- 01Extracting Training Data from Large Language ModelsCarlini et al., 2020 · arXiv · arxiv.orgThe study that showed language models can be prompted to reveal personal data from their training set.
- 02Quantifying Memorization Across Neural Language ModelsCarlini et al., 2022 · arXiv · arxiv.orgHow memorisation grows with model size, duplication and prompt length.
- 03Analyzing Leakage of Personally Identifiable Information in Language ModelsLukas et al., 2023 · arXiv · arxiv.orgMeasures how well scrubbing and other defences actually reduce PII leakage.
- 04Personal dataWikipedia · en.wikipedia.orgDefinitions of personal data and PII across legal frameworks such as the GDPR.