← Amazon Interview Insights

Amazon·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
May 2026

Summary

Amazon ML Engineer interview focused heavily on LLM fundamentals, covering everything from tokenization internals to inference optimization and safety. A lot of ground to cover and the breadth of it was a bit exhausting.

Questions Asked (7)

Q1

How does subword tokenization work, and why do modern LLMs use it instead of word-level or character-level approaches?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Walked through BPE: start with characters, merge the most frequent adjacent pairs iteratively until you hit your vocab size.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining subword tokenization and explaining its core idea of breaking words into frequent subunits. Then compare it to word-level and character-level approaches, highlighting trade-offs in vocabulary size, OOV handling, and sequence length. Finally, discuss why modern LLMs like BERT and GPT adopt subword methods, emphasizing balance between efficiency and expressiveness.

Pro tip: Mention specific algorithms like BPE, WordPiece, or SentencePiece and how they handle rare words, showing practical knowledge. Also, relate it to real-world implications like multilingual support and memory efficiency, which are crucial at scale.

1. Define Subword Tokenization

Explain that subword tokenization splits text into units smaller than words but larger than characters, often based on frequency. Mention common algorithms like BPE, WordPiece, or Unigram.

2. Compare with Word-Level and Character-Level

Contrast subword with word-level (large vocabulary, OOV issues) and character-level (long sequences, loss of semantic meaning). Highlight how subword balances these extremes.

3. Discuss Trade-offs and Benefits

Cover benefits: reduced vocabulary size, handling of rare words, efficient sequence length, and better generalization. Mention trade-offs like potential loss of morphological clarity.

4. Explain Adoption in Modern LLMs

Describe why LLMs use subword tokenization: scalability, multilingual support, and ability to capture meaningful subunits. Reference models like BERT, GPT, and T5.

5. Conclude with Practical Implications

Summarize how subword tokenization enables efficient training and inference, and its importance for handling diverse text data in real-world applications.

Key Points to Mention

  • Subword tokenization algorithms: BPE, WordPiece, SentencePiece, Unigram
  • Trade-offs: vocabulary size vs. sequence length vs. semantic granularity
  • Handling of out-of-vocabulary (OOV) words and rare words
  • Efficiency in model size, memory, and computation
  • Multilingual and domain adaptation benefits
  • Examples from modern LLMs (BERT, GPT, T5) and their tokenization methods

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

Q2

Explain how self-attention works and why its computational cost scales quadratically. What approaches exist to reduce that cost?

System DesignTechnical Trade-offs
Author's notes

The O(n^2) part is easy to explain: every token attends to every other token, so the attention matrix is n by n.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by explaining the self-attention mechanism mathematically, then derive the quadratic complexity from the matrix multiplications. Finally, discuss efficient attention variants, categorizing them by their approach (e.g., sparsity, low-rank, kernel-based) and trade-offs.

Pro tip: Relate the quadratic cost to real-world constraints like sequence length and memory, and mention that Amazon often deals with long sequences in NLP and recommendation systems, so efficient attention is critical for production.

1. Define self-attention

Explain that self-attention computes a weighted sum of all positions in a sequence, where weights are based on pairwise similarity between queries and keys.

2. Derive quadratic complexity

Show that for a sequence of length n, computing the attention scores requires n x n matrix multiplication, leading to O(n^2) time and memory complexity.

3. Discuss implications

Highlight that quadratic scaling limits the maximum sequence length and increases computational cost, especially for long sequences.

4. Survey efficient attention methods

Describe approaches like sparse attention (e.g., Longformer), low-rank approximations (e.g., Linformer), kernel-based methods (e.g., Performer), and recurrence (e.g., Transformer-XL).

5. Compare trade-offs

Discuss the trade-offs between efficiency and accuracy, and mention that some methods reduce complexity to O(n) or O(n log n) at the cost of expressiveness.

Key Points to Mention

  • Self-attention computes pairwise interactions between all positions in a sequence.
  • Quadratic complexity arises from the n x n attention matrix, requiring O(n^2) time and memory.
  • Efficient attention methods include sparse, low-rank, kernel-based, and recurrent approaches.
  • Trade-offs: reduced complexity often sacrifices accuracy or requires additional assumptions.
  • Practical considerations: memory bottlenecks, hardware efficiency, and implementation complexity.
  • Amazon's scale: long sequences in NLP, recommendations, and time-series data necessitate efficient attention.

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

