PII redaction for LLMs: what it catches and misses
PII redaction for LLM use explained: what masking catches, what it misses, where it breaks extraction, and when keeping data in-house is simpler.
Updated
PII redaction before an LLM means finding personal data in text and swapping it for placeholders before the text is sent to a model. It reduces what the provider sees, but it does not make the call safe on its own, and on extraction work it often breaks the job.
How LLM PII detection works
Most redaction pipelines use three layers. A pattern pass catches fixed shapes such as email addresses, phone numbers, card numbers, national ID formats and IP addresses. A name list catches known people and companies. A named-entity model catches the rest, such as personal names and places in free text.
Each layer has a known failure. Patterns miss any format they were not written for. Name lists go stale. Named-entity models trained on clean text miss names in lowercase, in abbreviations, in scanned documents with OCR errors, and in languages they were not tuned on. You cannot know your recall until you measure it on a sample of your own documents, so measure it before you rely on it.
What redaction misses
The biggest gaps are context, not format. A redactor sees “the patient” and “Dr. Lee” as separate tokens. It does not know that a date of birth, a postcode and a rare diagnosis together point to one person. Job titles, small towns and unusual events pass straight through.
Redaction also misses personal data that appears in the model’s output. If you ask a model to summarize a file, it may restate a name it saw earlier in the same context. Outputs need the same scan as inputs.
Where redaction breaks extraction tasks
Extraction means returning exact text from a document. Redaction changes the document first. If a contract names two parties and both are replaced with placeholders, the model can still find the clause, but the quote it returns no longer matches the source file. Your system then has to map the placeholders back, and any error in that mapping becomes a wrong value in a customer record.
Amounts, dates and account numbers have the same problem. A scanner may treat the value you asked for as personal data and mask it, so the task fails before the model reads the text. Teams often loosen the scanner to fix this, and that brings the leak back.
Does redaction make LLM use safe?
No. Redaction reduces the data a third-party provider receives. It does not change the provider’s retention, logging or processing locations. Check those in the provider’s own documents, not in your redactor.
Here is a hypothetical with round numbers. A team sends 1,000 support emails a day to a hosted model after masking names and email addresses. Two percent of those emails still carry an account number in a format the scanner does not know. That is 20 emails a day with customer data still in them, and nobody sees them unless someone checks the logs. The numbers are invented for illustration, not measured.
When keeping the data in-house is simpler
If data must not leave your environment, redaction is the wrong tool. Hosting a model in your own cloud account or on your own premises removes the transfer, and the question becomes access control and logging inside your own walls. Own Weights fine-tunes an open-weight model for one high-volume task, tests it against the current model on your data, and serves it in your cloud account or on-prem. The customer owns the weights.
Training is not a shortcut around privacy work. A fine-tuned model can memorize parts of its training text, so the training set needs the same review as any other sensitive data. See fine-tuning on sensitive data for what stays in the weights.
Redaction is still the simpler choice in some cases. If the text is not sensitive, if the task is occasional, or if a hosted provider’s contract already covers your data, a redaction layer on a hosted API can be enough. Running your own model means evaluation, serving and upkeep work that you do not have with a hosted API. For a wider view of the trade-off, read PII and third-party AI and LLM data privacy.
If you send personal data to a hosted API today, start with the free AI cost audit or book a call. The audit lists every AI call in your code and the model each one uses, so you can see where your text goes.
Questions
How to remove PII before sending to ChatGPT?
Run a scanner over the text first, replace each match with a placeholder, and keep the mapping on your side so you can restore the values in the answer. Then test the scanner on a sample of your own documents and count what it missed. Read the provider's current data terms before you assume the masked text is the only thing it receives.
Does anonymizing data before using AI make it safe?
It lowers what a provider receives, but it does not change how the provider stores, logs or processes what is left. Whether the call is acceptable depends on the provider's contract and your own policy, and a legal or security reviewer should check both. Redaction is one control among several.
What is PII masking for generative AI?
PII masking for generative AI replaces personal data in prompts and outputs with placeholders before the model call and restores or removes them after. It works well on fixed formats such as email addresses and card numbers. It works less well on names and context-based identifiers, which need a named-entity model and a human review sample.
Can a language model detect PII on its own?
A language model can flag personal data in text, but it is a detector like any other, so it misses some matches and can flag things that are not personal data. If you use a hosted model for detection, the raw text goes to that provider, which defeats the purpose. Run detection inside your own environment when the text is sensitive.
When is it simpler to keep data in-house than to redact it?
When the task needs the full record, such as exact clause extraction, redaction breaks the task and the placeholder mapping adds its own risk. Hosting a model in your own cloud account or on-prem removes the transfer, though you then run the model yourself. For small volumes of non-sensitive text, a hosted API under a signed data agreement is often the simpler choice.