← Amazon Interview Insights

Amazon·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
May 2026

Summary

Amazon ML Engineer interview that went deep on bandit algorithms, way deeper than I expected. They weren't satisfied with just naming the algorithms, they pushed hard on tradeoffs, production edge cases, and things like delayed rewards that I hadn't drilled enough.

Questions Asked (7)

Q1

What are multi-armed bandit algorithms, and when would you choose one over a traditional A/B test?

A/B Testing & ExperimentationTechnical Trade-offs
Author's notes

Felt pretty solid here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining multi-armed bandit algorithms as a dynamic experimentation method that balances exploration and exploitation to maximize cumulative reward. Then compare them to traditional A/B tests, which are static and focus on statistical significance. Finally, explain when to choose bandits, such as when you need to minimize opportunity cost, adapt quickly to changing conditions, or optimize a single metric in real-time.

Pro tip: Emphasize that bandits are not a replacement for A/B tests but a complement: use bandits for optimization and A/B tests for learning. At Amazon, where customer obsession and long-term thinking are key, highlight that bandits can reduce customer experience risk by quickly deprioritizing poor variants.

1. Define Multi-Armed Bandits

Explain that bandits are algorithms that dynamically allocate traffic to variants based on performance, balancing exploration of new options and exploitation of known winners to maximize cumulative reward.

2. Contrast with Traditional A/B Tests

Describe A/B tests as fixed-horizon experiments with static traffic split, designed to measure statistical significance and infer causality, often at the cost of opportunity.

3. Identify When to Use Bandits

Discuss scenarios where bandits excel: when you want to minimize regret, adapt to non-stationary environments, handle multiple variants, or optimize a single metric in real-time (e.g., click-through rate).

4. Acknowledge Trade-offs and Limitations

Mention that bandits can be biased for measuring long-term effects, may lack statistical power for causal inference, and require careful implementation to avoid feedback loops.

5. Provide a Recommendation

Conclude with a decision framework: choose bandits for rapid optimization and A/B tests for rigorous learning, and consider hybrid approaches like using bandits for exploration and then validating with an A/B test.

Key Points to Mention

  • Exploration vs. exploitation trade-off
  • Cumulative regret minimization
  • Common algorithms: epsilon-greedy, UCB, Thompson Sampling
  • Statistical significance and power in A/B tests
  • Non-stationarity and dynamic environments
  • Use cases: recommendation systems, ad placement, website optimization

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Compare epsilon-greedy, UCB, and Thompson sampling. How do they differ in terms of regret, exploration-exploitation balance, and underlying assumptions?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

This is where it got interesting.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining each algorithm briefly, then compare them across the three dimensions: regret, exploration-exploitation balance, and assumptions. Use a structured comparison to highlight trade-offs and practical implications, especially in large-scale systems like Amazon's.

Pro tip: Emphasize that Thompson sampling often achieves logarithmic regret and is Bayesian, making it robust in dynamic environments, but mention computational cost; relate to Amazon's need for scalable, real-time decision-making.

1. Define each algorithm

Briefly explain epsilon-greedy (random exploration with probability epsilon), UCB (optimism in the face of uncertainty using confidence bounds), and Thompson sampling (Bayesian posterior sampling).

2. Compare regret bounds

Discuss theoretical regret: epsilon-greedy has linear regret in worst case, UCB achieves logarithmic regret, and Thompson sampling also achieves logarithmic regret (often with better empirical performance).

3. Analyze exploration-exploitation balance

Explain how epsilon-greedy explores uniformly at random, UCB explores based on uncertainty (optimism), and Thompson sampling explores probabilistically according to posterior uncertainty.

4. Discuss underlying assumptions

Highlight assumptions: epsilon-greedy assumes stationary rewards and requires tuning epsilon; UCB assumes bounded rewards and deterministic confidence bounds; Thompson sampling assumes a Bayesian model and prior distribution.

5. Relate to practical scenarios

