How do you handle PII in an LLM pipeline end to end?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
Treat PII as something to keep out of every place it doesn't strictly need to be, at every hop. A layered approach:
Detect and redact before the model. Run a PII detector (Microsoft Presidio, cloud DLP, or a NER model) on inputs and replace entities with typed placeholders: John Smith → [PERSON_1], 555-... → [PHONE_1]. Keep a reversible map in your trusted layer so you can re-hydrate placeholders in the final output if the user legitimately needs the real values. This is pseudonymisation - the model reasons over structure without seeing raw identifiers, and if the prompt leaks, there's nothing sensitive in it.
Full worked answer with diagram
Treat PII as something to keep out of every place it doesn't strictly need to be, at every hop. A layered approach:
Detect and redact before the model. Run a PII detector (Microsoft Presidio, cloud DLP, or a NER model) on inputs and replace entities with typed placeholders: John Smith → [PERSON_1], 555-... → [PHONE_1]. Keep a reversible map in your trusted layer so you can re-hydrate placeholders in the final output if the user legitimately needs the real values. This is pseudonymisation - the model reasons over structure without seeing raw identifiers, and if the prompt leaks, there's nothing sensitive in it.
Minimise what you send. Don't dump whole records into context; send the fields the task needs. Data minimisation is both a privacy principle and a token saving.
Protect the logging/observability channel - this is where teams leak most. Redact before writing to logs and traces, or disable prompt capture for sensitive flows. A trace tool storing full prompts is a PII database you didn't mean to build.
Control the vendor channel. Enterprise tiers that don't train on your data; zero-data-retention to remove the abuse-monitoring window; a DPA (and a BAA for health data). For strict requirements, deploy in your VPC (Bedrock, Azure OpenAI, Vertex) or run open weights on-prem so data never leaves your boundary.
Isolate tenants. Separate vector-index namespaces, ACL filters applied at query time, no shared cache across tenants, per-tenant encryption keys where required.
Support deletion. GDPR/CCPA require erasure - easy for RAG (drop the document, re-index) but effectively impossible if PII is baked into fine-tuned weights, which is a strong argument against fine-tuning on raw PII.
The framing interviewers want: privacy is a data-flow property, so put a control on every edge where data crosses a trust boundary - not a single scrubber at the front door.
Worth sketching. Showing where the token map lives answers the rehydration follow-up before it is asked.
flowchart LR
A["Raw input with PII"] --> B["Detector"]
B --> C["Placeholders: PERSON_1, PHONE_1"]
B --> D["Token map, stays in your trusted layer"]
C --> E["Model or vendor API"]
E --> F["Answer still in placeholders"]
F --> G["Rehydrate from the map"]
G --> H["User"]
C --> L["Logs and traces only ever see placeholders"]
What a good answer covers
- Treat PII as something to keep out of every place it doesn't strictly need to be, at every hop
- Detect and redact before the model
- Run a PII detector (Microsoft Presidio, cloud DLP, or a NER model) on inputs and replace entities with…
- Keep a reversible map in your trusted layer so you can re-hydrate placeholders in the final output if…
- This is pseudonymisation - the model reasons over structure without seeing raw identifiers, and if the…
Key terms: reversible map · pseudonymisation · Minimise what you send · Protect the logging/observability channel · Control the vendor channel · zero-data-retention · VPC · Isolate tenants · Support deletion
In the glossary: Observability · RAG · Fine-tuning
Interviewer follow-ups to expect
How do you re-insert the real names into the model's answer after redaction?
Why is fine-tuning on PII a deletion nightmare?
Which is the channel teams most often forget to redact?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep