Prompt DLP detects and masks personal or secret data in prompts and outputs. The data is then not sent to an external LLM, not logged in plaintext, and not leaked back to the wrong user.

Tokenize, call, rehydrate: the redaction round trip

PII Redaction / Prompt DLPDiagram with these labels, in reading order: detect PII; mask PII; send tokenized prompt; generate response; scan for PII; return sanitized output; User Input; (Prompt); Detection Layer; (PII Tagging); Tokenization; (Pseudonymization); Model Call; (LLM); Output; (Rehydrate PII); Scan Output; (PII Check).detect PIImask PIIsend tokenized promptgenerate responsescan for PIIreturn sanitized outputUser Input(Prompt)Detection Layer(PII Tagging)Tokenization(Pseudonymization)Model Call(LLM)Output(Rehydrate PII)Scan Output(PII Check)
Data flow for PII Redaction
  1. A detection layer scans the prompt. Presidio, AWS Comprehend, or custom regex and named entity recognition (NER) tag names, social security numbers, credit card details, API keys and health data.
  2. Each tagged value is replaced with a token. John Smith becomes [PERSON_1].
  3. The tokenized prompt goes to the model, which can still work without seeing the values.
  4. The response is scanned, and the tokens are rehydrated with the original values for internal use.

Consider a healthcare application that sends patient data to a hosted model. Patient names and conditions become tokens before the request leaves, and the real values return only inside your environment. Without this step, personally identifiable information (PII) reaches an external system, which risks breach and compliance violations.

Scanning model output for leaked context

The same scan runs on the way back. A model might echo sensitive information from its training data, or leak context from another tenant's data. Scanning both directions covers prompts and responses. This is data-loss prevention (DLP) applied to the prompt path.

It resembles log scrubbing and field-level encryption at a trust boundary, with one difference. The payload is unstructured free text, so detection relies on probabilistic NER instead of a column mask. Recall does not reach 100%, and false negatives occur.

Detection misses some PII Treat redaction as a control that reduces exposure. It does not guarantee that no sensitive text gets through.

Why a provider's no-training policy leaves gaps

Trusting the provider's no-training policy overlooks data residency, subprocessor exposure, and sensitive text in your own logs. Tokenization keeps raw PII under your control whatever the provider does, which supports data-protection obligations such as GDPR.

Where egress protection matters most

  • Hosted API with regulated data such as health records, financial information or personal data of EU residents: redact and tokenize before sending.
  • Self-hosted model inside your VPC: egress protection is less urgent because the data stays in your environment. DLP still matters for logs and for cross-tenant leakage.

Example scenario: regex coverage misses most PII

Suppose a review finds that 85% of PII in prompts was not redacted. The figure is illustrative. A common cause is a pattern for SSNs that is too narrow, or one applied on only some input and output paths.

PII Redaction / Prompt DLPDiagram with these labels, in reading order: High PII Detection Rate; Redaction Algorithm; Failure; Training Data Inaccuracy; Missing Context Analysis; Update Redaction Rules; Enhance Training Dataset; Implement Contextual; Awareness.High PII Detection RateRedaction AlgorithmFailureTraining Data InaccuracyMissing Context AnalysisUpdate Redaction RulesEnhance Training DatasetImplement ContextualAwareness
Diagnosing PII Redaction Failure
  1. Review the regex patterns for coverage and correct configuration.
  2. Search the logs for unmasked PII to see which patterns failed to trigger.
  3. Test alternative pattern sets side by side in a controlled environment.

Updated patterns may add a little processing time, so watch prompt-handling latency and the rate of detected PII in logs.

Back to the knowledge baseRequest an assessment