Q3

What are the differences between pretraining, instruction tuning, and alignment techniques like RLHF or DPO?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Pretty comfortable here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer by contrasting the three stages in terms of their objectives, data, and training methods. Highlight how each stage builds on the previous one to produce a capable, safe, and helpful model. Use concrete examples to illustrate the differences and trade-offs.

Pro tip: Emphasize that alignment techniques like RLHF and DPO are not just about safety but also about aligning the model with human preferences and business objectives, which is crucial for deployment at scale. Mention that DPO simplifies the RLHF pipeline by directly optimizing on preference data, reducing complexity and cost.

1. Define Pretraining

Explain that pretraining involves training a large model on vast amounts of unlabeled text data to learn general language representations and world knowledge. It uses self-supervised objectives like masked language modeling or next-token prediction.

2. Define Instruction Tuning

Describe instruction tuning as supervised fine-tuning on a dataset of instruction-response pairs to teach the model to follow specific instructions and perform tasks. It bridges the gap between raw language understanding and task execution.

3. Define Alignment Techniques

Introduce RLHF and DPO as methods to align model outputs with human values and preferences. RLHF uses reinforcement learning from human feedback, while DPO directly optimizes the policy on preference data without a reward model.

4. Compare Objectives and Data

Contrast the objectives: pretraining for general knowledge, instruction tuning for task adherence, and alignment for safety and preference alignment. Highlight differences in data: unlabeled text, instruction-response pairs, and human preference comparisons.

5. Discuss Trade-offs and Use Cases

Explain when each stage is necessary and the trade-offs: pretraining is compute-intensive but foundational; instruction tuning improves usability; alignment ensures safety and alignment with business goals. Mention that DPO is simpler and more stable than RLHF but may have different performance characteristics.

Key Points to Mention

  • Pretraining uses self-supervised learning on large unlabeled corpora to build a foundation model.
  • Instruction tuning is supervised fine-tuning on diverse instruction-response pairs to improve zero-shot and few-shot performance.
  • RLHF involves training a reward model from human preferences and then fine-tuning the language model using reinforcement learning (e.g., PPO).
  • DPO directly optimizes the language model on human preference data without a separate reward model, simplifying the pipeline.
  • Alignment techniques aim to make models helpful, honest, and harmless, aligning with human values and reducing harmful outputs.
  • Trade-offs include computational cost, data requirements, and complexity: pretraining is most expensive, alignment is least but crucial for deployment.

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

Q4

Describe how you would design a RAG system, including how you'd handle indexing, chunking strategy, embedding choices, and the tradeoff between sparse and dense retrieval.

System DesignTechnical Trade-offs
Author's notes

This one took a while.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements (e.g., data volume, query types, latency, accuracy) and then walk through the end-to-end RAG pipeline: indexing, chunking, embedding, retrieval, and generation. Emphasize trade-offs at each stage, especially sparse vs. dense retrieval, and justify choices based on the use case.

Pro tip: Demonstrate awareness of Amazon's scale and cost constraints by discussing hybrid retrieval and the importance of evaluating retrieval quality with metrics like recall@k and MRR. Also, mention how you would iterate based on user feedback and A/B testing.

1. Clarify Requirements and Constraints

Ask about data size, query types, latency, accuracy, and cost constraints to tailor the design. This shows you can align technical decisions with business needs.

2. Design Indexing and Chunking Strategy

Explain how you would preprocess documents, choose chunk sizes (e.g., fixed-size, semantic, or recursive), and build an index that supports efficient retrieval. Consider overlap and metadata.

3. Select Embedding Models and Retrieval Methods

Discuss embedding choices (e.g., pre-trained vs. fine-tuned, domain-specific) and compare sparse (e.g., BM25) vs. dense (e.g., bi-encoders) retrieval, including hybrid approaches.

4. Address Trade-offs and Optimization

Analyze trade-offs: sparse retrieval is efficient and interpretable but may miss semantic matches; dense retrieval captures semantics but is computationally heavy. Propose hybrid or reranking to balance.