Connect to real-world applications, such as Amazon's recommendation or A/B testing, noting trade-offs in computational complexity, scalability, and ease of implementation.

Key Points to Mention

  • Regret bounds: epsilon-greedy linear, UCB and Thompson logarithmic
  • Exploration strategies: random vs. optimism vs. posterior sampling
  • Assumptions: stationarity, bounded rewards, Bayesian priors
  • Tuning parameters: epsilon for epsilon-greedy, confidence level for UCB, prior for Thompson
  • Computational complexity: Thompson sampling may be more expensive due to posterior updates
  • Practical considerations: Thompson sampling often performs well in practice but requires a model; UCB is deterministic and easier to implement; epsilon-greedy is simple but inefficient

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

How would you extend standard bandit approaches to contextual bandits, and what changes in terms of modeling and complexity?

Technical Trade-offsSystem Design
Author's notes

Talked about using context features to condition the policy, which is the whole point.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining the standard multi-armed bandit problem and its limitations, then explain how contextual bandits incorporate side information (context) to make decisions. Discuss the modeling changes (e.g., using context to predict rewards) and the increased complexity in terms of exploration-exploitation trade-offs, computational requirements, and data efficiency. Finally, highlight practical considerations for implementing contextual bandits in production systems.

Pro tip: Emphasize that contextual bandits are not just about adding features; they require careful design of the exploration strategy to avoid bias and ensure efficient learning, especially in non-stationary environments. Mention real-world applications like personalized recommendations at Amazon to demonstrate practical insight.

1. Define Standard Bandits

Briefly explain the standard multi-armed bandit problem: a set of arms with unknown reward distributions, and the goal to maximize cumulative reward by balancing exploration and exploitation.

2. Introduce Context

Describe how contextual bandits extend this by observing a context (feature vector) before choosing an arm, and the reward depends on both the arm and the context.

3. Modeling Changes

Discuss modeling approaches: e.g., linear models (LinUCB), logistic regression, or deep neural networks to estimate expected reward given context and arm. Mention the need for function approximation to generalize across contexts.

4. Complexity Considerations

Explain increased complexity: exploration strategies (e.g., Thompson sampling, UCB) must account for context; computational cost grows with context dimensionality; data efficiency and sample complexity increase; and non-stationarity may require adaptive methods.

5. Practical Implications

Highlight trade-offs: richer context can improve personalization but may lead to overfitting or slow learning; need for scalable infrastructure for real-time inference and logging; evaluation metrics like off-policy evaluation.

Key Points to Mention

  • Exploration-exploitation trade-off in contextual settings (e.g., LinUCB, Thompson sampling with context)
  • Function approximation techniques (linear models, neural networks) to handle high-dimensional contexts
  • Sample complexity and regret bounds: contextual bandits have higher regret due to context variability
  • Computational and memory complexity: scaling to large context spaces and many arms
  • Off-policy evaluation and counterfactual reasoning for model assessment
  • Real-world applications: personalized recommendations, dynamic pricing, and ad placement

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

How do you handle delayed or batched rewards in a bandit system?

Technical Trade-offsSystem Design
Author's notes

Blanked for a second.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by framing the problem: delayed or batched rewards introduce feedback latency, which breaks the standard bandit assumption of immediate reward observation. Then discuss trade-offs between exploration strategies (e.g., optimistic initialization, Thompson sampling) and practical solutions like reward imputation, delayed feedback models, or batching with credit assignment. Emphasize the need to balance exploration and exploitation under uncertainty, and mention how you would evaluate and monitor such a system.

Pro tip: Highlight that in production systems like Amazon's, delayed rewards are often the norm (e.g., purchases after clicks), so you should design for it from the start rather than treating it as an edge case. Mention that you would log all context and actions to enable offline counterfactual evaluation and credit assignment.

1. Clarify the problem and constraints

Ask about the nature of delay (fixed vs. variable), batch size, and whether rewards are partial or full. Understand business impact: how does delay affect user experience and revenue?

