Handling sensitive data and personally identifiable information (PII) in an AI workflow comes down to three controls: classify data before it enters the pipeline, de-identify it before it reaches a model, developer, or log, and define in policy which data may be used for training versus inference. AWS Prescriptive Guidance states the underlying principle directly — avoid exposing confidential data — and warns that sending raw customer data in prompts to a third-party LLM API can violate policy or regulation. Google’s production-AI codelab implements the same idea as an automated pipeline that inspects, classifies, and de-identifies PII across unstructured text, structured tables, and images.
This guide is for practitioners wiring models into real systems — a support assistant, a retrieval index, a WordPress automation, or a local model on their own hardware — who need a defensible way to keep regulated data out of places it should not reach.
What counts as sensitive data in an AI workflow
PII reaches AI systems in at least three shapes, and each needs different handling: unstructured text such as support chat logs and feedback forms, structured datasets such as CSVs, and text embedded in images such as scanned documents or user photos. Google’s codelab names exactly these three as the risks its de-identification pipeline is built to mitigate, because a single redaction method does not work across all of them.
The regulatory framing matters because it determines what “sensitive” means for your project. AWS Prescriptive Guidance cites GDPR, CCPA, and HIPAA as the kinds of privacy regimes that generative AI systems raise flags under, precisely because those systems ingest internal documents and personal data in user prompts. In practice, the sensitive set is usually broader than the regulated set: internal pricing, unreleased roadmaps, credentials pasted into a prompt, and customer identifiers all deserve the same handling even when no specific law names them.
Why AI pipelines widen the exposure surface
A conventional database has a small, known set of readers. An AI pipeline multiplies the places a record can be copied: prompt payloads, provider-side logs, fine-tuning corpora, embedding indexes, evaluation sets, tool-call traces, and agent memory. AWS notes that introducing generative AI into enterprise workflows brings new security risks across the data lifecycle, and that protecting the data, the outputs, and the model itself are all part of the job.
AWS also separates AI-specific risks from ordinary data risk. Alongside privacy and governance, it lists model hallucinations and output integrity, data poisoning attacks, adversarial inputs and prompt attacks, and model inversion attacks. These are not all solved by redaction. Poisoning is a training-data integrity problem, prompt attacks are an input-validation and privilege problem, and model inversion is a reason to be careful about what a model is ever allowed to learn.
A control model for the pipeline
The following sequence keeps the controls in dependency order: nothing downstream works if classification is wrong.
1. Inventory and classify before you process
List every place data enters and leaves the workflow, then classify it. Google’s approach uses inspection templates that detect specific sensitive information types, called infoTypes, so classification becomes a configured, repeatable step rather than an ad hoc judgement.
2. De-identify at the boundary, not at the end
Redact before data reaches a model, a developer, or a log. Google’s codelab describes the goal as establishing a workflow that identifies sensitive information and de-identifies it before making it available to developers and models — the ordering is the point.
3. Separate training data from inference data in policy
AWS recommends strong data governance policies that define which data can be used for model training and which can be used for inference. Those are different questions with different risk profiles, and answering them in writing prevents the common drift where a prompt log quietly becomes a training set.
4. Control egress to third-party models
If a prompt leaves your infrastructure, assume it is retained somewhere. AWS’s guidance to avoid exposing confidential data is most concrete here: raw customer data in a prompt to a third-party LLM API can breach policy or regulation, so the egress path needs its own filter rather than relying on the provider’s terms.
5. Treat logs, indexes, and evaluation sets as data stores
Anything that persists a copy inherits the sensitivity of the original. That includes vector indexes built from internal documents and the transcripts an automation platform stores for debugging.
6. Review agentic workflows separately
AWS devotes a distinct topic to data security considerations for agentic AI, which is a signal that tool-using systems need their own review: an agent that can query a database, send email, or call an API has a different blast radius than a chat completion.
De-identification techniques that keep data useful
Removing data is easy; removing it while keeping the dataset usable for tuning and testing is the actual constraint. Google’s codelab documents four techniques that address that tradeoff:
- Replacement with the infoType. Sensitive values are replaced by their detected category, which removes the exposure while preserving the surrounding context.
- Record transformations. Identifiers such as names are selectively redacted in structured data so the rest of the record survives.
- Character masking. Part of a string is masked while other characters are preserved, so a developer can still test with realistic-shaped values.
- Image-specific templates. Text found inside images is redacted, which handles scanned documents and user photos that text-only pipelines miss.
The codelab’s operational insight is that these should be applied by a single automated job that selects the correct de-identification template based on the file type it processes. Manual redaction across formats is described as inconsistent and error-prone, which matches most teams’ experience.
The table below illustrates the techniques; it is not a record of a specific test run. Exact output depends on how the template is configured.
| Input (illustrative) | Technique | Effect |
|---|---|---|
| Support note containing a phone number | Replacement with infoType | The number is replaced by its infoType label; the sentence structure remains |
| CSV row with a customer name and email | Record transformation | The name is redacted while other fields stay testable |
| Account identifier in a log line | Character masking | Some characters are masked and others preserved |
| Scanned invoice image | Image de-identification template | Text detected inside the image is redacted |
Where local models change the decision
Running a model locally is a data-boundary decision, not a compliance shortcut. Keeping inference on hardware you control removes the third-party prompt egress path that AWS warns about, which is a real reduction in exposure. It does not remove the other copies: local prompt logs, chat history files, backups, vector indexes, and any telemetry a front-end sends. The governance question — which data may be used for training versus inference — still applies, and in a local setup you are the only party who can answer it.
For teams in this position, the practical pattern is to apply the same classify-then-de-identify sequence at the ingestion point, and to treat the local model as one more consumer of already-sanitized data rather than as a trusted sink.
WordPress and automation touchpoints
Content sites and automation stacks accumulate PII quickly and quietly. Contact forms, comment moderation queues, chat widgets, order metadata, and webhook payloads all carry names, addresses, and free-text messages. When those payloads are forwarded to an external AI API for summarization, classification, or reply drafting, the site becomes the egress point.
Two controls cover most of the risk. First, de-identify or minimize the payload before the outbound request, so the API receives only what the task requires. Second, shorten retention for the intermediate copies — the automation platform’s run history and any plugin log — because those are frequently the least governed store in the stack.
Limitations and tradeoffs
De-identification reduces risk; it does not make data anonymous. Quasi-identifiers can re-identify records when combined, and detection is imperfect for free text and images. Aggressive redaction also destroys the context a model needs, which is why Google’s techniques are designed around preserving utility rather than deleting everything.
Two further limits are worth stating plainly. First, no single tool satisfies a compliance obligation; AWS frames the work as spanning privacy, governance, and AI-specific risks, which means policy, access control, and review are part of the answer. Second, model inversion and prompt attacks are not solved by redaction alone, so how much sensitive data a model is allowed to learn from should be a deliberate decision rather than a default.
How to verify de-identification actually worked
- Build a small test set of synthetic records containing each infoType you expect to encounter.
- Run it through the same automated job that processes production files.
- Inspect the output for the detected category labels and confirm the surrounding context survived.
- Check the downstream stores — logs, indexes, run history — not just the immediate output.
- Re-run the check whenever a template or file type changes, because a template that works for text may not cover an image.
If a step fails, the usual cause is that a file type is falling through to a default template rather than a missing detector.
Next step
Pick one pipeline that touches customer data and trace it end to end: where it enters, where it is copied, and where it leaves your control. Classify those points, apply a de-identification template at the earliest boundary, and confirm what the third-party endpoint or local log actually receives. That single pass usually reveals more than a policy document written in advance.
If you try this on a specific stack — a WordPress form handler, a local RAG index, or an agent with tool access — share the environment and what the sanitized output looked like in the community so others can compare templates.
FAQ
Does running a model locally remove my PII obligations?
No. Local inference removes the third-party prompt egress path, which reduces exposure, but copies still accumulate in prompt logs, chat history, backups, and vector indexes. AWS frames the governance question as which data may be used for training versus inference, and that question applies regardless of where the model runs.
Is redacting names enough to make a dataset anonymous?
Not reliably. Quasi-identifiers can re-identify records when combined, and detection is imperfect for free text and images. Google's techniques — infoType replacement, record transformations, character masking, and image templates — are designed to reduce exposure while preserving utility, not to guarantee anonymity.
Why use one automated job instead of redacting each file manually?
Google's codelab describes manual redaction across different data types as inconsistent and error-prone. A single automated job that applies the correct template based on file type keeps the same policy applied to text, tables, and images.
What should I check first if sanitized output still contains sensitive values?
Check whether that file type is falling through to a default template rather than a template built for it. Image content in particular needs an image-specific template, because text-only detection will not catch it.