5. Evaluate and Iterate

Describe how you would measure retrieval and end-to-end performance (e.g., recall@k, MRR, answer accuracy) and iterate on chunking, embeddings, and retrieval based on metrics.

Key Points to Mention

  • Chunking strategies: fixed-size, semantic, recursive, and their impact on retrieval quality.
  • Embedding choices: trade-offs between pre-trained models (e.g., Sentence-BERT) and fine-tuned domain-specific models.
  • Sparse vs. dense retrieval: BM25 vs. bi-encoders, and when to use each.
  • Hybrid retrieval: combining sparse and dense methods to improve recall and precision.
  • Indexing: use of vector databases (e.g., FAISS, Annoy) and inverted indices for scalability.
  • Evaluation metrics: recall@k, MRR, NDCG, and end-to-end answer accuracy.

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

Q5

How do you decide between prompting, fine-tuning, and parameter-efficient methods like adapters for a given use case?

Technical Trade-offsProduct Strategy
Author's notes

My framing was: prompting first, always.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Frame your answer around a decision framework that starts with the problem requirements—data availability, latency, cost, and maintenance—then evaluates each technique against those constraints. Emphasize that prompting is best for rapid prototyping and low-data scenarios, fine-tuning for high-stakes tasks with ample labeled data, and parameter-efficient methods like adapters for a balance of performance and efficiency. Conclude with a concrete example from your experience to demonstrate practical application.

Pro tip: At Amazon, always tie your decision to business impact and customer obsession—e.g., how the choice affects latency, cost per inference, and time-to-market—and mention that you'd start with the simplest approach (prompting) and only escalate complexity if metrics justify it.

1. Define the problem and constraints

Clarify the task, performance metrics, available data, latency requirements, budget, and deployment environment. This sets the criteria for evaluating techniques.

2. Evaluate prompting

Assess if prompting (zero-shot, few-shot, chain-of-thought) can meet requirements with minimal effort and no training. Consider its limitations in consistency and complex tasks.

3. Assess fine-tuning

Determine if full fine-tuning is necessary for high accuracy, but weigh it against data needs, compute cost, and risk of catastrophic forgetting.

4. Consider parameter-efficient methods

Explore adapters, LoRA, or prefix-tuning when you need fine-tuning benefits with fewer parameters, faster training, and easier deployment across multiple tasks.

5. Decide and iterate

Choose the approach that best balances performance, cost, and maintainability, and plan to iterate based on monitoring and feedback.

Key Points to Mention

  • Data availability and quality: prompting requires no labeled data, fine-tuning needs substantial data, PEFT can work with moderate data.
  • Compute and cost: prompting is cheapest, fine-tuning is expensive, PEFT reduces training and storage costs.
  • Latency and inference: prompting may have higher latency due to longer prompts, fine-tuned models can be optimized, PEFT adds minimal overhead.
  • Task complexity and performance: prompting may suffice for simple tasks, fine-tuning for complex, PEFT for a balance.
  • Maintenance and scalability: PEFT allows easy swapping of adapters for multiple tasks, fine-tuning requires separate models.
  • Business impact: align choice with time-to-market, customer experience, and operational costs.

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

Q6

What techniques do you use to optimize LLM inference for low latency, specifically around quantization, KV caching, and batching?

System DesignTechnical Trade-offs
Author's notes

Quantization reduces weight precision (INT8, INT4) to shrink memory and speed up matmuls at some accuracy cost.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer around the three pillars—quantization, KV caching, and batching—and for each, explain the technique, its latency benefit, and the trade-off it introduces. Emphasize that optimization is workload-dependent and requires profiling to balance latency, throughput, and accuracy. Conclude with a concrete example of how you combined these techniques in a production system.

Pro tip: Quantify the impact where possible (e.g., 'INT8 quantization reduced latency by 40% with <1% accuracy drop') and mention that you always validate with real traffic patterns, not just benchmarks. This shows you understand production constraints and avoid over-optimizing for synthetic data.

1. Clarify the latency budget and workload

Start by asking about the specific latency target (e.g., p99 < 100ms), request patterns (batch vs. real-time), and hardware constraints. This ensures your answer is tailored and demonstrates you don't apply optimizations blindly.