2. Choose an algorithmic approach

Discuss options like delayed feedback bandits (e.g., using survival analysis or hazard models), reward imputation (e.g., expected reward based on historical data), or batching with delayed updates. Compare trade-offs: simplicity vs. accuracy, computational cost, and adaptability.

3. Address credit assignment and exploration

Explain how to attribute delayed rewards to past actions (e.g., via inverse propensity scoring or temporal difference learning). Ensure exploration continues despite delayed feedback, perhaps using optimistic estimates or Thompson sampling with delayed updates.

4. Implement and monitor

Describe logging all decisions and contexts, and setting up offline evaluation (e.g., replay) and online A/B tests. Monitor for bias and drift, and have fallback strategies if delays increase.

5. Evaluate trade-offs and iterate

Summarize key trade-offs: complexity vs. performance, short-term vs. long-term rewards, and computational overhead. Emphasize iterative improvement based on metrics like regret or conversion rate.

Key Points to Mention

  • Delayed feedback breaks the i.i.d. assumption and can lead to stale exploration.
  • Techniques: reward imputation, survival analysis, hazard models, and delayed Thompson sampling.
  • Credit assignment: inverse propensity scoring, temporal difference, or counterfactual reasoning.
  • Batching strategies: update models periodically rather than per interaction, but beware of increased regret.
  • Evaluation: offline replay with logged data, counterfactual estimators, and online A/B testing.
  • Production considerations: logging, monitoring, and fallback mechanisms for when delays exceed expectations.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q5

How do you detect and handle non-stationarity or distribution drift in a deployed bandit?

Technical Trade-offsRoot Cause Analysis
Author's notes

Mentioned sliding windows, discounted updates, change-point detection.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining what non-stationarity and distribution drift mean in the context of a deployed bandit, then outline a systematic approach to detect drift using statistical tests and monitoring metrics, and finally describe how to adapt the bandit algorithm to handle drift, emphasizing trade-offs between exploration and exploitation. Use a concrete example from your experience to illustrate the process.

Pro tip: Emphasize the importance of setting up automated alerts and dashboards for real-time monitoring of reward distributions and action selection probabilities, as this shows you understand production ML systems. Also, mention that drift detection should be integrated into the bandit's feedback loop to enable automatic adaptation.

1. Define and Monitor Key Metrics

Identify metrics such as reward distribution, action selection probabilities, and context distribution that can indicate drift. Set up continuous monitoring with statistical process control or windowed comparisons.

2. Detect Drift Statistically

Apply statistical tests like Kolmogorov-Smirnov, chi-squared, or Page-Hinkley to detect changes in reward or context distributions. Use sequential testing to minimize false positives.

3. Diagnose Root Cause

Determine whether drift is due to changes in user behavior, environment, or the bandit's own actions (e.g., feedback loops). Analyze if the drift is gradual or abrupt.

4. Adapt the Bandit Algorithm

Choose an adaptation strategy: for gradual drift, use discounting or sliding windows; for abrupt drift, reset or re-initialize priors. Consider contextual bandits with change detection.

5. Evaluate and Iterate

Measure the impact of adaptation on key metrics like cumulative regret or conversion rate. Use A/B testing to validate changes and iterate on the detection and adaptation mechanisms.

Key Points to Mention

  • Types of drift: covariate shift, concept drift, and reward drift.
  • Statistical tests for drift detection: ADWIN, Page-Hinkley, KL divergence.
  • Adaptation techniques: sliding window, exponential discounting, and Bayesian change point detection.
  • Trade-offs: sensitivity vs. false positives, adaptation speed vs. stability.
  • Integration with production systems: monitoring, alerting, and automated retraining.
  • Amazon-specific: customer behavior changes, seasonality, and the need for scalable solutions.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q6

How would you do offline policy evaluation for a bandit before deploying it to production?

