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.
You're asked to remove a popular personalization feature implemented with on-device ML models because of privacy concerns, but it improves engagement by ~10%. Propose alternative architectures or design changes that preserve value while reducing privacy risk, and outline an evaluation plan to compare them.
Sample Answer
Direct answer. First find out what the privacy concern actually is, because on-device models already keep raw data off the server, so removal may be a heavier fix than the risk needs. Then offer a ladder of designs from least to most change, test them against both engagement and a privacy-risk score, and pick the option that keeps most of the value at the lowest risk. The decision rule is written before the test starts.
Step 1: pin down the concern. Typical causes: the model infers sensitive traits (health, finances), the data is retained too long, a sync to the cloud exists, other apps or people could read the on-device store, or the feature is switched on without a clear choice. Each leads to a different fix, so ask privacy and legal what the specific objection is.
Step 2: alternatives, from least to most change
- Keep the model, shrink the inputs: remove sensitive categories from features, use coarse categories rather than item-level history, shorten the window, add decay (older actions count for less each day, so old history fades instead of accumulating).
- Change the defaults and controls: opt-in or a clear first-run choice, a visible "why this" and a reset button. This addresses consent without touching the model.
- Contextual personalisation: rank by the current session and context (time, screen, query) with no stored history. Usually lowest value, lowest risk.
- Cohort model: the server trains on aggregated groups of similar users (cohorts) and the device picks the closest cohort, so no individual history is stored. Needs a minimum group size so no cohort identifies a person.
- Remove the feature: the baseline for comparison.
Step 3: evaluation plan. Illustrative numbers: engagement without personalisation is 20%, and the feature lifts that by about 10% relative (10% of 20% is 2 points), to 22%. Decision rule: adopt an alternative if it retains at least half the lift. Half of 2 points is 1 point, so the bar is 21%.
- Detecting 20% against 21% needs a sample size. Significance of 5% (two-sided) is the false-alarm rate you accept: a 1 in 20 chance of declaring a difference when there is none. Power of 80% is the chance the test catches a real difference of this size, so 1 in 5 real effects of this size are missed. The two-proportion formula is n = (1.96 * sqrt(2 * pbar * (1 - pbar)) + 0.8416 * sqrt(p1(1-p1) + p2(1-p2)))^2 / (p1 - p2)^2, where 1.96 and 0.8416 are the normal-curve values for 5% two-sided significance and 80% power, p1 = 0.20, p2 = 0.21 and pbar = 0.205. That gives n = (1.1190 + 0.4805)^2 / 0.0001 = 25,582.5, rounded up to 25,583 users per arm (computed in python). With four arms (no personalisation, current feature, two alternatives) that is 102,332 users.
- Run for whole weeks, at least two, so weekday patterns and a novelty effect (a short-lived jump in engagement because something is new) do not mislead.
- Compare each alternative with the no-personalisation arm (the 21% bar is judged against the 20% baseline) using a correction for several comparisons: each extra comparison is another chance for a fluke to look significant, so split the 5% budget. With two comparisons, test each at 2.5%, which raises the sample to about 30,980 per arm (about 123,920 across four arms) (computed in python, same formula with 2.2414 in place of 1.96, the normal-curve value for a 2.5% two-sided level, so 2.24 would give about 30,952). Comparing an alternative directly with the current feature (21% against 22%) is a different test with a smaller gap relative to the noise: it needs about 26,493 per arm at the 5% level and about 32,082 at 2.5% (computed in python), so size the arms for whichever comparison the decision rests on.
- Guardrails (metrics that must not get worse even if the main metric wins): opt-out rate, support complaints, session length, and a privacy-risk score computed per design. An illustrative scoring rule: 1 point per personal field retained, plus 5 if sensitive categories can be inferred, plus 1 per 30 days of retention (rounded up), plus 5 if anything leaves the device. The current feature retains 12 fields, allows sensitive inference and keeps data 180 days: 12 + 5 + 6 + 0 = 23. Alternative 1 (smaller inputs) retains 5 fields, no sensitive inference, 30 days: 5 + 0 + 1 + 0 = 6. If alternative 1 shows 21.4% engagement (1.4 of the 2 points, 70% of the lift) it clears the 21% bar at about a quarter of the risk score.
Step 4: who signs off. Product owns the engagement trade-off, privacy and legal own the residual risk, and security owns the on-device protection. If the "10%" is an absolute rather than a relative gain, redo the sample size.
Pitfalls. Judging only by engagement will favour the risky design. A test too small to see a 1 point difference will say "no difference" when there is one.
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.
A tailored-recommendations feature would work much better with more user data. How do you weigh privacy against personalization, and what design choices let you keep most of the value while collecting less?
Sample Answer
Direct answer
I weigh it by asking how much recommendation quality each extra data item actually buys (the gain is called lift: the improvement in a chosen recommendation metric, such as the share of recommendations clicked, compared with a baseline version) and what exposure it adds, then pick the cheapest data that delivers most of the value. In many products the first-party signals (data the product itself collects directly from what the user does in it, as opposed to bought or third-party data) and the user's stated interests deliver most of the lift, and the sensitive, intrusive signals add little, but that is a hypothesis to test on your own data, not a rule. So the default design collects less and processes closer to the user, and extra data is requested only where the user sees a benefit and agrees.
A repeatable decision process
- List candidate signals (purchase history, in-app clicks, location, contacts, third-party data, inferred traits).
- Estimate value for each by an offline test (replaying saved data through the model without showing anything to users) or an A/B experiment (showing different versions to randomly split groups of live users): how much does the recommendation metric move when the signal is removed?
- Estimate privacy and legal risk: sensitivity (health, finances, children, precise location are higher), surprise to the user, and storage duration. Legal review decides where law restricts a signal.
- Estimate engineering effort for consent capture, deletion support and storage controls.
- Decide in this order: signals with high value and low risk go in; high risk and low value are dropped; the middle is gated behind consent or an on-device design.
Design choices that keep value while collecting less
| Choice | How it works | What you give up |
|---|---|---|
| Session and first-party signals only | Use what the user does in the product right now | Less long-range personalization |
| Coarse features | Interest categories ("running shoes") instead of full browsing histories | Less nuance |
| On-device ranking | The server sends a shortlist of candidate items; the app on the phone holds the user's history and does the final ordering locally, so the history never uploads | More engineering work; weaker for brand-new users (cold start: no history exists yet) |
| Short retention of raw signals | Keep derived features for a window, drop raw events | Cannot retrain on old raw data |
| User controls | "Why am I seeing this?" and a switch to reset or turn off personalization | Some users will opt out |
| Opt-in for the extra-sensitive signals | Ask when the benefit is clear ("use my location for local picks") | Smaller trained population |
Collection strategy
Capture consent at the moment of benefit, store the preference where the recommendation service reads it, keep the data in the region and system where it is needed, and give the user a control to view, correct or delete. Enforce the choice in code, not only in the interface: the feature pipeline should drop signals for users who declined.
Worked example
A retail app tests three versions: (a) in-app clicks only, (b) clicks plus purchase history, (c) both plus precise location and contact data. Illustrative results on the metric "share of recommendations clicked": (a) 3.0%, (b) 3.6%, (c) 3.7%. Lift over (a) is +0.6 points for (b) and +0.7 points for (c), so (b) captures 0.6 / 0.7 = about 86% of (c)'s lift while using no location or contact data. The extra 0.1 point from (c) does not justify its exposure, so ship (b) by default and offer location as an opt-in for local offers. The decision is evidence-based and the sensitive data stays out unless it earns its place. (These figures are made up to show the method; real tests also report confidence intervals before anyone decides.)
What would change the call
A test showing a large lift from a sensitive signal, plus a clear user benefit and valid consent, can justify collecting it. A regulator's rule or a children's audience can rule it out regardless of lift.
Your ML platform has a shared feature store, and some features are derived from sensitive personal data. How would you build privacy controls into the store itself so that sensitivity is tracked per feature, access follows it, and a user's deletion or consent change propagates?
Sample Answer
Direct answer. Treat the feature store as a governed catalog: every feature carries metadata (sensitivity class, allowed purposes, source data, retention), access policy reads that metadata at request time, and user-keyed lineage lets a deletion or consent change reach the online store, offline store and training datasets. A feature store is a shared service that computes, stores and serves model input features, with an online store for low-latency serving and an offline store for training.
1. Sensitivity tracked per feature
(An entity ID is the key a feature is stored under, here the user's ID. Lineage is the recorded chain of which source tables fed which feature and which features fed which training set. A manifest is a saved list that records exactly what went into one training set.)
- Registering a feature requires: owner, source datasets, classification (for example public, personal, sensitive), allowed purposes, retention.
- Derived features inherit the highest sensitivity of their inputs unless a reviewer records why it is lower. Example:
avg_night_heart_rate_30d, derived from health data, is classed sensitive-health, allowed forsleep-coach, denied forads-ranking. - Lineage (which tables fed which feature) is stored, so reclassifying a source cascades to its features.
2. Access follows sensitivity
- Read policy checks the caller's declared purpose against the feature's allowed purposes, for training jobs and for online serving, and logs every read.
- A model that requests a denied feature fails at training-set build time, not in production.
3. Deletion and consent propagation
- Keys are the user (entity) ID. A consent service publishes events on withdrawal or deletion.
- Online store: consume the event and delete or invalidate the user's keys quickly, or check a consent flag at read time. Real-time enforcement suits serving. Worked example: user 8841 withdraws consent for
ads-ranking. Within minutes the flagads-ranking: withdrawntakes effect on the online path: keys for features whose only allowed purpose isads-rankingare deleted for 8841, while keys for a feature shared with a purpose the user still allows (such assleep-coach) stay and are simply refused to anyads-rankingread, so the next ads request gets no personalised features; offline rows are purged in the nightly job only for features with no remaining allowed purpose, and the training set built that weekend forads-rankingcarries the filterconsent[ads-ranking] != withdrawn, so its manifest lists 8841 as excluded. - Offline store: batch purge or rewrite partitioned tables on a schedule, and apply the consent flag as a join filter (when the training set is assembled by joining tables, rows for users whose flag says withdrawn are dropped) when building each training set. Batch enforcement suits training, because a training set is built at a point in time.
- Dynamic consent flags: a per-user, per-purpose flag in the store (for example
user 8841, ads-ranking: withdrawn on 12 March) drives both paths, so changing a purpose does not require recomputing every feature.
4. Dataset versioning and audit trail. Every training set is saved as a versioned manifest: feature list and versions, snapshot time, consent filter applied, and the model trained on it. Auditors can see which data a model used and prove withdrawn users were excluded after a date. Deleting a user from a trained model needs a retraining policy (for example retrain within a set window); state this limit honestly.
5. Pseudonymization and noise. Keyed pseudonymous IDs (a secret key turns each real ID into a code, so analysts see codes only) reduce exposure but the data stays personal data while the key exists. Adding noise (small random changes to feature values, the idea behind differential privacy) hides any one person's contribution but costs model accuracy, and the more noise the stronger the protection; it suits aggregate statistics and sensitive features, and many feature stores never need it.
Trade-off. Strict purpose checks slow feature reuse; offset with a self-service request flow for new purposes.
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.
Unlock Full Question Bank
Get access to all 12 Privacy by Design and Default interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.