2. Explain quantization techniques

Discuss post-training quantization (PTQ) and quantization-aware training (QAT), covering INT8/FP8 and their impact on latency and accuracy. Mention that lower precision reduces memory bandwidth and compute time, but may require calibration or fine-tuning to maintain quality.

3. Detail KV caching strategies

Describe how KV caching avoids recomputing keys/values for autoregressive decoding, and advanced variants like paged attention (vLLM) or multi-query attention to reduce memory footprint. Highlight that cache management is critical for long sequences and high concurrency.

4. Cover batching approaches

Explain continuous batching (iteration-level scheduling) and dynamic batching to maximize GPU utilization without increasing latency. Contrast with static batching and note that continuous batching is key for online serving with variable sequence lengths.

5. Discuss trade-offs and measurement

Summarize how these techniques interact: quantization may affect batching efficiency, KV cache size limits batch size, etc. Emphasize the need for profiling (e.g., using NVIDIA Nsight, TensorRT) and A/B testing to find the optimal configuration for your SLA.

Key Points to Mention

  • Post-training quantization (PTQ) vs. quantization-aware training (QAT) and their latency/accuracy trade-offs
  • KV cache memory management, including paged attention and multi-query attention
  • Continuous batching (iteration-level scheduling) for online inference
  • Hardware-specific optimizations (e.g., TensorRT, CUDA graphs, FlashAttention)
  • Profiling and benchmarking with real traffic to validate latency improvements
  • Trade-offs between latency, throughput, and model accuracy

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

Q7

How do you evaluate LLM outputs, and what strategies do you use to reduce hallucinations and manage safety risks?

Technical Trade-offsProduct Analytics & Metrics
Author's notes

Task-specific metrics where you can get them: exact match, ROUGE, code execution pass rates.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer around a systematic evaluation framework that covers both automated metrics and human judgment, then explain how you use that evaluation to iteratively reduce hallucinations and manage safety risks. Emphasize a layered defense strategy that combines model-level improvements, retrieval augmentation, and guardrails, and tie it back to Amazon's customer-obsession and operational excellence principles.

Pro tip: Highlight the importance of defining clear evaluation criteria and building a golden dataset early, as this prevents subjective debates and enables measurable progress. Also, mention that you treat safety and hallucination reduction as continuous processes, not one-time fixes, and that you monitor production outputs to catch regressions.

1. Define Evaluation Criteria and Metrics

Start by clarifying what 'good' looks like for your use case: correctness, faithfulness, relevance, safety, and tone. Then select a mix of automated metrics (e.g., BLEU, ROUGE, BERTScore, perplexity) and human evaluation protocols (e.g., Likert scales, pairwise comparisons) that align with these criteria.

2. Build a Golden Dataset and Benchmark

Curate a diverse, representative dataset with ground-truth answers and edge cases, including adversarial and safety-sensitive examples. Use this to benchmark models and track improvements over time, ensuring reproducibility and fairness.

3. Implement Hallucination Reduction Techniques

Employ strategies such as retrieval-augmented generation (RAG) to ground responses in external knowledge, fine-tuning on domain-specific data, and prompt engineering to encourage citations or uncertainty expression. Also, use self-consistency checks and post-hoc verification against trusted sources.

4. Deploy Safety Guardrails and Moderation

Integrate content filters, toxicity classifiers, and rule-based constraints to block harmful outputs. Use techniques like red-teaming to identify vulnerabilities, and implement human-in-the-loop review for high-risk scenarios.

5. Monitor, Iterate, and Close the Loop

Continuously monitor production outputs for hallucinations and safety violations using automated alerts and user feedback. Feed these insights back into the evaluation dataset and model retraining to drive iterative improvements.

Key Points to Mention

  • Automated metrics (e.g., BLEU, ROUGE, BERTScore) and their limitations; need for human evaluation.
  • Retrieval-augmented generation (RAG) to ground responses and reduce hallucinations.
  • Fine-tuning and prompt engineering to improve factuality and safety.
  • Safety guardrails: content filters, toxicity detection, and red-teaming.
  • Human-in-the-loop evaluation and active learning for continuous improvement.
  • Amazon leadership principles: Customer Obsession, Dive Deep, and Deliver Results.

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