A/B Testing & ExperimentationTechnical Trade-offs
Author's notes

Inverse propensity scoring came up, doubly robust estimators too.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining the evaluation goal and the data available (logged bandit feedback). Then describe offline estimators like IPS, DM, and DR, emphasizing their assumptions and trade-offs. Finally, discuss validation techniques and how to decide when the policy is ready for production.

Pro tip: Always check for support overlap between the logging policy and the new policy; if the new policy takes actions rarely seen in the logs, IPS estimates become high-variance and unreliable. Mentioning this shows practical awareness of a common pitfall.

1. Clarify the evaluation setup

Define the target policy, the logging policy that generated the data, and the reward metric. Confirm that the logged data includes propensities (action probabilities) and rewards.

2. Choose offline estimators

Select appropriate estimators such as Inverse Propensity Scoring (IPS), Direct Method (DM), or Doubly Robust (DR). Explain how each works and their bias-variance trade-offs.

3. Validate and diagnose

Use techniques like cross-validation, bootstrapping for confidence intervals, and check for support overlap (common support). Consider sensitivity analysis to unobserved confounders if applicable.

4. Compare and decide

Compare the new policy against the logging policy and possibly other baselines. Use the estimates and confidence intervals to decide if the new policy is likely to improve performance.

5. Plan for production deployment

Outline a safe deployment strategy, such as a small-scale A/B test or a gradual rollout, to further validate the policy in the live environment.

Key Points to Mention

  • Inverse Propensity Scoring (IPS) and its variance issues
  • Direct Method (DM) and its reliance on a reward model
  • Doubly Robust (DR) estimator combining IPS and DM
  • Importance of support overlap and propensity clipping
  • Confidence intervals and statistical significance
  • Limitations of offline evaluation and need for online validation

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q7

What safety mechanisms or guardrails would you put around a bandit system running in production?

System DesignTechnical Trade-offs
Author's notes

Good question to end on and I actually felt okay here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by framing the core risks of bandit systems in production—exploration causing user harm, reward hacking, and feedback loops—then present a layered defense strategy covering offline validation, online guardrails, and continuous monitoring. Emphasize how each mechanism balances exploration with safety and business constraints, and tie it back to Amazon's customer-obsession and operational excellence principles.

Pro tip: Propose a 'circuit breaker' that automatically reverts to a known-safe policy when guardrail metrics breach thresholds, and mention how you'd simulate adversarial scenarios (e.g., reward manipulation) in a pre-production environment to validate the guardrails themselves.

1. Identify Risks and Failure Modes

Enumerate potential harms: unsafe recommendations, reward hacking, feedback loops, and distribution shift. Prioritize risks based on user impact and likelihood.

2. Offline Validation and Simulation

Use historical data and counterfactual evaluation to test the bandit policy. Run adversarial simulations to stress-test reward functions and guardrails before deployment.

3. Online Guardrails and Constraints

Implement hard constraints (e.g., action whitelists, budget caps), safety filters, and a fallback policy. Use a shadow mode or canary deployment to limit exposure.

4. Monitoring and Automated Response

Track guardrail metrics (e.g., CTR, safety violations) in real time. Set up alerts and a circuit breaker that reverts to a safe policy if thresholds are breached.

5. Governance and Iteration

Establish a review process for policy updates, document decisions, and periodically re-evaluate guardrails. Incorporate human-in-the-loop for high-stakes actions.

Key Points to Mention

  • Exploration-exploitation trade-off and how to bound exploration (e.g., epsilon-decreasing, Thompson sampling with priors).
  • Reward shaping and validation to prevent reward hacking (e.g., using multiple metrics, human evaluation).
  • Safety constraints and action filtering (e.g., whitelists, blacklists, business rules).
  • Monitoring and alerting on guardrail metrics (e.g., safety violations, user satisfaction).
  • Fallback mechanisms and circuit breakers to revert to a safe policy.
  • A/B testing and canary deployments to limit blast radius.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.