AI ENGINEERING · LLMS IN PRODUCTION · SAFETY · 35 OF 35

Privacy and Compliance for LLM Applications

What data reaches a model provider and what it may keep, data minimisation and a worked masking example, secrets out of prompts and logs, per-user isolation in RAG and memory, data residency, deletion that reaches embeddings, caches and logs, consent, audit logs, GDPR-style laws, the EU AI Act risk tiers and India's DPDP Act, a vendor checklist and an engineering checklist.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
1 / 19

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Map the data
  • send less
  • mask
  • no secrets
  • filter per user
  • pin regions
  • delete everywhere
  • tell users
  • audit

Notes

The idea

Start with the flow. A user types a message into your app. Your app wraps it in a system prompt, adds retrieved documents and tool results, maybe a file, and sends the lot to a model provider. All of that leaves your boundary. The user typed one sentence, but the prompt might hold their address and order history. Privacy work starts by knowing exactly what is in each prompt.

What leaves your boundary
  • the user's message
  • system prompt and examples
  • retrieved documents
  • tool results (orders, CRM)
  • uploaded files and images
  • metadata: user id, IP
  • every one may hold personal
  • data you are responsible for

What they may keep

So what does the provider keep? Three questions. How long are inputs and outputs retained, and why? Often around thirty days for abuse monitoring. Are they used to train future models? Business API terms usually say no by default, while consumer chat apps often train unless you opt out. Is zero data retention available? Many providers offer it by agreement. And watch stored features like uploaded files or saved threads, which keep data until you delete them.

Questions for the provider
  • retention: how long are inputs and outputs kept? why? (often ~30 days, abuse checks)
  • training: used to train models? business APIs: usually no consumer apps: often opt-out zero retention: available by agreement for some endpoints
  • stored features: files, threads, batch jobs keep data longer

Minimise, then mask

First, minimise. For every field, ask whether the model needs it. A ticket summariser needs the complaint, not the phone number. Then mask what is left. Here, three items are found: a name, an email and a phone number. Each becomes a placeholder, and the mapping stays in your app for this one call. The order number stays, because the model needs it. When the reply says name one, you swap the real name back in.

A worked mask
in:  I am Priya Shah, priya@mail.com,
     +91 98200 12345. Order 7781 lost.
out: I am [NAME_1], [EMAIL_1],
     [PHONE_1]. Order 7781 lost.

map, kept in your app for this call:
  NAME_1  → Priya Shah
  EMAIL_1 → priya@mail.com
  PHONE_1 → +91 98200 12345
reply:   Sorry [NAME_1], ...
restore: Sorry Priya Shah, ...

Secrets

Secrets are a separate problem. Never put an API key, a database password or an access token in a prompt. Anything in the context can be repeated back, logged by someone, or pulled out by a prompt injection. Instead, the model asks for a tool, and your tool code fetches the credential from a vault at run time. Scan logs for secret patterns, and if a key leaks, rotate it. Deleting the log line is not enough.

Keep secrets out
  • no API keys, passwords or tokens in prompts: anything in context can be repeated
  • tools fetch credentials from the vault at run time
  • scan prompts, outputs and logs for secret patterns
  • a leaked key gets rotated, not just deleted from logs

Logs and caches

Your own systems are often the bigger leak. One prompt gets copied into traces, error trackers, analytics, a response cache, and later into eval sets and fine tuning data. Each copy needs rules. Redact before writing, set an expiry measured in days, and limit who can read it. Watch semantic caches especially. If the cache key ignores the user, one customer can get an answer built from another customer's data.

Where prompts get copied
  • traces and debug logs
  • error trackers and analytics
  • response and semantic caches
  • eval sets and fine-tune data
  • rules for every copy:
  • redact before writing
  • expiry (days, not forever)
  • access by role, not everyone
  • cache keys include the user

Keep users apart

Retrieval is where data most often crosses between users. Tag every chunk with its tenant, owner and allowed groups. At query time, filter inside the vector search using the identity from the login session, never from the model. A prompt saying only use Alice's documents is not access control, because the model can be talked out of it. Memory works the same way: per user, viewable and deletable by them.

Isolation in RAG + memory
  • tag every chunk: tenant_id, owner, allowed groups
  • filter inside the search, from the session identity
  • never "please only use Alice's docs" in a prompt
  • big tenants: own namespace
  • memory: per user, viewable, deletable by that user

Data residency

Some customers and laws require data to stay in a region. Ask four questions. Where does inference run? Where are logs and uploaded files stored? Where are backups? And who can access the data from abroad, including support staff and sub-processors? Many providers sell regional endpoints. But residency covers every copy, so your vector database, your traces and your caches must sit in the same region too.

Residency questions
  • where does inference run?
  • where are logs and files kept?
  • where are backups?
  • who can access from abroad (support, sub-processors)?
  • many providers sell regional
  • endpoints; check every store, your vector DB and logs too

Right to deletion

When a user asks to be deleted, the request must reach every copy. Here, user forty two has three documents, which became two hundred and twelve vector chunks, plus eighteen cache entries, nine memory facts, traces and two files at the provider. Embeddings count as personal data, because research shows the text can often be largely rebuilt from them. Data baked into a fine tuned model is very hard to remove, so avoid training on it.

A deletion run, user 42
source docs           3 deleted
vector chunks       212 deleted
semantic cache       18 entries
chat memory           9 facts
traces           purged by user id
provider files        2 deleted
backups      expire within 35 days
eval / tune sets  check, then drop

embeddings ARE personal data:
text can be largely rebuilt

Audit logs

An audit log answers a different question from a debug log: who accessed which data, when, and was it allowed? Each record holds the time, the actor, the action, the ids of the data touched, which model and region served it, and the policy decision. Store ids rather than raw prompt text, so the audit log is not itself a new privacy risk. Make it append only and tamper evident.

One audit record
time     2026-03-04T10:22Z
actor    user 42 (support agent)
action   rag.search + summarise
data     ticket 9913, chunks 4
model    frontier, eu region
policy   pii masked, allowed

append-only, tamper-evident,
ids not raw prompt text,
kept as long as policy says

Data protection laws

You do not need to be a lawyer, but know the shape. GDPR style laws, in Europe, the United Kingdom and many other places, ask for a lawful basis, a clear purpose, minimal data, rights to access and erase, an impact assessment for risky processing, and contracts with every processor, including your model provider. India's Digital Personal Data Protection Act asks for clear notice and consent, correction and erasure, breach reporting, and lets the government restrict transfers to certain countries.

The shape of the rules
  • GDPR-style laws (EU, UK, more) lawful basis, purpose limit, minimise, access + erasure, impact assessment if risky, contracts with processors
  • India DPDP Act 2023 clear notice + consent, correction and erasure, breach reporting, transfers can be restricted by country

EU AI Act tiers

The European Union's AI Act regulates by risk. Unacceptable uses, like social scoring, are banned. High risk uses, such as screening job candidates, credit decisions or grading exams, carry strict duties: risk management, data quality, logging and human oversight. Limited risk systems, like chatbots, must tell people they are dealing with AI and label deepfakes. Minimal risk covers most other apps. Model providers have their own duties. The rules phase in over several years.

EU AI Act risk tiers
  • unacceptable: banned e.g. social scoring
  • high risk: strict duties hiring, credit, exams, health risk mgmt, logs, human review
  • limited: transparency say it is AI, label deepfakes
  • minimal: no extra duties most chat and search apps
  • + duties for general-purpose model providers

Vendor review

Before real data flows to any AI vendor, run the same checklist. A signed data processing agreement. A written promise not to train on your data. The retention period and whether zero retention is available. Regions for both compute and storage. The list of sub-processors. Independent security certifications. How quickly they must tell you about a breach. How you delete data on request and when you leave. And encryption in transit and at rest.

Vendor checklist
  • □ data processing agreement
  • □ no training on our data
  • □ retention period, zero- retention option
  • □ regions for compute + storage
  • □ sub-processor list
  • □ security certifications
  • □ breach notice time
  • □ deletion on request + exit
  • □ encryption in transit + rest

Numbers worth knowing

Some numbers to quote, knowing terms change. Provider retention for abuse checks is usually zero to about thirty days, and zero retention is by agreement. Under GDPR, a breach must reach the regulator within seventy two hours, and user requests get an answer within about a month. Maximum fines are four percent of global turnover under GDPR, seven percent under the AI Act, and two hundred and fifty crore rupees under India's law.

