Privacy by Design and Default Questions
Designing privacy into products, architectures and the software development lifecycle instead of bolting it on afterward. Covers the privacy-by-design principles and privacy-protective defaults, data minimization and purpose limitation at design time, personal-data flow mapping and PII inventory for a feature, consent and preference design including consent storage, enforcement across web and mobile and region-specific consent flows, retention and deletion design including legal holds, deletion across backups and immutable logs, provable deletion, and data-subject access, export and erasure flows, PII-safe logging, telemetry and session replay, on-device processing to limit data exposure, privacy-versus-personalization trade-offs, privacy in ML training data, feature stores and erasure from trained models, and privacy review gates, checklists, CI/CD checks, release readiness and requirements traceability inside engineering workflows. Includes designing privacy-first features, reference architectures, remediating privacy design flaws and rollout programs across product teams, and working with product, legal and security partners. Cryptographic and statistical privacy techniques, formal impact assessments, data-protection law, cross-border transfer rules, vendor risk, and encryption or access-control mechanics are covered elsewhere.
Your org has a privacy checklist and review gate, yet teams still ship privacy bugs because compliance is something done at the end. How would you embed privacy into how an ML or product team works day to day so it stops being a separate checklist?
Sample Answer
Direct answer. The checklist fails because it is a late, separate, binary step owned by someone else, so teams optimize for passing it. I would move privacy into the existing workflow: design docs, tickets, code review, pipelines and retrospectives, and let the review gate become a small escalation path for genuinely new risk rather than the main control.
What is wrong with the current setup (the critique)
- Review at the end finds problems after the architecture and data model are fixed, so fixes are expensive and get waived.
- A checklist asks "did you do privacy?" instead of "which personal data does this feature touch and why?".
- Nobody on the team owns the answer, so privacy bugs are the review team's problem.
What I would change, in order
- Start from the bugs. Classify the last few quarters of shipped privacy bugs (for example PII in logs, features trained on data without a purpose check, missing deletion path). Build the first changes around the top classes, so the effort answers a real pain.
- Put the questions in the design doc template. A short section: what personal data, what purpose, retention, who can access, what happens on user deletion or consent withdrawal. A design is not review-ready with it blank. For ML, add: training data sources, whether labels or outputs are personal data.
- Add to the definition of done. Stories touching personal data carry acceptance criteria (for example "event schema tagged with data classification", "deletion path tested"), reviewed like any other criterion.
- Automate the repeatable. Pipeline checks for PII in logs and untagged schema changes catch the common mistakes at pull request time, so humans spend time on judgement.
- Name a privacy champion per team (an engineer with a few hours a week, not a new role), trained by the privacy team, who is the first reviewer and escalates only new patterns.
- Close the loop. Every privacy bug gets a blameless retrospective and a new automated check or template question.
Reasoning on ownership. The engineering manager owns the outcome, the privacy team owns the standard and the tooling, and the gate owns only escalations such as a new sensitive data category.
Measures. Privacy bugs found before merge versus after release, time from first design doc to privacy sign-off, and share of designs that arrive with the section filled in.
What would change my call. If most bugs come from one shared platform, fix it there instead of training every team.
You lead a product that trains ML models on user data. Define a product strategy to manage training data lifecycle: labeling, retention, deletion on user request, auditing datasets for leaked PII, and versioning models so deletion requests are honored. Include trade-offs.
Sample Answer
Direct answer. Treat training data as a governed asset with a lifecycle: collect only what the model needs, label it with provenance, retain it for a defined period, honor deletion by removing it from datasets and scheduling retraining, and keep manifests so you can show which model was trained on which data. Be honest that removing a person's data from a trained model is hard: a model stores what it learned as numbers (weights) spread across the whole model, not as rows you can look up, so deleting the training row does not remove its influence. There is no cheap, reliable way yet to subtract one person from the weights, so the strategy relies on retraining cadence and on avoiding personal data in training where possible.
Lifecycle stages.
- Collection and consent: record the purpose and lawful basis (the legal ground for using the data; a question for counsel) at ingestion. Exclude users who opted out of training use. Collect fewer fields: drop or tokenize direct identifiers before they reach the training store.
- Labeling: labelers see the minimum, through access-controlled tools; vendors are bound by contract; labels link to records by pseudonymous ID, not names.
- Storage and retention: the raw store, the processed features and the training snapshots each have a retention class. Raw data expires sooner than the derived snapshots only if the derived ones no longer identify anyone.
- Dataset manifests: every training run records a manifest: the list of record IDs (pseudonymous), schema and filter version, and code commit, plus a hash of the list. This gives auditable reproducibility and lets you answer "was this user's data in model v7?" by looking the ID up in the stored list, without keeping the underlying data forever. The hash alone cannot answer membership; it only proves the stored list has not been altered since training. An illustrative entry:
{model: "v7", trained: "2026-04-12", snapshot: "snap-0412", id_list_hash: "5b1e...", filter_version: "f19", code_commit: "a3c91e7"}, where the hash is a short fingerprint that changes if any listed ID changes (the full ID list sits in the manifest store undersnap-0412). - PII audit: scan datasets before training for emails, phone numbers, ID numbers and secrets using detectors plus sampled human review; block runs that fail; scan model outputs for memorized personal data in evaluation (a model can sometimes reproduce rare training text, such as an email address, word for word).
- Deletion on request: delete the user's rows from raw data, features and snapshots using the manifest index. Persisted artifacts such as embeddings (lists of numbers that represent a text or user so models can compare them), cached features and fine-tuned weights (the model's adjustable numbers after extra training on your data) are tracked as derived data too: delete derived features directly; for weights, record the request and remove the user in the next scheduled retrain.
- Model versioning: each model version links to its manifest; versions older than a defined age are retired so no stale model keeps data in it indefinitely.
Deletion-aware retraining cadence. Choose a cadence (for example, retrain quarterly and always before a model is relaunched) where each retrain excludes everyone who has deleted or opted out. In between, apply an output-side suppression filter (a check that stops the model from returning data about people on the pending-deletion list) and keep that list. Whether an interim lag is acceptable is a legal and risk decision, and you state the maximum lag to users.
| Option | Benefit | Cost |
|---|---|---|
| Frequent full retrain | Strongest deletion story | Compute cost, regression risk |
| Periodic retrain plus suppression | Lower cost | Deleted data influences the model until next retrain |
| Sharded training (train by data slice, retrain only the affected slice) | Cheaper deletions | More engineering, possible accuracy loss |
| Train on de-identified or synthetic data | Fewer deletion obligations | Utility loss; de-identification must be shown to hold |
In practice the usual default is periodic retrain plus suppression; the other rows apply when the deletion lag or the cost is unacceptable. Sharded training example: split users into 10 slices, each with its own sub-model, combined when serving; a deletion from slice 4 retrains only slice 4, about one tenth of the compute of a full retrain.
Worked example. A model is trained on 10 million user records. Over a quarter, 4,000 users request deletion (0.04%). The manifest finds their IDs, the next scheduled retrain excludes them, and the old model version is retired 30 days after rollout, so no model trained with them stays in production beyond about one retrain cycle plus 30 days. Numbers are illustrative.
Trade-offs. Faster deletion costs compute and may hurt model quality; stronger minimization may lower accuracy. As product lead, I would set the cadence with legal, publish the lag, and measure it.
A user exercises their right to be forgotten, but their data has already shaped trained models and derived features. How would you handle this, when is retraining actually necessary, and what would you tell the user and the regulator?
Sample Answer
Direct answer
Treat the request in two layers. First, delete the person's data everywhere it is stored as data: source tables, feature stores, training snapshots, caches and exports. Second, decide model by model whether the trained artifact still holds the person's information. Retraining is necessary only when it does, or when you cannot show that it does not. I would tell the user exactly what was deleted and what happens to models by a stated date, and the regulator only what a complaint or inquiry asks for, with counsel (the company's lawyers) deciding the legal position.
Step 1: Map what the person touched
| Layer | Example | Action |
|---|---|---|
| Source records | orders, chat logs | delete (GDPR Art. 17, the right to erasure) |
| Derived features (stored in a feature store, the shared service that holds model inputs) | "avg basket size", embeddings | delete or recompute without the person |
| Training snapshots | frozen parquet files (a columnar file format common for training data) | delete the rows, keep a deletion ledger |
| Trained models | churn model v7 | assess, then retrain, retire or keep |
| Backups | nightly copy | let expire on schedule, block restores from reintroducing the data |
A deletion ledger is a list of person IDs that every training job reads and excludes from its input. It stops the data coming back at the next run. Store the IDs hashed (run through a one-way scramble, with a secret key added so common IDs cannot be guessed) so the ledger itself does not become a list of people to leak; hashed IDs are still pseudonymous, which is acceptable for a list that exists only to enforce exclusion.
Pseudonymizing (swapping names for IDs while a key exists elsewhere) is not erasure: the data is still personal data. Only truly irreversible anonymization removes it, and that is hard to prove.
Step 2: When is retraining actually necessary?
Ask whether the model could reveal or reproduce this person's data.
- Low risk, no immediate retrain: a model trained on millions of rows with simple features (for example a gradient-boosted churn model, which combines many small decision trees and learns general patterns rather than storing rows) where one person has a negligible influence and the model outputs only a score. Exclude them via the ledger at the next scheduled retrain and record the date.
- High risk, retrain or retire promptly: a model that stores records (a nearest-neighbour lookup keeps the training records and returns the closest ones; an embedding index holds numeric fingerprints of text or items that can be mapped back to them), a fine-tuned language model that can regurgitate text, or a small model where the person is a large share of the data. Test with a membership-inference check (can an attacker tell whether a record was in the training set? Example: show the model 1,000 records it trained on and 1,000 it never saw, and let the attacker guess which is which. Guessing right 1,030 times out of 2,000 is 51.5%, close to the 50% of a coin flip, so no meaningful leakage; 90% would mean the model gives records away) and a probe for memorized strings. If the test cannot clear it, retrain without the person or roll back to a model trained before their data.
- Cost trade-off: a retrain costing days of compute can be batched into the normal cadence if risk is low. Machine-unlearning research methods (techniques that try to remove one person's influence from a trained model without retraining it) exist but are not settled enough to be your only defence.
Step 3: What to tell whom
- User: within one month of the request (Art. 12(3) sets one month, extendable by two further months for complex or numerous requests, with the person told of the extension and the reason within the first month): confirm deletion from systems, say that models will exclude them from the next training run by a date, and name any retained data with the legal reason (Art. 17(3) lists the exceptions to erasure, such as a legal obligation to keep invoices or the need to defend legal claims).
- Regulator: erasure requests are not themselves reported. If the user complains, show the record: ledger entry, model risk assessment, dates. Do not claim "the model forgot you" unless you tested it. Wording and any contested position go through counsel and the data protection officer (DPO, the person some organisations must appoint to advise on and monitor GDPR compliance).
- Recipients: tell processors (vendors that handle data on your behalf) and partners who received the data unless impossible or disproportionate effort (Art. 19).
Worked example
A support-ticket classifier is trained monthly on 2 million rows. A user asks for erasure on day 3. You delete their 14 tickets and features by day 5, add them to the ledger, and the day-30 training run excludes them. A membership check on the live model shows no leakage above chance, so you keep it until then and record that. If the same data had fine-tuned a model that quotes tickets, you retire it now.
Your support team wants to use free-text customer chat transcripts for analytics and model training. The text contains names, account numbers and occasionally health details. What would you require before this data is used, and what processing design makes it safe enough?
Sample Answer
Direct answer
I would not allow raw transcripts into analytics or training. I would require a documented purpose and legal basis (under GDPR you need one of a short list of lawful reasons, such as consent or legitimate interests, before processing personal data), a risk assessment, a redaction pipeline that runs before any data scientist sees text, separated access, and a retention limit. Health details are special-category data (types of personal data that GDPR protects more strictly, such as health, beliefs and biometrics) under GDPR Art. 9, so they get the strictest treatment, and if reliable redaction is not possible for a use, I would refuse that use.
What I would require first
- Purpose and lawful basis. "Improve support" is too vague. Name each use (for example topic analytics, and a model that suggests replies). Customers were told the chat was for support, so using it for model training may be a new purpose that needs its own basis, notice or opt-out. Counsel decides the basis.
- An extra condition for the health content. Special-category data needs an Art. 9(2) condition (such as explicit consent) on top of the ordinary lawful basis, and legitimate interests alone does not cover it. This is another reason to strip health text before any use.
- A DPIA (data protection impact assessment), a structured risk review, because this is large-scale, sensitive, and new technology.
- Owner and sign-off from the data owner and privacy lead before any copy is made.
Processing design
- Detect. Combine pattern rules for account numbers and emails, a named-entity model (software trained to spot names of people, places and organisations in free text) for names, and a keyword or classifier layer for health terms. Measure recall (the share of the sensitive items that really exist which the detector catches) on a hand-labelled sample, since a missed entity is a leak, and accept that no detector is perfect.
- Redact or replace. Swap with typed placeholders (for example [NAME], [ACCOUNT]) or consistent fake tokens (the same fake name each time the same real name appears, so a reader can follow who said what) so conversation structure survives. Before: "Hi, I'm Priya Nair, account 48213, my diabetes medication was refused." After: "Hi, I'm [NAME], account [ACCOUNT], my [HEALTH] was refused." Drop whole transcripts that contain health content if the use does not need them.
- Separate. Raw transcripts stay in a restricted store with a few named readers. The redacted copy goes to the analytics zone. Any re-link key (the table that maps a fake token back to the real value) lives elsewhere with its own access.
- Retain briefly. Keep raw text only as long as the redaction pipeline needs, and delete the redacted copy when the model and analysis no longer need it. Add deletion-request handling so a customer's transcripts can be located by ID.
- Guard the model. A model trained on residual text can memorize it, so test generations for leaked names and numbers before release, and keep the training run's data version recorded.
Worked example
On a sample of hand-labelled transcripts containing 500 sensitive spans in total, say the detector finds 460 of the 500 (92% recall). The 8% left (40 spans) would flow into training. That is too many for health content, so I would add a second pass or exclude those transcripts, and only proceed when a re-measured sample meets a bar the privacy lead signs. An illustrative bar for health content is 99% or better, and the sample must be big enough to show it: if a fresh sample of 500 spans has zero misses, the 95% upper limit on the miss rate is still about 3/500 = 0.6%, so recall of roughly 99.4% or better is supported. A 92% result is nowhere near it.
When to refuse
Refuse if consent or basis cannot cover the use, if health data is essential to the text and cannot be removed, or if the team cannot show redaction quality.
You are adding a prediction or personalization feature that trains on customer data. How do you build privacy in at the design stage, and where do you draw the line on what the model is allowed to see and keep?
Sample Answer
Direct answer
Decide at design time what data the model is allowed to learn from and keep, before any training run. Privacy goes in by minimizing the training data (fewest fields and rows that deliver the quality), limiting the purpose and retention, and controlling what the trained model and its outputs can reveal. The line I draw: the model may see features that plausibly predict the target and that users would expect to be used; it may not see direct identifiers or sensitive categories without a stated need and permission, and it does not keep raw customer data past the training and evaluation window.
Design steps
- State the purpose and the prediction (for example, predict which customers will cancel).
- Feature review: for each candidate feature ask if it improves the prediction and if the customer would expect it to be used. Drop direct identifiers (name, email); replace the customer ID with a pseudonymous key (a random token that stands in for the ID, with the lookup table that maps it back kept separately and locked down); coarsen others (age band, not birth date).
- Sensitive attributes: exclude health, precise location and similar data unless there is a clear need and consent, and check whether proxies reintroduce them. A proxy is an innocent-looking feature that stands in for a sensitive one: a postcode can reveal ethnicity or income, and a purchase history of specific products can reveal a health condition. To check, test how well the candidate feature predicts the sensitive attribute on a labelled sample, and drop or coarsen it if it predicts it well.
- Data lifecycle: training data lives in a controlled environment with limited access; raw snapshots are deleted after a set window while the minimal feature table stays; logs of predictions are retained on a schedule.
- Model risk: models can memorize rare records (a model trained on support tickets may repeat one customer's unusual complaint, with their details, when prompted the right way), so avoid training on free text without redaction, test whether the model reproduces training examples, and treat the model and its prediction logs as data that may need deletion handling when a customer asks for deletion.
- Serving: return the prediction a feature needs (a score), not the underlying customer attributes. On-device inference (running the model on the user's phone or laptop so the raw data never leaves it) is one option when the model is small enough and the data is on the device; privacy-preserving training techniques are a further option at a cost in accuracy and engineering effort: differential privacy (adding calibrated noise during training so no single record changes the model much) and federated learning (training across many devices so raw data is not centralized).
Worked example: churn model
Start with a feature trace. Illustrative candidate features for the cancellation model, and the decision for each:
| Candidate feature | Decision | Reason |
|---|---|---|
| Name, email | Drop | Direct identifiers add nothing to the prediction |
| Customer ID | Replace with pseudonymous key | Needed only to join tables during training |
| Birth date | Coarsen to age band | The band usually predicts about as well (check on a holdout set) |
| Logins in last 30 days, days since last login | Keep | Predictive and customers expect usage to be analysed |
| Postcode | Drop or coarsen to region | Likely proxy for income or ethnicity |
| Free-text support tickets | Exclude unless redacted | Can contain names and health details, and can be memorized |
| Precise GPS location | Drop | Sensitive, with no stated need |
Three privacy principles sit behind those decisions, and I would prioritize them in this order:
- Data minimization: fewer features reduce exposure and often cost little accuracy; in churn models usage frequency and recency are commonly strong predictors, but confirm by comparing holdout accuracy with and without each dropped feature.
- Purpose limitation: the data is approved for retention prediction, so reusing it to target ads needs a new decision.
- Privacy by default for outputs: scores are visible only to the retention team, and the customer-level table is access-controlled.
Retaining data for model improvement
Teams want to keep data to retrain. Controls: keep a minimized, pseudonymized feature table instead of raw records, set a retention period tied to model refresh cycles, honour deletion by removing the customer from the next retrain, and document who may use the table. Prioritise the controls by benefit and complexity:
| Control | Privacy benefit | Complexity | Priority |
|---|---|---|---|
| Drop direct identifiers, coarsen fields | High | Low | First |
| Retention limit on raw snapshots | High | Low to medium | First |
| Access control and purpose tags on the dataset | Medium to high | Medium | Second |
| Deletion handling in retraining pipeline | Medium | Medium to high | Second |
| On-device inference | Varies | High | Case by case |
Pitfalls
Assuming a model is not personal data because it has no names in it; training on raw support text; and forgetting that deleting a customer from the database does not remove their influence from an already trained model, so state the policy (retrain on the schedule without them) in advance.
Unlock Full Question Bank
Get access to all 10 Privacy by Design and Default interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.