Skip to content

GuidePart of: De-identification checklist

PII Redaction for LLM Training Data: Methods and Tools

Published 5 min read

Two engineers in a dark office at night reviewing chat transcripts with highlighted placeholder tags on two monitors.
On this page

PII redaction for LLM training data means finding personal details in text and removing or replacing them before a model learns from it. Good pipelines combine pattern rules, entity models and human review. They replace names with typed tokens like <PER_1>, and they measure recall on a labelled sample. No tool finds everything, so the evidence matters as much as the method.

This guide is for teams at labs and data vendors who build or check that step. It covers how detection works, what to replace PII with, how to test it, and where it breaks in enterprise data. For the list of evidence to demand from a supplier, see the de-identification checklist for enterprise datasets.

What counts as PII in training data?

PII (personally identifiable information) is any detail that points to a real person, alone or combined with other details. In work data, it comes in three layers.

  • Direct identifiers: names, email addresses, phone numbers, account numbers, national ID numbers.
  • Quasi-identifiers: job titles, office locations, dates and project names. One is harmless. Three together can single out a person in a 40-person company.
  • Sensitive content: health, salary, union membership and disciplinary details, even when no name is attached.

Redaction is removing or masking those details. Pseudonymisation is replacing them with consistent stand-ins, so <PER_1> is the same person all through a thread. Most training pipelines want pseudonymisation, because a model can't learn who said what to whom from a wall of blanks.

Why does PII in LLM training data matter?

Models can repeat what they saw. That's the core risk, and it's measured, not guessed.

Carlini and colleagues pulled hundreds of verbatim sequences out of GPT-2's training data, including names, phone numbers and email addresses. Later work tested scrubbing itself. The Lukas et al. study on PII leakage in language models found scrubbing "reduces but does not prevent" leakage. Even with sentence-level differential privacy, about 3% of PII sequences still leaked.

Scrubbing lowers the odds a model repeats a person's details. It doesn't bring them to zero.

So a redaction step needs two things. It needs high recall on the identifiers that matter most. And it needs evidence a buyer can check.

How do PII redaction tools find personal data?

They stack several detectors, because each one misses different things. Here's how the main methods compare.

Method Good at Misses
Regular expressions Emails, phone numbers, URLs, IBANs Names, anything without a fixed shape
Checksums National IDs and card numbers with check digits Numbers without a check digit
Named-entity models Person, organisation and place names Lower-case names, nicknames, names in code
Context rules Raising confidence near words like "call" or "Dear" Rare phrasings, other languages
LLM prompts Context and unusual formats Consistency; it may skip or rewrite text
Allow and deny lists Company staff lists, product names to keep Anyone not on the list

Patterns and checksums

These are cheap and exact for shaped data. A Dutch BSN has 9 digits and a check rule. A regex plus a checksum finds it with few false alarms. But patterns can't find "Anna from finance".

Entity models

Named-entity recognition (NER) is a model that tags spans of text as people, organisations or places. It finds names that no pattern could. It also misfires on product names and misses names in odd casing, like @pieter.devries in a chat.

LLM-based detection

A language model asked to tag PII catches context well. It knows "my manager Sam" refers to a person. But it can change text it should only label. Keep its output as spans with offsets, never as rewritten text.

Three reviewers at a long table in a dim office at night, one marking printed records with a green highlighter.

Which PII redaction tools do teams use?

Most teams start from an open-source framework and add their own rules. The common building blocks:

  • Presidio: an analyzer for finding PII in text, an anonymizer with several operators, and an image redactor. It combines NER, regular expressions, rule-based logic and checksums. It's now a community-owned project, and the Presidio documentation warns there's no guarantee it finds all sensitive information.
  • spaCy: an NLP library whose entity models often sit underneath a redaction pipeline. You can train it on your own labelled spans.
  • Managed cloud PII APIs: the large cloud providers sell PII detection as a service. They're quick to start, but the text leaves your environment, which a licence may forbid.
  • Your own rules: a staff list from the data owner, customer names from the CRM, and a keep list for product names. These often add more recall than switching tools.

Should you delete, mask or replace PII?

Replace direct identifiers with typed tokens in most cases. Delete only what has no training value. Here's how the options compare.

Approach Example Keeps context Risk
Delete "Call at 3pm" Low Breaks sentences and threads
Mask "Call [REDACTED] at 3pm" Medium Loses who is who
Typed token "Call <PER_2> at 3pm" High Token links can rebuild a profile
Realistic surrogate "Call Maria at 3pm" Highest A missed real name hides among fakes

Typed tokens numbered per conversation are the usual choice. The model still learns that two people talked and who replied to whom. Our Slack thread dataset schema shows how those tokens fit into a record. Surrogates read best, but they make a missed real name look like a fake one. That makes review harder, so flag surrogate data clearly.

How do you measure whether PII redaction worked?

Measure recall on data the tool hasn't seen, per identifier type. A single "99% accurate" figure hides the gaps.

  1. Build a gold set. Label a few hundred records by hand, across sources, languages and years.
  2. Run the pipeline on it. Count found, missed and wrongly tagged spans per type.
  3. Report recall per type. Emails at 99.9% and names at 92% is a very different dataset from the reverse.
  4. Scan the output. Search the full delivery for known staff names, email domains and phone formats.
  5. Review a random sample. People read records end to end and log every miss.
  6. Write it down. Put method, recall and residual misses in section 6 of the dataset datasheet template.

Where does PII redaction fail in enterprise data?

Work data breaks tools trained on news text. These are the gaps that show up most in samples.

Names outside English

Polish names change form by grammatical case. Dutch surnames carry lower-case particles like "van der". Detectors trained on English miss both. Our page on non-English enterprise data lists the traps per language.

Identifiers hiding in structure

Email signatures, ticket fields, file paths and URLs carry names and phone numbers in odd places. So do code comments and commit authors. In tickets, the requester fields matter as much as the body, as our support ticket dataset guide shows.

Quasi-identifiers and attachments

A token can't hide "the only woman on the Rotterdam sales team". Small teams need generalised titles and places. Screenshots and PDFs need OCR before any text detector sees them, or they slip through untouched.

FAQ

Questions about this guide

What is the best PII redaction tool for LLM training data?

There isn't one tool that wins on every dataset. Open-source frameworks like Presidio are easy to extend and run on your own servers. Whatever you pick, test it on a labelled sample of your own data, because recall changes a lot between data types and languages.

Can I use an LLM to redact PII?

Yes, and it often catches names and context that patterns miss. But it can also skip items, rewrite text or invent changes. Use it as one detector among several, keep the original offsets, and measure its recall on a gold set like any other tool.

Is redacted data anonymous under the GDPR?

Usually not. Replacing names with tokens is pseudonymisation, and the data stays personal for anyone who can reasonably link it back. The EU Court of Justice said in September 2025 that this depends on the recipient's means. Your privacy counsel decides where the line sits.

What recall should PII detection reach before data goes into training?

No law or standard sets a number. Many teams set separate targets per identifier type, with direct identifiers like emails and phone numbers held to the highest bar. Agree the target and the test set in writing before delivery.

Does redaction stop a model from memorising personal data?

It lowers the risk but does not remove it. Research on GPT-2 and later models shows that missed identifiers can be recalled word for word. That's why leak scans and memorisation tests after training matter too.

Should redaction happen before or after deduplication?

Usually after. Deduplicate first so you don't review the same email signature a thousand times. Then redact, and run deduplication again, because tokens can make near-duplicates identical.

Related