# PII, Data Privacy and Compliance

> Handle personal and confidential data responsibly across prompts, logs, vector stores and third-party model providers. Free notes, key concepts, resources and...

Canonical: https://www.internhack.in/roadmaps/tracks/ai-engineer/pii-data-privacy
Last updated: 2026-11-28

Handle personal and confidential data responsibly across prompts, logs, vector stores and third-party model providers.

Intermediate · about 4 hours · difficulty 3/5

Learn first: [Tracing and LLM Observability](https://www.internhack.in/roadmaps/tracks/ai-engineer/tracing-observability)

Every prompt you send to a hosted model leaves your infrastructure, and every trace you log stores user data. Privacy has to be designed in from the start.

### Know your data flows

Map where data goes: user input, retrieved documents, the model provider, your logs and traces, your vector database, fine-tuning datasets and analytics. Each is a place data can leak or be retained too long.

### Practical controls

- **Provider terms**: check data retention, whether data is used for training (business APIs generally are not by default), zero data retention options, and data residency regions.
- **Minimization**: send only the fields the model needs. Do not paste an entire customer record to answer a shipping question.
- **Redaction and pseudonymization**: detect PII (names, emails, phone numbers, ids) with tools like Microsoft Presidio and replace it with placeholders before logging or before sending when feasible.
- **Access control in RAG**: filter retrieved documents by the requesting user's permissions. A vector store with no ACLs will happily leak HR documents to everyone.
- **Retention and deletion**: set expiry on traces and memories, and support user deletion requests across every store, including embeddings.

### Regulation

Know the basics of GDPR and similar laws (lawful basis, data subject rights), sector rules like HIPAA for health data, and emerging AI regulation such as the EU AI Act, which classifies systems by risk.

### Good enough to move on

You can draw the data flow of your app, point to where PII is redacted, show that retrieval respects document permissions, and explain what your model provider retains.

## Key concepts

- **Mapping data flows**
- **Provider retention and training terms**
- **Data minimization**
- **PII detection and redaction**
- **Permission-aware retrieval**
- **Retention and deletion**
- **GDPR, HIPAA and the EU AI Act**

## Mini project

Add a redaction step with Presidio that masks emails, phone numbers and names before logging traces, and add per-user document permissions to your RAG retrieval with a test proving another user's documents never appear.

## Check yourself

A user asks you to delete their data. List every place in a RAG chatbot where that data might live.

## Free resources

- [Microsoft Presidio](https://microsoft.github.io/presidio/) (Microsoft)
- [Anthropic privacy center](https://privacy.anthropic.com/) (Anthropic)
- [OpenAI: enterprise privacy](https://openai.com/enterprise-privacy/) (OpenAI)

Previous: [Jailbreaks and Red Teaming](https://www.internhack.in/roadmaps/tracks/ai-engineer/jailbreaks-red-teaming) · Next: [Guardrails and Content Moderation](https://www.internhack.in/roadmaps/tracks/ai-engineer/guardrails-moderation)

## More in Safety, Security and Responsible AI

- [Prompt Injection and Defensive Design](https://www.internhack.in/roadmaps/tracks/ai-engineer/prompt-injection)
- [Jailbreaks and Red Teaming](https://www.internhack.in/roadmaps/tracks/ai-engineer/jailbreaks-red-teaming)
- [PII, Data Privacy and Compliance](https://www.internhack.in/roadmaps/tracks/ai-engineer/pii-data-privacy)
- [Guardrails and Content Moderation](https://www.internhack.in/roadmaps/tracks/ai-engineer/guardrails-moderation)
- [Bias, Hallucination and Responsible AI](https://www.internhack.in/roadmaps/tracks/ai-engineer/responsible-ai)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [AI Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/ai-engineer)
