PII Protection

PII protection reduces exposure of personal data in prompts, retrieval, logs, memory, and outputs. It is a control inside broader data privacy and guardrails, not a guarantee by itself.

Choosing the least destructive control

A practical pipeline classifies fields, redacts or masks high-risk patterns, minimizes context, and enforces permissions before tool use. Deterministic recognizers catch common emails, phone numbers, and card-shaped strings. Model classifiers may help with free-form sensitive text, but they should not be the only control for regulated fields.

Use the least destructive control that satisfies the privacy requirement. Some tasks need redaction before the model call. Others should keep private fields out of the prompt and fetch them through a permissioned tool only when needed. Logs should avoid raw prompts unless the retention and access policy explicitly allows them.

ControlBest forTradeoff
Redactionremoving direct identifiers before model callscan destroy information needed for the task
Masking with typed placeholderspreserving task structure without raw identifiersplaceholders can still reveal sensitive context
Tokenization or pseudonymizationlinking repeated entities across a workflowmapping table becomes sensitive infrastructure
Permissioned retrieval/toolingusing private data only after an access checkmore engineering complexity and audit requirements
Log minimizationreducing breach impact and retention riskweaker debugging unless traces keep safe metadata

Worked redaction example

Before sending support text to a model, deterministic recognizers can replace high-risk fields with typed placeholders:

input spanrecognizerreplacement
ana@example.comemail pattern[EMAIL]
1234-5678-9012-3456card-shaped digit pattern[CARD]

The prompt fragment

Email ana@example.com about acct 1234-5678-9012-3456.

becomes

Email [EMAIL] about acct [CARD].

Typed placeholders preserve the task shape while removing direct identifiers. The example is intentionally narrow: deterministic rules are useful for structured PII, but they do not solve names, addresses, or context-dependent identifiers by themselves.

Placement in a GenAI System

PII controls should appear before, during, and after generation:

StageControl question
Input intakedoes the user request contain unnecessary personal data?
Retrievalis the requesting user allowed to access the retrieved record?
Prompt constructioncan the model solve the task with placeholders or aggregates?
Tool useare private fields fetched through audited permission checks?
Outputdoes the answer leak identifiers that were not needed?
Loggingare raw prompts, sources, and outputs retained safely or minimized?

The safest design is often data minimization rather than clever redaction: never place private fields in the model context unless the task requires them.

Caveats

Regex misses names, addresses, and context-dependent identifiers. Redaction can break task quality, so systems may need permissioned tools instead of sending raw records to the model. Synthetic examples copied from production support tickets should still be treated as production data unless they have been de-identified.

References