← Amazon Interview Insights

Amazon·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
Jun 2026

Summary

Amazon ML Engineer interview that went deep on LLM internals, fine-tuning techniques, and training best practices. Felt more like a technical seminar than a standard screen. The breadth was a lot to cover in one sitting.

Questions Asked (5)

Q1

Compare encoder-decoder and decoder-only Transformer architectures. Walk through the decoder-only stack in detail, including self-attention, feed-forward blocks, normalization, and residual connections.

System DesignTechnical Trade-offs
Author's notes

This is the kind of question where you think you know it cold and then halfway through your explanation you realize you're fuzzy on why layer norm goes before or after attention in modern implementations.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by contrasting the two architectures at a high level, focusing on how the encoder-decoder uses cross-attention for sequence-to-sequence tasks while the decoder-only relies solely on self-attention with causal masking for autoregressive generation. Then, walk through the decoder-only stack layer by layer, explaining the purpose and mechanics of each component. Conclude with trade-offs in terms of training efficiency, inference speed, and suitability for different tasks.

Pro tip: Emphasize that decoder-only models like GPT have become dominant for generative tasks due to their simplicity and scalability, but encoder-decoder models like T5 still excel in tasks requiring explicit input understanding, such as translation. Mentioning real-world examples (e.g., Amazon's use of such models in Alexa or product description generation) shows practical awareness.

1. High-level comparison

Contrast encoder-decoder and decoder-only architectures: encoder-decoder has separate encoder and decoder stacks with cross-attention, while decoder-only has a single stack with causal self-attention. Highlight typical use cases: encoder-decoder for seq2seq (translation, summarization), decoder-only for language modeling and generation.

2. Decoder-only stack overview

Describe the overall structure: a stack of identical layers, each containing a masked self-attention sub-layer and a feed-forward network, with residual connections and layer normalization around each sub-layer. Mention that the input is embedded and combined with positional encodings.

3. Self-attention mechanism

Explain masked self-attention: each position attends to previous positions only (causal masking) to preserve autoregressive property. Detail how queries, keys, and values are computed, scaled dot-product attention, and multi-head attention for capturing diverse relationships.

4. Feed-forward and normalization

Describe the position-wise feed-forward network: two linear transformations with a ReLU activation in between, applied independently to each position. Explain layer normalization: applied before or after sub-layers (pre-LN vs post-LN) and its role in stabilizing training.

5. Residual connections and trade-offs

Discuss residual connections that add the input of a sub-layer to its output, mitigating vanishing gradients and enabling deep stacks. Summarize trade-offs: decoder-only is simpler, more parallelizable during training, and efficient for generation, but may lack the explicit encoding of input that encoder-decoder provides for certain tasks.

Key Points to Mention

  • Causal masking in self-attention ensures autoregressive generation.
  • Multi-head attention allows the model to focus on different representation subspaces.
  • Position-wise feed-forward networks introduce non-linearity and increase model capacity.
  • Layer normalization and residual connections are crucial for training stability and deep networks.
  • Encoder-decoder architectures use cross-attention to condition on the encoder's output, beneficial for tasks like translation.
  • Decoder-only models (e.g., GPT) are dominant for generative tasks due to scalability and simplicity, while encoder-decoder models (e.g., T5) are still strong for seq2seq tasks.

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

Q2

How are positional embeddings handled in LLMs? Compare absolute, relative, and rotary approaches and describe the trade-offs.

Technical Trade-offsSystem Design
Author's notes

Rotary embeddings tripped me up a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by explaining the purpose of positional embeddings in transformers, then systematically compare absolute, relative, and rotary approaches, highlighting their mechanisms and trade-offs. Conclude with practical considerations for choosing an approach in real-world systems, especially at scale like Amazon.

Pro tip: Emphasize that rotary embeddings (RoPE) are widely adopted in state-of-the-art LLMs due to their efficiency and length generalization, but mention that relative approaches like T5's bucketed relative bias are still relevant for certain tasks. Show awareness of implementation details like precomputation and memory overhead.

1. Explain the need for positional information

Describe why transformers lack inherent sequence order and how positional embeddings inject this information, affecting model performance and capabilities.

2. Compare absolute, relative, and rotary approaches

Define each method: absolute (learned or sinusoidal), relative (learned biases based on distance), and rotary (rotating query/key vectors). Highlight their key differences in formulation and application.

3. Discuss trade-offs

Analyze trade-offs: absolute is simple but limited in extrapolation; relative offers better length generalization but adds complexity; rotary is efficient and extrapolates well but may require careful implementation.

4. Relate to practical LLM systems

Connect to real-world usage: mention that models like GPT-3 use absolute, T5 uses relative, and LLaMA uses rotary. Discuss implications for training stability, inference speed, and memory.

5. Conclude with recommendations

Summarize when to choose each approach based on requirements like sequence length, computational budget, and task type, showing engineering judgment.

Key Points to Mention

  • Absolute embeddings: learned (e.g., BERT) vs. sinusoidal (original Transformer); fixed length limitation.
  • Relative embeddings: e.g., T5's bucketed relative bias; better for long sequences but adds parameters and computation.
  • Rotary embeddings (RoPE): used in LLaMA, GPT-NeoX; encodes position by rotating query/key vectors; efficient and supports length extrapolation.
  • Trade-offs: absolute is simple but poor extrapolation; relative is flexible but complex; rotary is efficient and generalizes but may need tuning.
  • Implementation considerations: precomputation of frequencies, memory overhead, compatibility with FlashAttention.
  • Impact on model performance: effect on long-context tasks, training stability, and inference speed.

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

Q3

Describe your hands-on experience fine-tuning large language models. When would you use LoRA versus other adapter-based methods?

Technical Trade-offsSystem Design
Author's notes

My strongest answer of the session.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by briefly describing a specific project where you fine-tuned an LLM, including the model, dataset, and goal. Then compare LoRA with other adapter-based methods like prefix tuning and adapter layers, focusing on trade-offs in performance, efficiency, and use case. Conclude with a clear decision framework for when to use each method.

Pro tip: Quantify the impact: mention metrics like training time reduction, memory savings, or accuracy improvements from your experience. Also, relate the trade-offs to Amazon's scale and cost-efficiency priorities.

1. Set the context with a concrete example

Describe a specific fine-tuning project you worked on, including the model, dataset size, task, and why you chose a particular method.

2. Explain LoRA and its advantages

Define LoRA and highlight its benefits: parameter efficiency, reduced memory footprint, and ability to maintain base model knowledge.

3. Compare with other adapter-based methods

Discuss alternatives like prefix tuning, adapter layers, and IA3, contrasting their architecture, performance, and computational requirements.

4. Provide a decision framework

Outline when to use LoRA versus others based on factors like task complexity, available compute, need for multi-task serving, and latency constraints.

5. Relate to Amazon's context

Connect your experience to Amazon's scale, cost sensitivity, and production needs, emphasizing practical trade-offs.

Key Points to Mention

  • LoRA's low-rank decomposition and how it reduces trainable parameters
  • Comparison of LoRA with prefix tuning, adapter layers, and IA3 in terms of performance and efficiency
  • Trade-offs between parameter efficiency, training speed, and model quality
  • Use cases: when to choose LoRA (e.g., limited compute, multi-task) vs. full fine-tuning or other adapters
  • Practical considerations: memory usage, inference latency, and deployment complexity
  • Quantitative results from your experience (e.g., 'LoRA reduced training time by 60% with minimal accuracy drop')

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

Q4

During LLM training, how do you prevent overfitting? What regularization strategies, data augmentation techniques, or early stopping criteria do you use?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Went through dropout, weight decay, and learning rate scheduling.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by acknowledging that LLM overfitting is typically addressed through a combination of regularization, data augmentation, and early stopping, but emphasize that the best strategy depends on model size, dataset size, and training objectives. Then walk through each category with specific techniques you've used, highlighting trade-offs and how you monitor validation metrics to make decisions.

Pro tip: Mention that for LLMs, overfitting often manifests as memorization of training data, so techniques like dropout on attention weights, weight decay, and data deduplication are particularly effective. Also, note that early stopping should be based on multiple metrics (e.g., validation loss, downstream task performance) rather than a single one.

1. Define overfitting in the LLM context

Explain that overfitting in LLMs often means the model memorizes training data and fails to generalize, which can be detected by a widening gap between training and validation loss.

2. Discuss regularization strategies

Cover techniques like dropout (especially attention dropout), weight decay (AdamW), and label smoothing, and explain how they help prevent overfitting.

3. Describe data augmentation and preprocessing

Mention techniques such as data deduplication, token-level augmentation (e.g., random masking, synonym replacement), and using diverse data sources to improve generalization.

4. Explain early stopping criteria

Detail how you monitor validation metrics (e.g., validation loss, perplexity, downstream task accuracy) and use patience-based early stopping with a threshold to avoid overfitting.

5. Highlight trade-offs and practical considerations

Discuss the balance between regularization strength and model capacity, and how you tune hyperparameters (e.g., dropout rate, weight decay) based on compute budget and dataset size.

Key Points to Mention

  • Dropout on attention weights and feed-forward layers
  • Weight decay (e.g., AdamW optimizer) and its interaction with learning rate
  • Data deduplication and quality filtering to reduce memorization
  • Early stopping based on validation loss with patience and restore best weights
  • Label smoothing for classification tasks
  • Monitoring multiple metrics (e.g., validation loss, downstream task performance) to avoid overfitting to a single metric

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

Q5

How do you evaluate a fine-tuned LLM? Walk through both intrinsic and extrinsic metrics, and explain how offline validation differs from online validation.

A/B Testing & ExperimentationProduct Analytics & Metrics
Author's notes

The offline vs online distinction is one I actually care about, so this went well.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining the evaluation goal and the distinction between intrinsic and extrinsic metrics, then walk through concrete examples of each. Finally, contrast offline validation (using held-out datasets) with online validation (A/B testing in production), emphasizing how they complement each other.

Pro tip: Always tie metrics back to business impact—Amazon cares about customer outcomes, so highlight how you'd choose metrics that directly influence key performance indicators like conversion or customer satisfaction.

1. Clarify evaluation objectives

Begin by stating that evaluation depends on the task (e.g., classification, generation) and the goal (e.g., improve accuracy, reduce toxicity). This shows you tailor your approach.

2. Explain intrinsic metrics

Describe metrics computed on a held-out test set, such as accuracy, F1, BLEU, ROUGE, perplexity, or task-specific metrics. Mention that these are fast and cheap but may not reflect real-world performance.

3. Explain extrinsic metrics

Discuss metrics tied to downstream applications or user behavior, like click-through rate, conversion, user engagement, or human evaluation scores. These are more aligned with business impact but harder to measure.

4. Contrast offline vs. online validation

Offline validation uses static datasets and is done before deployment; online validation involves live traffic, A/B tests, and monitoring. Highlight that offline is for rapid iteration, online for causal inference and real-world impact.

5. Discuss trade-offs and best practices

Emphasize the need for both: offline to filter candidates, online to confirm. Mention pitfalls like overfitting to offline metrics, distribution shift, and the importance of statistical significance in online tests.

Key Points to Mention

  • Intrinsic metrics: accuracy, F1, BLEU, ROUGE, perplexity, exact match
  • Extrinsic metrics: user engagement, conversion rate, task success rate, human evaluation
  • Offline validation: held-out test set, cross-validation, no user impact, fast iteration
  • Online validation: A/B testing, interleaving, canary deployment, real user feedback
  • Trade-offs: offline may not correlate with online; online is costly and risky
  • Amazon context: customer obsession, metrics tied to business KPIs, statistical rigor

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