Ballparks
provider abuse retention   ~0-30 days
zero retention             by agreement
GDPR breach notice         72 hours
GDPR reply to a request    ~1 month
GDPR max fine        4% turnover/€20M
AI Act max fine      7% turnover/€35M
DPDP max penalty     ₹250 crore
backup expiry              ~30-90 days
regex: strong on emails, cards
names need NER, still misses some

Common mistakes

The common mistakes. Trusting regular expressions to find names. They catch emails and card numbers well, but names and addresses need an entity recogniser, which still misses some. Forgetting that a postcode, birth date and gender together identify most people. Logging full prompts forever. Sharing a cache across users. Putting access rules in the prompt. Deleting database rows but not their vectors. And staff pasting customer data into a consumer chat app.

Mistakes to avoid
  • trusting regex to find names
  • zip + birth date + gender: re-identifies most people
  • full prompts logged forever
  • cache shared across users
  • access rules in the prompt
  • deleting rows, not vectors
  • prod data in eval sets without consent or masking
  • consumer chat app for work

Engineering checklist

Here is the engineering checklist. Draw a data map of every field and every store it lands in. Minimise and mask before sending. Keep secrets in a vault and scan for leaks. Filter retrieval by the signed in user. Redact logs and give them an expiry. Key caches by user or tenant. Pin the region for every copy. Write one deletion job that reaches every store. Show notice and get consent. Keep an audit log, and review every vendor.

Before launch
  • □ data map: every field, store
  • □ minimise + mask before send
  • □ secrets in a vault, scanned
  • □ retrieval filtered per user
  • □ logs redacted, with expiry
  • □ cache keyed by user/tenant
  • □ region pinned for all copies
  • □ one delete job, all stores
  • □ notice, consent, AI label
  • □ audit log + vendor review

Say it like this

How to say it. We mask names, emails and phone numbers before the prompt and restore them in the reply. The provider is under a zero retention agreement, in an EU region, with no training on our data. Retrieval filters by tenant using the session identity, not the model. Logs are redacted and expire in fourteen days. And one deletion job covers vectors, caches, traces and provider files. That shows you followed the data.

In the interview
  • "We mask names, emails and phones before the prompt and restore them after. The provider has zero retention, an EU region and no training. Retrieval filters by tenant from the session. Logs expire in 14 days, and one delete job covers vectors, caches, traces and provider files."

Interview questions

Q1What data does a model provider see, and what might it keep?

Everything in the request: the user message, system prompt, retrieved documents, tool results and files. Depending on the terms it may retain inputs and outputs for a period (often around 30 days for abuse monitoring), and consumer products may train on them; business APIs usually do not, and zero-retention options exist by agreement.

Q2How would you remove personal data from prompts?

First send only the fields the task needs. Then detect personal data with regex for structured values (emails, phones, cards) plus an entity recogniser for names and addresses, replace each with a consistent placeholder like [NAME_1], keep the mapping in your app for that call, and restore the real values in the reply.

Q3How do you stop one user seeing another user's data in a RAG system?

Tag every chunk with tenant, owner and allowed groups and filter inside the vector search using the identity from the authenticated session. Never rely on prompt instructions for access control, and use per-tenant namespaces when isolation must be strong.

Q4Why should API keys never go into a prompt?

Anything in the context can be echoed back, logged or extracted through prompt injection. Tools should fetch credentials from a vault at run time, and prompts, outputs and logs should be scanned for secret patterns, with leaked keys rotated.

Q5What does honouring a deletion request involve in an LLM application?

Deleting the source records and every derived copy: vector chunks, semantic and response caches, chat memory, traces and logs, eval or fine-tuning sets, and files stored at the provider, with backups expiring on a schedule. Embeddings count as personal data because text can often be reconstructed from them.

Q6What is data residency and what does it cover?

A requirement that data stays in a given region. It covers where inference runs and where every copy lives, including logs, files, backups, vector stores and caches, plus who can access the data from abroad, such as support staff and sub-processors.

Q7What are the EU AI Act risk tiers?

Unacceptable risk uses are banned, high-risk uses such as hiring or credit scoring carry strict duties like risk management, logging and human oversight, limited-risk systems such as chatbots must disclose that they are AI, and minimal-risk systems have no extra duties. General-purpose model providers have separate obligations.

Q8What would you check before sending customer data to an AI vendor?

A data processing agreement, no training on your data, the retention period and zero-retention option, compute and storage regions, the sub-processor list, security certifications, breach notification time, deletion on request and at exit, and encryption in transit and at rest.