Privacy-Enhancing Technologies and Anonymization Questions
Technical safeguards that reduce identifiability: anonymization, pseudonymization, tokenization, differential privacy, and related privacy-enhancing technologies. Covers the difference between anonymized and pseudonymized data, re-identification risk, and when each technique is appropriate. Includes evaluating the privacy-utility tradeoff of a given technical control.
Hard: Consider a model trained on web-scraped data that accidentally memorized a small number of PII strings. Propose a production-safe procedure to detect and remove memorized sensitive strings across model versions and to prevent reintroduction during future training.
Sample Answer
Situation: A trained model has memorized a few PII strings from web-scraped data. The objective is to detect those memorized strings across model versions, remove them from production models safely, and prevent reintroduction in future training.
Procedure (production-safe, repeatable):
- Detection (automated + measurable)
- Maintain a canonical PII blocklist and hashed corpus of known leak candidates (emails, SSNs, credit-card patterns, long unique tokens).
- Run automated extraction tests: prompt the model with partial-context queries and measure exposure using log-probability/exposure metrics (Carlini et al. “exposure”): if the model assigns anomalously high likelihood to a candidate sequence or reproducibly outputs it, flag it.
- Canary-based periodic auditing: inject synthetic canaries into training simulator; after training, measure recoverability to estimate memorization risk.
- Record deterministic fingerprints (token IDs, byte offsets of outputs) for flagged leaks and store in an auditable incident DB.
- Removal / Remediation
- Fast rollbacks: if high-risk PII is exposed in prod, retire the model version and serve the last safe checkpoint while remediation runs.
- Targeted model editing: apply a surgical fix like fine-tuning on “negatives” (contrastive examples) with high learning rate on flagged sequences, or use techniques such as Knowledge Neurons editing / ROME or S3 (for transformer weights) to remove specific memorized mappings; verify no broad degradation.
- Output-level mitigations: deploy response filters that detect and redact PII patterns at inference (regex/ML PII detector + entropy checks). Use deterministic blocking for high-sensitivity cases until model edit verified.
- Retrain if necessary: if edits insufficient or many leaks present, retrain from scrubbed dataset.
- Prevention (pipeline + policy)
- Training-data hygiene: pre-ingest normalization, PII detection, redaction (or hashing with reversible KMS only for dev), deduplication, and provenance metadata per example.
- Differential privacy / DP-SGD for future training where feasible to bound memorization.
- Data lineage + dataset versioning: enforce mandatory review for sources with low provenance score.
- Continuous integration: unit tests in training pipeline that run canary recall tests, exposure scans, and run model on blocklist before release.
- Governance: SLOs for acceptable exposure rates, incident response playbook, and periodic external audits.
- Validation & Monitoring
- After remediation, re-run extraction tests, synthetic canaries, and end-to-end user-simulated prompts.
- Monitor telemetry for unusual repeated generation of sensitive tokens; alerting and automatic throttling/rollback.
Why this works:
- Multi-layered (data, model, inference) prevents single-point failure.
- Surgical edits + output filters provide immediate risk reduction while preserving model utility.
- Canary/exposure metrics provide quantitative guardrails to detect regressions across versions.
- DP and strict data hygiene lower future memorization risk while dataset provenance supports auditability and compliance.
You need to choose an epsilon for DP-SGD fine-tuning of a ranking model. Describe an experimental evaluation plan to quantify privacy-utility trade-offs, including metrics to track, holdout strategy, curves to plot, and decision criteria for selecting epsilon under business constraints.
Sample Answer
Situation: We need to pick an epsilon for DP-SGD fine-tuning of a ranking model so business utility remains acceptable while meeting privacy targets.
Plan (steps)
- Define constraints and goals
- Set allowed delta (e.g., 1e-6 or 1/|users|) and regulatory/contractual privacy floors.
- Define minimum acceptable business metrics (e.g., NDCG@10 loss ≤ X% relative to non-DP baseline, CTR lift thresholds, latency constraints).
- Experimental setup
- Holdout strategy: user-level split (no user in both train and test) into train/val/test. Reserve a separate “production shadow” holdout built from latest traffic for final validation and A/B simulation.
- Repeatable runs: run each config with 3–5 seeds to get variance.
- Sweep and tuning
- Sweep epsilons: e.g., {0.1, 0.3, 1, 3, 8, ∞ (non-DP)}. For each ε, tune clipping norm and learning rate using the same budgeted hyperparameter protocol to avoid confounding.
- Use privacy accountant (RDP / moments accountant) to compute exact ε for the entire fine-tune procedure; report ε, δ.
- Metrics to track
- Utility: NDCG@k, MRR, AUC, calibration (expected calibration error), offline CTR prediction loss, business KPIs simulated (predicted revenue/CTR).
- Robustness: recall by cohort (cold-start, tail queries), fairness metrics across demographic groups if available.
- Stability: per-query ranking variance, permutation consistency.
- Privacy: reported ε, δ, total training steps, clipping norm, noise multiplier.
- Cost: compute/time.
- Analysis & plots
- Plot utility metric vs epsilon with error bars (mean ± CI). Also show relative change vs non-DP baseline.
- Privacy-utility frontier (Pareto): utility on y, ε on x; mark points satisfying business thresholds.
- Additional plots: utility vs noise multiplier, utility vs clipping norm, cohort-specific utility curves.
- Calibration and fairness deltas vs ε.
- Decision criteria
- Primary rule: choose smallest ε whose utility stays above business threshold with statistical significance (e.g., non-inferiority test, p < 0.05) and acceptable cohort/fairness behavior.
- If multiple ε satisfy, prefer lower ε (better privacy) unless operational costs (training time or stability) trade off.
- If no ε meets threshold, consider alternatives: partial DP (only sensitive features), pretraining with DP, synthetic data, or relaxed business targets with mitigation.
- Deployment checks
- Run production shadow A/B for top candidate ε for 2–4 weeks; monitor online KPIs, user-level metrics, and any distribution shifts.
- Maintain reproducible privacy accounting and documentation for compliance.
This plan gives a quantitative privacy-utility curve, cohort and fairness checks, and concrete selection criteria aligned with business constraints.
Compare secure multiparty computation (MPC), homomorphic encryption (HE), and differential privacy (DP) as privacy technologies for machine learning. Explain trust assumptions, types of computations supported, performance characteristics, and example use cases where each is preferable.
Sample Answer
High-level summary: MPC, HE, and DP address different privacy goals and make different trust/performance trade-offs. Use the table below (described in text) to choose the right tool per use case.
Trust assumptions
- MPC: Multiple non-colluding parties compute joint functions without revealing inputs. Security requires an honest majority or bounded collusion; no single trusted server needed.
- HE: A data owner encrypts data and a (possibly untrusted) server computes on ciphertexts; security relies on cryptographic hardness (LWE, RLWE). The decryptor must hold the secret key.
- DP: Trust in a curator or mechanism that adds calibrated noise; guarantees are statistical (bounded leakage) even if outputs are public. Does not protect raw intermediate values.
Types of computations supported
- MPC: General-purpose, supports arbitrary functions including ML training/inference via garbled circuits, secret-sharing-based arithmetic. Flexible but protocol complexity rises with function complexity.
- HE: Naturally supports arithmetic (add/multiply). Some schemes (CKKS) support approximate real-valued linear algebra and neural-net inference; deep non-linear operations (activations) are expensive or require approximation/interaction.
- DP: Agnostic to computation; it’s an output-perturbation layer. You can train models with DP-SGD or release DP aggregates/statistics.
Performance characteristics
- MPC: Communication-heavy and latency-sensitive; scales with number of parties and rounds. Secret-sharing arithmetic is efficient for linear ops; garbled circuits costly for many gates.
- HE: Computation-heavy on server-side, low communication. Bootstrapping (to refresh ciphertexts) is expensive if deep circuits required. Good for low-interaction workloads (one server).
- DP: Minimal runtime overhead (noise addition); main cost is accuracy loss — utility vs epsilon privacy. Computation cost comparable to non-private training (DP-SGD adds gradient clipping/noise).
When to prefer each (use cases)
- MPC: Collaborative analytics where parties cannot reveal raw data to each other (joint fraud detection between banks, multi-hospital study) and low-latency interaction among known parties is acceptable.
- HE: Outsourced inference/training where a single cloud provider should not see raw inputs (private inference for user data, encrypted genomic queries); best when model operations are mostly linear or shallow networks.
- DP: Public release of models/statistics or to protect model outputs against membership inference (training a recommendation model to be shared, telemetry analytics, analytics dashboards). Combine with HE/MPC to bound leakage from outputs.
Practical combos and trade-offs
- Combine DP+HE: HE protects data in transit/compute; DP limits what final model leaks. Useful for outsourced training with public model release.
- Combine MPC+DP: Use MPC for secure joint training, apply DP at output to limit aggregate leakage.
- Consider engineering cost: HE/MPC require cryptographic libraries and heavy compute; DP requires careful privacy accounting, tuning epsilon, and may need larger datasets to retain utility.
Example specifics
- HE (CKKS) for encrypted inference of logistic regression or first layers of a CNN.
- MPC (3-party replicated secret sharing) for secure linear regression across hospitals.
- DP-SGD with epsilon 1-8 for training language models when releasing model weights publicly.
Key takeaway: MPC and HE protect raw values with cryptographic guarantees at a performance/complexity cost; DP protects against inference from outputs with statistical guarantees and lower runtime cost but sacrifices accuracy. Choose based on who you must trust, which computations are needed, and acceptable performance/privacy trade-offs.
Spotify is exploring federated learning to personalize recommendations without centralizing raw listening histories. As technical lead, outline the federated architecture, privacy guarantees, aggregation strategy, client heterogeneity handling, and production deployment considerations including costs and performance trade-offs.
Sample Answer
Requirements & constraints:
- Personalize recommendations on-device without centralizing raw listening histories
- High privacy (regulatory + user trust), reasonable latency, battery/network constraints, model update frequency, and support for millions of devices
High-level architecture:
- Orchestrator (cloud) coordinates rounds: selection, config, aggregation, validation, rollout
- Client runtime (mobile SDK) maintains local data store, feature extractor, trainer (on-device), secure comms
- Secure Aggregation Service and Model Store (encrypted checkpoints)
- Monitoring & analytics pipelines (telemetry, DP-safe metrics)
Privacy guarantees:
- Local differential privacy for sensitive features where needed; add calibrated noise to per-client updates
- Secure Aggregation (cryptographic multi-party) so server only sees aggregated gradients
- Per-round and cumulative privacy accounting (Rényi DP) and policies to cap exposure
- Minimal telemetry with DP/Synthetic summaries and opt-in controls
Aggregation strategy:
- Federated Averaging with weighted aggregation by effective sample size (listens, playtime)
- Momentum/Server-side Adam to stabilize non-iid updates
- Robustness: clipped updates, adaptive clipping, outlier detection, and Byzantine-resilient aggregation (trimmed mean / Krum) for poisoned updates
- Periodic centralized fine-tuning on anonymized aggregated summaries for backbone models
Handling client heterogeneity:
- Partial participation: sampling strategy based on availability, diversity and stratified by device capability and region
- Smaller local epochs for low-capacity devices; asynchronous fallback (send compressed updates)
- Techniques: personalization layers (meta-learning / per-client head), multi-task adapters, FedProx to handle heterogeneity, and distillation to compress models
- Compression: quantization, sparsification, delta encoding to reduce bandwidth
Production deployment & trade-offs:
- Cost drivers: orchestration, secure-aggregation compute, validation training, increased telemetry storage, and client CPU/energy impact
- Performance trade-offs: privacy (DP noise) vs accuracy; communication compression vs convergence speed; infrequent rounds reduce cost but increase model staleness
- CI/CD: staged rollout (canary -> region -> global), offline simulation using held-out shards, shadow training, A/B tests with metrics: CTR, retention, personalization lift, offline loss, and DP budget usage
- Monitoring & rollback: detection for training regressions, anomaly detectors, automated rollback and hotfix pipeline
- Compliance & UX: transparent opt-in, explainability (local model diagnostics), battery/network safeguards, user controls
Key metrics and targets:
- Privacy: epsilon per 30 days budget target (e.g., ε≤3)
- Latency: model update completion < X hours for active cohort
- Resource: average CPU <5% per update, avg upload/download per round <100KB
- Business: +X% personalized CTR lift with negligible battery impact
This design balances strong cryptographic and DP guarantees, robust aggregation for non-iid clients, and pragmatic production controls to manage cost and model utility.
How would you design personalization features for Airbnb recommendations while minimizing privacy risk and complying with regulations? Evaluate approaches such as differential privacy, federated learning, cohort-based personalization, local aggregation, and feature hashing. Discuss trade-offs in model utility, deployment complexity, and auditability.
Sample Answer
Situation: Design Airbnb recommendation personalization that maximizes relevance while minimizing privacy risk and meeting regulations (GDPR, CCPA).
Approach overview (requirements & constraints):
- High utility: relevant listings, host/item personalization
- Privacy: limit PII exposure, enable user control, data minimization
- Auditable & explainable for compliance
- Scalable, low-latency for UX
Evaluate approaches:
- Differential Privacy (DP)
- What: add calibrated noise to gradients/aggregates or use DP-SGD.
- Utility: small utility loss tunable via epsilon; tight privacy reduces accuracy.
- Complexity: moderate (privacy accounting, tuning epsilon, re-training).
- Auditability: good — formal guarantees and logs; but explains only overall risk, not individual recommendations.
- Federated Learning (FL)
- What: train models on-device; only model updates sent.
- Utility: near-central training if many clients; heterogeneity and communication noise affect convergence.
- Complexity: high (orchestration, secure aggregation, compression, handling stragglers).
- Auditability: harder — need provenance for updates and secure aggregation makes inspection limited; combine with DP for stronger guarantees.
- Cohort-based Personalization (e.g., k-anonymity / hashed cohorts)
- What: bucket users into behavior cohorts for group-level signals (similar to FLoC-like).
- Utility: lower granularity than per-user, but still effective for many features.
- Complexity: low — easier to deploy and explain.
- Auditability: high — cohorts are transparent and easier to document; risk of re-identification if cohorts small.
- Local Aggregation / On-device Feature Engineering
- What: compute features locally (preferences, recent searches), send only aggregates or feature hashes.
- Utility: retains temporal personalization; can combine with server models.
- Complexity: moderate — requires client code, storage, sync logic.
- Auditability: good if aggregates logged; preserves raw PII on-device.
- Feature Hashing / Pseudonymization
- What: hash identifiers or map to pseudo-ids; reduce direct linkage to PII.
- Utility: minimal loss for categorical features; potential collision issues.
- Complexity: low.
- Auditability: medium — reversible if salts leaked; must manage key rotation.
Trade-offs & recommended hybrid design:
- Combine FL + DP + local aggregation: train base model centrally, fine-tune on-device with FL; apply DP to updates and secure aggregation to prevent update leakage. Use cohort signals for cold-start and non-sensitive personalization.
- Use feature hashing + strict key management for server-side features, and keep sensitive raw data local.
- Provide auditability by logging model versions, privacy budgets, cohort definitions, and running periodic privacy impact assessments. Expose opt-out controls and data deletion flows.
Practical considerations:
- Start with cohort-based + server models (fast, low-risk). Pilot FL+DP for high-value personalization where client density is sufficient.
- Monitor utility vs. epsilon; run A/B tests measuring CTR, bookings, and fairness metrics.
- Ensure legal/compliance sign-off, encryption-in-transit & at-rest, and regular privacy audits.
This hybrid balances utility, deployment effort, and provable privacy while remaining auditable and compliant.
Unlock Full Question Bank
Get access to all 26 Privacy-Enhancing Technologies and Anonymization interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.