Professional Integrity and Ethics Questions
How the candidate demonstrates honesty, ethical judgment, and integrity in their work and decisions. Covers acting with candor when it is costly, making principled decisions in ethically gray situations, owning mistakes truthfully, and upholding professional and interview integrity. Distinct from self-awareness: this is about values and ethical conduct rather than calibrated self-knowledge.
Design an audit logging and provenance system to track datasets, transformation steps, model training hyperparameters, model versions, and per-decision metadata for compliance and investigations. Assume 100M users and hundreds of models; describe storage choices, indexing/query patterns, retention policies, privacy protections, and how auditors would query the system.
Sample Answer
Requirements (clarify): immutably record dataset versions, transformation steps, model training hyperparameters & versions, and per-decision metadata for 100M users and hundreds of models. Support fast auditor queries for investigations and compliance; enforce privacy, retention and access controls.
High-level architecture:
- Append-only event stream (Kafka) for real-time ingestion of provenance events (dataset ingest, transformation run, model train start/finish, prediction decision).
- Long-term object store (S3 with versioning & object lock) to persist raw artifacts (datasets, model binaries, logs) referenced by event IDs.
- Metadata & indices: primary metadata store in a strongly consistent DB (Postgres or DynamoDB) for transactional metadata (version ids, hashes, timestamps, actor). A graph DB (Amazon Neptune / Neo4j) for lineage relationships (dataset -> transform -> model -> decision).
- Search index (Elasticsearch / OpenSearch) for full-text and ad-hoc querying (e.g., find all decisions affecting user X in date range).
- Audit UI + query layer: REST API that composes results from metadata DB, graph DB, and search.
Storage choices & rationale:
- Kafka: durable ingestion, replay for reprocessing.
- S3: cheap, durable, supports immutability and legal hold.
- Postgres/DynamoDB: low-latency point lookups and ACID for metadata.
- Graph DB: natural fit for lineage traversal queries.
- Elasticsearch: supports faceted search, aggregations for auditors.
Indexing & query patterns:
- Write each event with keys: event_id, type, timestamp, actor, artifact_id, dataset_version, model_version, user_id_hash, pointers to S3, parent_ids.
- Partition indices by time + tenant (month + model) to support range scans.
- Precompute and cache common joins: model_version -> training hyperparams, dataset_version -> checksum, decision -> model_version.
- Lineage/traversal queries use graph DB (e.g., find all data sources influencing model V).
- Ad-hoc and per-decision queries use Elastic + metadata DB (e.g., all decisions for user U between dates -> fetch decision events, then join to model_version and hyperparams).
Retention and compliance:
- Retention tiers:
- Short-term (0–1 year): full detail in hot stores (ES, Postgres).
- Mid-term (1–7 years): metadata + pointers in cold store; raw artifacts archived in S3 Glacier Deep Archive.
- Legal hold: mark object lock on S3 to prevent deletion.
- Automatic roll-up: after policy age, collapse per-decision raw logs into summarized records (counts, aggregates) if allowed.
- Retention policies enforced by lifecycle jobs and IAM guards.
Privacy & protections:
- PII minimization at ingestion: store user identifiers as salted cryptographic hashes; keep reversible mapping in restricted KMS-protected vault only for legal-approved investigators.
- Encrypt data at rest (SSE-S3 or KMS) and in transit (TLS).
- Differential privacy / noise injection for aggregate reporting endpoints.
- Role-based access control + attribute-based policies (RBAC/ABAC) for auditors vs developers; all accesses logged to immutable audit trail.
- Field-level masking and query-time filtering for sensitive fields; ephemeral decryption keys for approved sessions.
How auditors query:
- Use an auditor UI or CLI that authenticates via strong MFA and uses scoped temporary credentials.
- Examples:
- "Give me all decisions affecting user H from 2025-01-01 to 2025-02-01": Query ES for decision events by user_hash and time, return decision ids -> metadata DB join to model_version -> fetch hyperparams and model artifact S3 pointers; show lineage via graph DB to datasets.
- "Show provenance for model v12": Graph DB traversal: model v12 -> training run -> dataset_version(s) -> transformation steps; return artifact checksums and S3 URIs.
- "List changes to training hyperparameters for models owned by team X": SQL on metadata DB with time + team filter, plus diffs between hyperparam blobs.
Scalability & perf considerations:
- Shard Kafka topics by model/tenant; use compaction for latest state topics (e.g., model current version).
- Postgres for transactional metadata can be scaled via read replicas; heavy-scale use DynamoDB with GSIs (partition by model_id, sort by timestamp).
- Graph DB sizing: keep only lineage edges/ids; heavy artifacts stay in S3 to limit graph size.
- Bulk indexes and streaming ETL (Kafka Connect) to ES and graph DB; backpressure & throttling for bursts.
- Sampling + summarization for extremely high-volume per-decision logs; allow full retention only when mandated.
Trade-offs:
- Keeping full per-decision raw payloads is expensive; prefer hashed/pointered approach and legal hold for full retention.
- Graph DB gives expressive lineage queries but adds operational complexity; acceptable because provenance queries are central.
This design provides an immutable, queryable provenance trail linking datasets, transforms, training hyperparameters, model versions and per-decision metadata while balancing cost, scalability, privacy and auditability.
You need to reduce disparate impact for a target outcome but are not permitted to use the protected attribute directly in training. Outline algorithmic and non-algorithmic approaches you would explore (for example proxy-aware adjustments, fairness-constrained post-processing, targeted data collection, or policy changes), discuss pros/cons, and describe validation strategies.
Sample Answer
Approach overview: since the protected attribute (A) cannot be used, combine proxy-aware algorithmic methods, targeted data actions, and organizational/policy changes. For each I list what I’d try, pros/cons, and how I’d validate.
Algorithmic options
- Proxy-aware adjustments (use proxies Z correlated with A, e.g., ZIP+occup): build models that explicitly model P(A|Z) and adjust predictions via reweighting or thresholding.
- Pros: uses available signal to reduce disparity; interpretable adjustments.
- Cons: risk of proxy leakage, legal/privacy concerns, imperfect proxies introduce noise.
- Pre-processing: reweighing / optimal transport / synthetic balancing (generate balanced training distribution).
- Pros: model-agnostic, simple to implement.
- Cons: may distort joint distribution, hurt overall accuracy.
- In-processing fairness constraints: add constraints or regularizers (e.g., demographic parity gap, equalized odds or group-specific loss penalties) to training objective without using A directly by using proxy-estimates P(A|Z).
- Pros: principled trade-off control.
- Cons: requires careful tuning; optimization may be harder.
- Adversarial debiasing using proxy labels: train predictor while adversary predicts proxy-estimated A; minimize predictor utility and adversary performance.
- Pros: can remove information useful for predicting protected class.
- Cons: unstable training; may remove useful signal for legitimacy.
- Post-processing: fairness-constrained calibration (e.g., reject-option, group-specific thresholds determined via proxy-based grouping).
- Pros: no retraining; easy to deploy.
- Cons: relies on proxy grouping; can be seen as disparate treatment if misapplied.
Non-algorithmic / operational options
- Targeted data collection: collect richer features or voluntary self-identified A (with consent) to accurately measure disparity and improve fairness interventions.
- Pros: better measurement; reduces reliance on proxies.
- Cons: privacy/regulatory hurdles; response bias.
- Policy/process changes: redesign decision rules to reduce reliance on model outputs (human-in-loop, constraints on automated denials), introduce appeal processes, or change business rules that disproportionately affect groups.
- Pros: immediate, transparent, aligns with legal/regulatory goals.
- Cons: may increase operational cost; slower to scale.
- Outcome remediation: offer alternative interventions to groups showing higher negative outcomes (e.g., targeted support programs).
- Pros: directly reduces harm.
- Cons: resource intensive; requires careful targeting to avoid stigma.
Trade-offs and practical concerns
- Accuracy vs fairness: many methods trade some predictive performance for lower disparity. Quantify acceptable trade-off with stakeholders.
- Proxy risks: proxies may imperfectly capture A and create residual unfairness or legal exposure.
- Privacy & consent: collecting A requires clear consent and secure handling.
- Legal/regulatory: some jurisdictions forbid proxy use; coordinate with legal/compliance.
Validation strategies
- Metrics: track multiple fairness metrics—demographic parity difference/ratio, equalized odds (TPR/FPR gaps), calibration within groups, and subgroup utility metrics. Report confidence intervals via bootstrap.
- Proxy robustness: evaluate fairness using multiple proxy definitions and sensitivity analysis for P(A|Z) estimation error.
- Holdout and cross-validation: compute metrics on a reserved test set and on temporal and geographic slices to detect distributional shifts.
- Counterfactual / causal checks: where feasible, run causal analyses (e.g., matching, uplift) to ensure observed disparities aren’t due to legitimate covariates.
- Human review & A/B tests: small-scale randomized trials or shadow deployments comparing baseline vs mitigation, measuring business and fairness outcomes plus user experience.
- Monitoring: set production alerts for metric drift (accuracy and fairness gaps), log decisions for audits, and periodically retrain with updated data.
- Stakeholder validation: legal, product, and affected-community reviews; perform blameless postmortems after issues.
Concrete example (brief): estimate P(A|Z) with a calibrated classifier on historical voluntary A; use reweighing in training to equalize expected positive rates, then post-process thresholds per proxy-group and validate via held-out bootstrapped TPR/FPR gaps and an A/B test measuring downstream business KPIs and complaint rates.
Final note: combine methods—start with policy/process changes and targeted data collection for measurement, then apply conservative algorithmic adjustments with robust validation and ongoing monitoring.
Describe a time you discovered a potential bias, privacy issue, or other ethical concern in data or model outputs. What immediate steps did you take, which stakeholders did you involve (legal, product, etc.), and how did you balance the business objectives with ethical obligations in the short and long term?
Sample Answer
Situation: At my previous company I was building a churn prediction model for targeted retention campaigns using customer transaction and support interaction data. During EDA I noticed that the model scores were systematically higher for a specific demographic group and that a seemingly innocuous feature—“preferred store location”—was highly correlated with both churn and protected attributes (ZIP → ethnicity/income).
Task: I needed to assess whether the model encoded bias or used privacy-sensitive proxies, stop any harmful rollout, and recommend a path that balanced retention goals with fairness and legal compliance.
Action:
- Immediately paused the experimental campaign and flagged the model as not production-ready.
- Performed additional analysis: disaggregated performance by demographic slices, computed fairness metrics (equal opportunity, disparate impact), and tested feature importance with and without the suspect features.
- Convened a cross-functional meeting including Product, Legal/Privacy, and a senior ML engineer to present findings and risks.
- With Legal, reviewed data lineage and consent for ZIP-level usage; with Product, discussed business impact of removing or transforming the feature.
- Implemented short-term mitigations: removed the direct location feature, added regularization and adversarial debiasing (a classifier penalized for encoding protected attributes), and retrained.
- Produced a monitoring plan (slice-aware metrics, drift detection) and proposed a longer-term governance step: a feature approval checklist and periodic fairness audits.
Result: After mitigation, disparate impact reduced from 1.6 to 1.05 while model AUC dropped only 0.03—an acceptable trade-off agreed with Product. Campaigns proceeded with the debiased model and ongoing monitoring. This taught me to treat fairness and privacy as product requirements: pause, quantify, involve the right stakeholders, and choose mitigations that preserve business value while protecting customers.
A public complaint alleges your deployed model discriminates by zip code. Draft a rigorous investigation plan that includes what data to gather, which statistical tests to run (and why), how to control for confounders, how to coordinate with legal and PR, proposed remediation steps, and a plan for transparent public communication if discrimination is confirmed.
Sample Answer
Situation overview: A public complaint alleges zip-code–based discrimination by our deployed model. The investigation must be rigorous, legally defensible, and transparent. Below is an operational plan covering data, tests, confounder control, stakeholder coordination, remediation options, and public communication.
- Data to gather
- Model inputs, outputs, and timestamps for affected period.
- Ground-truth labels or outcomes used for training and evaluation.
- User metadata: zip code, demographics (race, income, age) where available and legally permissible, device, channel, application version.
- Training data snapshot, preprocessing pipelines, feature engineering logs, hyperparameters, and model version.
- Decision logs (why automated decision made), downstream actions, appeal records, business rules.
- Access logs and any A/B experiment assignments.
- Preliminary exploratory analysis
- Aggregate model outcome rates by zip code and visualize geographic heatmaps and time series.
- Compare complaint zip codes to population distribution (census) and customer base.
- Check sample sizes per zip (exclude low-n unstable cells or flag for special handling).
- Statistical tests and why
- Disparate impact ratio (selection rate in zip vs. reference): quick flag for relative disparity.
- Difference-in-proportions test (z-test) with Bonferroni/Holm correction across many zip codes to control false positives.
- Logistic regression of model decision ~ zip_code + covariates (demographics, income, prior behavior) treating zip as fixed effects to quantify adjusted association; test significance of zip coefficients.
- Multilevel (hierarchical) logistic model: zip as random effects to estimate variance attributable to geography.
- Propensity score matching / inverse-prob weighting: compare similar individuals across zip codes to control observed confounders.
- Causal sensitivity analysis (e.g., e-values, Rosenbaum bounds) to assess how strong an unobserved confounder would need to be to explain the effect.
- Calibration and performance parity tests: compare model calibration, false positive/negative rates, and ROC/AUC across zip groups (Equalized odds, predictive parity).
- Permutation tests for robustness when distributional assumptions fail.
- Bayesian posterior intervals where sample sizes small.
- Controlling for confounders
- Identify candidate confounders (income, prior interactions, product availability) using domain knowledge and causal diagrams (DAGs).
- Use multivariate adjustment (regression), matching, and stratification.
- Run backdoor-adjusted causal models; if randomization exists (A/B), analyze within-experiment strata.
- Where key confounders are missing, perform targeted data collection or sensitivity analyses before concluding discrimination.
- Reproducibility & audit trail
- Log all queries, code, seeds, and environment; produce a notebook that can be audited.
- Freeze snapshots (data/model) used for analysis.
- Prepare clear summary tables and visualization appendices.
- Coordination with Legal and PR
- Immediately notify legal counsel and compliance; provide scope, timelines, and risk assessment.
- Create a cross-functional incident team: Data Science lead, Legal, Compliance, Product, Engineering, Security, Privacy, and PR.
- Legal: advise on permissible data use (sensitive attributes), regulatory reporting requirements, and mitigation to avoid legal exposure.
- PR: craft controlled external messaging drafts, holding statements, and internal comms; prepare answers to likely media questions.
- Establish embargoed technical summary for regulators and executives; coordinate timing of public disclosure with legal counsel.
- Remediation options (if discrimination likely)
- Short-term mitigations:
- Implement conservative human review / hold-until-manual for decisions in flagged zip codes.
- Apply temporary threshold adjustments to equalize selection rates subject to risk/utility trade-offs.
- Turn off features that directly encode zip if they drive the behavior, while evaluating impact.
- Medium-term:
- Retrain with fairness-aware methods: reweighing, adversarial debiasing, constrained optimization (e.g., minimize loss subject to parity constraints).
- Enrich training data for underrepresented geographies.
- Introduce calibrated post-processing (e.g., reject-option classification) aimed at specific harms.
- Long-term:
- Redesign product flows to reduce reliance on zip as proxy for protected traits.
- Deploy continuous monitoring and alerting for geographic fairness metrics.
- Establish appeals process and remediation for affected customers.
- Validation of remediation
- Test candidate fixes offline on holdout data and via A/B tests with fairness and utility metrics.
- Predefine success criteria: reductions in disparity metrics (e.g., disparate impact ratio), maintained overall performance, and acceptable business KPIs.
- Run sensitivity and regression tests to ensure no unintended harms elsewhere.
- Transparent public communication (if discrimination confirmed)
- Work with Legal/PR to publish:
- A plain-language incident summary: what happened, who was affected (scope), immediate actions taken.
- Technical appendix: methods used, data sources, fairness metrics before/after, and remediation approach.
- Timeline for fixes, audit results, and independent third-party review plans.
- Steps for affected customers: contact channels, remediation options (refunds, manual review).
- Offer independent audit by a credible external firm and commit to publishing their findings.
- Commit to ongoing monitoring and regular public updates (e.g., 30/90/180-day reports).
- Provide a point of contact for regulators and community groups.
- Metrics and timeline
- Immediate (24–72 hrs): data collection, preliminary analysis, legal/PR notification, temporary mitigations if high-risk.
- Short (1–2 weeks): adjusted statistical analysis, causal checks, internal report with recommended fixes.
- Medium (2–8 weeks): implement and validate remediation, A/B test, and prepare public communication materials.
- Ongoing: monitoring dashboards, audits, and quarterly public fairness reports.
Conclusion: This plan balances rigorous statistical investigation (controlling for confounders and quantifying uncertainty) with operational steps for remediation, legal risk management, and transparent public communication. All findings, code, and data snapshots should be retained to support internal review, regulatory inquiries, and third-party audits.
Describe a practical monitoring plan to detect model drift that could introduce new fairness issues after deployment. Which metrics would you track (both performance and fairness), what sampling and alerting strategies would you use, and what remediation workflows would you trigger on alerts?
Sample Answer
Start with objectives: detect distributional/label drift that degrades accuracy and detect shifts that disproportionately affect protected groups (fairness drift). Monitor continuously and trigger graded responses.
Key metrics
- Performance: overall accuracy, AUC/precision-recall, calibration (Brier score), prediction confidence distribution, per-segment confusion matrix (TPR/FPR).
- Fairness: per-group metrics (TPR, FPR, precision, false omission), demographic parity gap, equalized odds gap, predictive parity difference, and calibration per group.
- Data: population feature distributions (KS/Wasserstein distances), PSI for features, rate of missingness, upstream schema changes.
Sampling & frequency
- Real-time for prediction metadata (latency, confidence) with daily aggregates.
- Weekly stratified sampling for labeled outcomes (delay depending on label availability). Ensure stratification by protected attributes and high-risk segments (low-confidence, new feature values).
- Maintain rolling windows (7/30/90 days) for drift statistics.
Alerting strategy
- Threshold-based alerts: e.g., PSI >0.2, AUC drop >5%, TPR gap >3–5 percentage points.
- Statistical tests with p-values + effect size (e.g., KS test for features, permutation test for metric changes) to avoid noisy alerts.
- Tiered alerts: informational → investigate → critical (stop-lift). Send to ML ops + model owner + fairness lead.
Remediation workflows
- Automated: increase sampling for affected segment, enable shadow model routing, rollback to previous model if critical.
- Investigative: run root-cause notebook to compare feature distributions, label quality, upstream pipeline changes; reproduce on recent data; run counterfactual or subgroup error analysis.
- Corrective actions: retrain with upweighted underrepresented segments, add fairness-aware constraints (e.g., equalized odds post-processing or reweighing), calibrate thresholds per group, or deploy debiased model variant.
- Governance: record incident in model registry, log decisions, and schedule postmortem and stakeholder communication.
Rationale: combine distributional and outcome-based monitoring to detect both technical drift and emergent fairness harms; stratified sampling and tiered alerts reduce false positives; structured remediation balances automated safeguards with human review and governance.
Unlock Full Question Bank
Get access to all 44 Professional Integrity and Ethics interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.